question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not load setup file defined in package.json

See original GitHub issue

Environment

  1. node -v: v8.6.0

  2. npm -v: yarn 1.1.0

  3. npm ls react-scripts (if you haven’t ejected): not a cra project

  4. 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
fzaninottocommented, Oct 30, 2017

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.

2reactions
seanpoultercommented, Jan 21, 2018

Seems like we an opportunity for a PR to refresh the extension if package.json or the VS Code settings change.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found