node -v: v8.6.0npm -v: yarn 1.1.0npm ls react-scripts (if you haven鈥檛 ejected): not a cra project
Operating system: OS X
Define a setup script in package.json, as explained in the jest docs
{
"jest": {
"setupTestFrameworkScriptFile": "./test-setup.js"
},
...
}
Jest should run the setup file. I use it to initialize enzyme with a React adapter.
Jest does load the setup file when called via ./node_modules/.bin/jest, but not in VSCode.
This causes the following error from enzyme in VSCode Jest output:
Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none. To
configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
before using any of Enzyme's top level APIs, where `Adapter` is the adapter
corresponding to the library currently being tested. For example:
import Adapter from 'enzyme-adapter-react-15';
To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html
Environment
Steps to Reproduce
Define a setup script in package.json, as explained in the jest docs
{
"test": "jest --config=jest.config.json --watch"
},
...
}
Expected Behaviour
Jest should run the setup file. I use it to initialize enzyme with a React adapter.
Actual Behaviour
Same as fzaninotto
Can you create a sample repo so we can clone and try to reproduce?
Created a sample repo in https://github.com/fzaninotto/vscode-jest-error, but it seems to work now... Maybe I needed to relaunch the editor.
Thanks for looking into this anyway.
You need relaunch the editor. Thanks @fzaninotto 馃槃
Seems like we an opportunity for a PR to refresh the extension if package.json or the VS Code settings change.
I'm going to close this in favor of #231 that aggregates the issues. We'd love you help fixing the problem!
Most helpful comment
Created a sample repo in https://github.com/fzaninotto/vscode-jest-error, but it seems to work now... Maybe I needed to relaunch the editor.
Thanks for looking into this anyway.