So WebStorm 2017.1.2 is out, so I added a configuration to run my tests.

Its seems to work (Thanks WebStorm devs !!) but there is still some problems:
This works:

But when I Moved global.a to setupTests.js it fails (console.log doesn't print on console as well)

It seems that setupTests isn't been run before each test, because all my test depends on setupTests.js, I can run any test.
notice that in terminal the same test is passes
also adding import '../../setupTests' in the test file will make it work in WebStorm also.
so the issue is that in WebStorm, setupTests.js does not run before each test.
@shai32 can you include "setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js", in your jest(in package.json). That should run setupTests before jest!
Something on these lines
// package.json
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"testPathIgnorePatterns": [
"<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]"
],
}
Let me know if it helps!
Yea, this will not be very smooth because WebStorm isn't aware of the configuration we're passing to Jest. So indeed your best option would be to (unfortunately) duplicate it in package.json as described by @anilreddykatta.
it works, thanks (should be added to docs)
but there is another problem.
this is the test:

this is the error

when running from terminal the test passes
@shai32 Please while running from webstorm add this to --env=jsdom to JEST options.
Let us know how it goes?
@anilreddykatta works!!!! :)
@shai32 Can you close if the issue is resolved?
Close - works when defining setupTestFrameworkScriptFile in package.json and add --env=jsdom to JEST options
This solution doesn't seem to work anymore without ejection:
These options in your package.json Jest configuration are not currently supported by Create React App:
• setupFiles
Most helpful comment
@shai32 Please while running from
webstormadd this to--env=jsdomto JEST options.Let us know how it goes?