Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test does not run in CRA #209

Closed
bitops opened this issue Aug 27, 2021 · 6 comments
Closed

Test does not run in CRA #209

bitops opened this issue Aug 27, 2021 · 6 comments

Comments

@bitops
Copy link

bitops commented Aug 27, 2021

Hello! I am trying to set up the plugin with a React app from CRA. I have the plugin installed in VSCode and I have followed the configuration instructions in the README. I do see the "Run" and "Debug" options in my test file. However when I click "Run" nothing happens, it seems that the tests never really get started.

Here is my extension configuration:

# "jestrunner.jestCommand"
npm run test --

The target definition:

# package.json
"test": "react-scripts test",

Output seen in terminal:

me@mymachine web % cd '/Users/me/src/foo-app/web'
npm run test -- '/Users/me/src/foo-app/web/src/hooks/useTheStuff.spec.js' -c '/Users/me/src/foo-app/web/jest.config.js' -t 'useTheStuff%
me@mymachine web % npm run test -- '/Users/me/src/foo-app/web/src/hooks/useTheStuff.spec.js' -c '/Users/me/src/foo-app/web/jest.config.js' -t 'useTheStuff renders'

> foo-app-web@0.1.0 test /Users/me/src/foo-app/web
> react-scripts test "/Users/me/src/foo-app/web/src/hooks/useTheStuff.spec.js" "-c" "/Users/me/src/foo-app/web/jest.config.js" "-t" "useTheStuff renders"

Usage: test.js [--config=<pathToConfigFile>] [TestPathPattern]

Options:
  --help, -h                    Show help                              [boolean]
  --version, -v                 Print the version and exit             [boolean]
... rest of content omitted ...

I am on version v0.4.44.

@bitops
Copy link
Author

bitops commented Aug 27, 2021

Also, after some searching online, I tried changing my test target definition to this:

"test": "react-scripts test --",

That seems to do something but then I am confronted with this error and a huge list of stack traces.

Invalid testPattern ... crazy gobbledygook ...

@ianldgs
Copy link

ianldgs commented Sep 15, 2022

What seems like is causing problem is the -c flag.

This started to fail recently for me. I think because of #270, that was merged today.

The command that runs on the terminal now has the -c flag pointing to the package.json.
If I remove it and try again, everything works.

@firsttris
Copy link
Owner

can you verfiy if this happens with the latest version 0.4.56.

because i was not able to reproduce it?

@ianldgs
Copy link

ianldgs commented Sep 22, 2022

I'm afraid I still have the issue :/

Relevant info:

"jest": "27.5.1",

  "jestrunner.projectPath": "./frontend/ui/",
  "jestrunner.jestCommand": "npm run test -- --watchAll=false",

Output:

cd './frontend/ui/'
npm run test -- --watchAll=false '/Users/iserpa/code/project/frontend/ui/src/shared/Component.spec.tsx' -c '/Users/iserpa/code/project/frontend/ui/package.json' -t 'Component should allow doing something'
iserpa@amsmac6y3f project % cd './frontend/ui/'
iserpa@amsmac6y3f ui % npm run test -- --watchAll=false '/Users/iserpa/code/project/frontend/ui/src/shared/Component.spec.tsx' -c '/Users/iserpa/code/project/frontend/ui/package.json' -t 'Component should allow doing something'

> frontend@1.0.0 test
> tsc && craco test "--watchAll=false" "/Users/iserpa/code/project/frontend/ui/src/shared/Component.spec.tsx" "-c" "/Users/iserpa/code/project/frontend/ui/package.json" "-t" "Component should allow doing something"

Usage: test.js [--config=<pathToConfigFile>] [TestPathPattern]

If I edit the command and remove the -c '/Users/iserpa/code/project/frontend/ui/package.json' part, everything works fine.

@firsttris
Copy link
Owner

okay i reverted it.

@ianldgs
Copy link

ianldgs commented Sep 23, 2022

I have updated to 0.4.57 and can confirm this no longer happens.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants