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 jest config from CRA

See original GitHub issue

Environment

  1. node -v: v12.13.0
  2. npm -v: 6.12.0
  3. npm ls jest or npm ls react-scripts (if you haven’t ejected):
npm ls jest
└─┬ react-scripts@3.2.0
  └── jest@24.9.0 
npm ls react-scripts
└── react-scripts@3.2.0 
  1. your vscode-jest settings if customized:

    • jest.pathToJest? [fill]
    • jest.pathToConfig? [fill]
    • anything else that you think might be relevant? [fill]
  2. Operating system: macOS High Sierra 10.13.6

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) npm run test

Steps to Reproduce

https://github.com/abumalick/vscode-test-cra/commit/1a787e8cf3513fa4e0b6d891a405a5330af5baac

Try to run vscode on this repository, you will see that vscode-jest’s test will fail. If you run yarn test it will pass.

If you uncomment https://github.com/abumalick/vscode-test-cra/blob/master/src/App.test.js#L4 the test passes.

This shows that vscode-jest is not loading jest config of create-react-app

Relevant Debug Info

[fill]

Expected Behavior

It should load the config from create react app

Actual Behavior

It seems that it is not the same configuration


It seems that wallaby creates a jest configuration that will be generated from jest configuration of create-react-app ref: https://wallabyjs.com/docs/tutorial/react.html

Thank you for the extension

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
connectdotzcommented, Oct 29, 2019

I wonder if it could have anything to do with my test script command?

@palcisto indeed, from the code here you can see it try to match against the default CRA test scripts, i.e. react-scripts test. Your test script has a prefix REACT_APP_ENV=beta thus the plugin failed to recognize your project as a CRA project.

You should be able to fix this by setting jest.pathToJest to yarn test. see here for more info.

0reactions
palcistocommented, Oct 29, 2019

@connectdotz thanks that helped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use jest.config.js with create-react-app - Stack Overflow
The problem here is with react-scripts not seeing the options being passed to it. We can demonstrate this by running it directly. ./node_modules ......
Read more >
Configuring Jest
Configuring Jest. The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >
Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your project or through the --config <path/to/json> option.
Read more >
Setup - Testing Library
React Testing Library does not require any configuration to be used. ... In these docs we'll demonstrate configuring Jest, but you should be ......
Read more >
Running Tests | Create React App
When you run npm test , Jest will launch in watch mode *. ... it assumes that you don't often commit the code...
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