-
Notifications
You must be signed in to change notification settings - Fork 295
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
out-of-the-box unexpected token with create-react-app #125
Comments
This is working for me on my default create-react-app example, https://github.com/orta/vscode-jest/tree/master/integrations/create-react-example - which I just updated now to the latest version 52610d0 Any chance you can run the extension in debug mode and have a look at what causing it? |
Hi there, I'm sorry, it worked flawlessly when I tried it in another project. Then I downloaded CRA again and it worked as well, so I'm assuming there was something weird in my previous installation/configuration, because it is still not working there. Thanks for your time. |
I got the same error. In my case, the cause was after I installed |
@orta, can I help get this one fixed? Any tips on what I'm looking for if I get the extension running in debug mode? It's failing from a clean create-react-app project with [email protected], [email protected], vscode-jest v2.4.2. |
Honestly, I'm not that sure, maybe that the Jest config isn't being respected somehow? |
You're right @orta. The
|
For Jest, the extension aims to support I'm happy to have a similar aim with CRA, I think it's probably a bit easier to handle as it could be a matter of checking for the right files in the right places. I'm happy for you to do that yep - I generally run projects like this so I'll give you access rights to handle issues however you like |
So what is the fix here? |
Have you reproduced the issue today @djErock? |
If you're having problems @djErock could you please create a new issue with lots of detail so we can investigate. I've just confirmed create-react-app has worked OK on OS X, Linux, and Windows systems. If you're asking to summarize the issue, updating the extension should resolve it. There are a couple fixes at play that improved detection of create-react-app, and spawning the runner in a shell on Windows. |
I'm getting the same issue with failing tests after creating a project with Environment
Expected BehaviourPass the tests Actual BehaviourI am currently getting Steps to ReproduceHere's what happens when I start from scratch: Install and set up $ mkdir /tmp/react
$ cd /tmp/react
$ brew install nodeenv
(installs nodeenv)
$ nodeenv .venv
* Install prebuilt node (9.8.0) ..... done.
$ source .venv/bin/activate Create (.venv) $ npx create-react-app react-test
npx: installed 67 in 5.669s
[...snipped...]
> [email protected] install /private/tmp/react/react-test/node_modules/fsevents
> node install
[fsevents] Success: "/private/tmp/react/react-test/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" is installed via remote
> [email protected] postinstall /private/tmp/react/react-test/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
+ [email protected]
+ [email protected]
+ [email protected]
added 1440 packages in 59.115s
[...snipped...] Run vanilla react tests: (.venv) $ cd react-test
(.venv) $ npm test
> [email protected] test /private/tmp/react/react-test
> react-scripts test --env=jsdom
PASS src/App.test.js
✓ renders without crashing (17ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.925s
Ran all test suites related to changed files. Install (.venv) $ npm install --save jest
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
+ [email protected]
added 112 packages, removed 1 package, updated 35 packages and moved 9 packages in 18.697s Run tests after installing (.venv) $ npm test
FAIL src/App.test.js
● Test suite failed to run
TypeError: environment.dispose is not a function
at Promise.resolve.then (node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/build/runTest.js:102:17)
at <anonymous>
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.791s, estimated 1s
Ran all test suites related to changed files.
{
"name": "react-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"jest": "^22.4.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
} Replace (.venv) $ sed -i -e 's/"test": .*/"test": "jest",/' package.json
(.venv) $ grep '"test":' package.json
"test": "jest", Run (.venv) $ npm test
> [email protected] test /private/tmp/react/react-test
> jest
FAIL src/App.test.js
● Test suite failed to run
/private/tmp/react/react-test/src/App.test.js: Unexpected token (7:18)
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
> 7 | ReactDOM.render(<App />, div);
| ^
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.509s
Ran all test suites.
npm ERR! Test failed. See above for more details. |
@orta @seanpoulter: This issue still persists as of today with the latest versions. |
I'm a little confused, I don't think this has anything to do with the vscode-jest extension? |
This comment says it all: jestjs/jest#5119 (comment)
Your error isn't good but it's expected. Installing
|
If you continue to experience problems please create a new issue and reference #125. I've locked the conversation for this issue since we've resolved the original and subsequent issues. 🔒 |
When a project is bootstrapped with create-react-app using the latest versions of node/npm, the react-scripts executable is installed in the top level node_modules/.bin directory. This has been added as the first path to check. This fixes jest-community#161, closes jest-community#39, closes jest-community#113 and resolves facebook/create-react-app#2709, and closes jest-community#125.
Hi there,
Environment
node -v
: v6.10.3npm -v
: 4.6.1npm ls react-scripts
(if you haven’t ejected): 1.0.10Operating system: MacOS
Steps to Reproduce
create-react-app
jest
extension for Visual Studio Code (the recommended one)Expected Behavior
Pass the tests (as it does in CLI)
Actual Behavior
Thanks!
The text was updated successfully, but these errors were encountered: