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.

Using with create-react-app typescript?

See original GitHub issue

Environment

  1. node -v: 8.9.2

  2. npm -v:

  3. npm ls react-scripts (if you haven’t ejected): Yes (TypeScript)

  4. Operating system: Windows

Steps to Reproduce

Create brand new project with cra: create-react-app my-app --scripts-version=react-scripts-ts . Apptest.tsx is:

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<App />, div);

  expect(1).toBe(2);
});

Expected Behavior

Tests are detected and auto run with highlighting within vscode showing green or red if they pass or not.

Actual Behavior

I was under the impression (maybe wrongly) that the plugin should just auto work even with CRA typescript? instead the extension fails to find any tests in the output window and going into my tests i don’t get any highlighting (as it hasn’t found my tests).

Any help appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:26 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
seanpoultercommented, Feb 1, 2018

Thanks for the info. I could reproduce that bug. When we decide how to run your tests we look for jest and react_scripts in node_modules. Since we find jest before react-scripts(-ts) we incorrectly start running tests with jest instead of the npm test script.

For now, your workaround would be to add a user setting in .vscode/settings.json:

{
    "jest.pathToJest": "npm.cmd test --"
}
3reactions
JoshSchreudercommented, Jan 24, 2019

No worries. Well it’s documented here so if someone else runs into the problem at least they know how I managed to fix it 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App and TypeScript: A Quick How-To | Built In
If you're building a new app and using create-react-app , the docs are great: You can start a new TypeScript app using templates....
Read more >
Create React App with TypeScript - Complete Guide
To create a React App with Typescript, run the npx create-react-app command with the --template flag set to typescript , e.g. npx create-react-app...
Read more >
TypeScript and React using create-react-app - Level Up Coding
create -react-app is a command line tool that allows developers to easily create new React apps with sensible defaults and zero configuration. ......
Read more >
How to Use Create React App With TypeScript
To view Create React App, open your terminal, navigate to your workspace directory and run the below command. ... This is going to...
Read more >
Building a React App with TypeScript - Section.io
As you might have guessed, to set up a react typescript application, we'd still use create-react-app just with some extra flags.
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