-
Notifications
You must be signed in to change notification settings - Fork 51
Running Jest tests I got "The body of the arrow function supplied to idx
must be a single expression"
#19
Comments
hi @yungsters ,
When I run tests directly from Webstorm everything is OK But from console with |
@davscro Can you share the contents of your |
Sure @yungsters
setup-jasmine-env.js /* eslint-disable no-undef */
const jasmineReporters = require('jasmine-reporters');
jasmine.VERBOSE = true;
jasmine.getEnv().addReporter(
new jasmineReporters.JUnitXmlReporter({
consolidateAll: false,
savePath: './results',
filePrefix: 'test-results'
})
); test-setup.js window.matchMedia = window.matchMedia || function() {
return {
matches : false,
addListener : function() {},
removeListener: function() {}
};
}; |
I have the same problem. When I remove |
Interesting! I wonder if a coverage plugin is injecting extra AST nodes into the arrow function. Thanks for that insight. I'll need to brainstorm with @cpojer about how to best proceed. |
Is there anyway to work this around? I had the issue above a long time running, I thought to maybe implement a function identical to idx locally rather using the babel plugin. |
Hmm... this is an unfortunate collision between the two plugins. I don't have time to dig into this, but if we could identify the output of the coverage plugin, we can add a special case in Open to other ideas, too. |
Isn't idx just a "hopefully" temporary wrapper around the new optional chaining proposal? If there is currently a babel implementation of the optional chaining proposal, it would be interesting if jest coverage would work with them. Correct me if I'm wrong, but at least to me it seems that the babel implementation shouldn't be that different? |
const f = () => 'a'; turns during jest run with coverage into () => {/* istanbul ignore next */++cov_14mnsv87h8.f[0];++cov_14mnsv87h8.s[1];return 'a';} So, when this transformation applied to idx's fake function argument, it violates idx's assertions (not a single stmt, curly braces, referencing values other than single argument's properties, etc). |
Looks like babel 7 could solve this issue - it puts each plugin on separate compilation pass, which may prevent conflict between idx babel plugin and instanbul plugin, that included by babel-jest in babel config when we run jest with |
…ibly nullable properties on a JavaScript objects This also disables Jest code coverage because of babel plugins conflict. See: facebook/idx#19
You can also use the following workaround jestjs/jest#3549 (comment) TL;DR use the idx as a package, but don't take the compilation step for the test phase |
This issue is almost a year old now. I'm going to close it out, but please do file a new one if this is still a problem (with Babel 7). |
…ibly nullable properties on a JavaScript objects This also disables Jest code coverage because of babel plugins conflict. See: facebook/idx#19
When running Jest with `--coverage`, modules using idx fail with the error shown in facebook/idx#19. Change the babel configuration so that is `NODE_ENV=test`, the idx plugin is not loaded.
When running Jest with `--coverage`, modules using idx fail with the error shown in facebook/idx#19. Change the babel configuration so that is `NODE_ENV=test`, the idx plugin is not loaded.
When running Jest with `--coverage`, modules using idx fail with the error shown in facebook/idx#19. Change the babel configuration so that is `NODE_ENV=test`, the idx plugin is not loaded.
When running Jest with `--coverage`, modules using idx fail with the error shown in facebook/idx#19. Change the babel configuration so that is `NODE_ENV=test`, the idx plugin is not loaded.
The text was updated successfully, but these errors were encountered: