TypeError: Cannot read property 'value' of undefined
Turbo87 opened this issue · comments
ERR tests/integration/helpers/format-duration-test.js Transformation error
TypeError: Cannot read property 'value' of undefined
at NodePath.<anonymous> (/private/var/folders/6y/_8qpkt114jzb442txt_9w_2c0000gn/T/jscodeshift117921-31469-1qh934w.snxof:249:27)
at __paths.forEach (/Users/tbieniek/.config/yarn/global/node_modules/jscodeshift/src/Collection.js:76:36)
at Array.forEach (native)
at Collection.forEach (/Users/tbieniek/.config/yarn/global/node_modules/jscodeshift/src/Collection.js:75:18)
at processSubject (/private/var/folders/6y/_8qpkt114jzb442txt_9w_2c0000gn/T/jscodeshift117921-31469-1qh934w.snxof:247:27)
at NodePath.<anonymous> (/private/var/folders/6y/_8qpkt114jzb442txt_9w_2c0000gn/T/jscodeshift117921-31469-1qh934w.snxof:303:11)
at NodePath.each (/Users/tbieniek/.config/yarn/global/node_modules/recast/node_modules/ast-types/lib/path.js:101:26)
at updateModuleForToNestedModule (/private/var/folders/6y/_8qpkt114jzb442txt_9w_2c0000gn/T/jscodeshift117921-31469-1qh934w.snxof:289:14)
at module.exports (/private/var/folders/6y/_8qpkt114jzb442txt_9w_2c0000gn/T/jscodeshift117921-31469-1qh934w.snxof:405:3)
The format-duration-test.js
file looks like this:
import { moduleFor, test } from 'ember-qunit';
import moment from 'moment';
function convertToMS(amount, unit) {
return moment.duration(amount, unit).asMilliseconds();
}
moduleFor('helper:format-duration', 'Integration | Helper | format duration', {
integration: true,
async beforeEach() {
await this.container.lookup('service:intl').loadAndSetLocale('en');
}
});
test('1 min', function(assert) {
let helper = this.subject();
let result = helper.compute([convertToMS(1, 'minute')]);
assert.equal(result, '1 min');
});
test('59 min', function(assert) {
let helper = this.subject();
let result = helper.compute([convertToMS(59, 'minutes')]);
assert.equal(result, '59 min');
});
test('1h00', function(assert) {
let helper = this.subject();
let result = helper.compute([convertToMS(1, 'hour')]);
assert.equal(result, '1h00');
});
test('1h01', function(assert) {
let helper = this.subject();
let result = helper.compute([convertToMS(61, 'minutes')]);
assert.equal(result, '1h01');
});
It looks like this is mainly an issue if integration: true
is set even though the test is actually a unit test
I thought I had fixtures for this case (moduleFor + integration: true + this.subject()), maybe I missed it.