Vscode-jest: Fix support for create-react-app and react-scripts

Created on 4 Nov 2017  路  2Comments  路  Source: jest-community/vscode-jest

This is a new issue to aggregate existing issues for supporting create-react-app and react-scripts. The latest node LTS version doesn't install Jest where it's currently expected (in src/helpers.ts). This seems to be the cause of #39, #41, #113, and #125.

--

Environment

  1. node -v: 8.9.0
  2. npm -v: 5.5.1
  3. npm ls react-scripts (if you haven鈥檛 ejected): N/A
  4. Operating system: Windows 7

  5. Extension version: v2.4.1 as of 23af6f0

Steps to Reproduce

The create-react-app User Guide has a section for Updating to New Releases. Instead of installing newer versions of react-scripts, I've used this approach to bootstrap app with each supported version (>= v1.0.0) and confirm the extension doesn't work.

create-react-app app
cd app
npm uninstall react-scripts
npm install "react-scripts@<version>"
code --extensionDevelopmentPath=<...\vscode-jest> .

Expected Behavior

The extension should detect the bootstrapped app.

Actual Behavior

An "Unexpected token" error is thrown when Jest runs without detecting this has been bootstrapped.

2017-11-04 -- vscode-jest -- unexpected token

Suggested Changes

  • Maintain the existing check to support older versions of node/npm
  • Detect react-scripts in node_modules/.bin/react-scripts(.cmd)?

Most helpful comment

I'm getting the Unexpected token error on JSX using react-scripts 1.1.4. Setting jest.pathToJest to npm test -- as a workaround fixes it, but shouldn't it be automatic?

All 2 comments

I'm getting the Unexpected token error on JSX using react-scripts 1.1.4. Setting jest.pathToJest to npm test -- as a workaround fixes it, but shouldn't it be automatic?

@nickmccurdy thanks for the workaround. @orta this still seems to be an issue BTW, the test runner is using jest directly, instead of going through react-scripts.

Was this page helpful?
0 / 5 - 0 ratings