Does not load setup file defined in package.json
See original GitHub issueEnvironment
-
node -v
: v8.6.0 -
npm -v
: yarn 1.1.0 -
npm ls react-scripts
(if you haven’t ejected): not a cra project -
Operating system: OS X
Steps to Reproduce
Define a setup script in package.json
, as explained in the jest docs
{
"jest": {
"setupTestFrameworkScriptFile": "./test-setup.js"
},
...
}
Expected Behavior
Jest should run the setup file. I use it to initialize enzyme with a React adapter.
Actual Behavior
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
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top Results From Across the Web
npm can't find package.json - Stack Overflow
After downloading or creating a project, you have to cd into this project folder. Inside is the file package.json. cd <path_to_project> npm install....
Read more >Creating a package.json file - npm Docs
A package.json file: lists the packages your project depends on; specifies versions of a package that your project can use using semantic versioning...
Read more >package.json Quick Start Guide | phoenixNAP KB
Learn how the package.json file lets you automatically manage various Node.js package metadata, such as project dependencies in this guide.
Read more >npm install | how it works - StackChief
Both of these commands do the same thing. Running npm install without arguments installs modules defined in the dependencies section of the package.json...
Read more >yarn install
Install all the dependencies listed within package.json in the local ... Verifies that already installed files in node_modules did not get removed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Seems like we an opportunity for a PR to refresh the extension if
package.json
or the VS Code settings change.