dimanche 1 avril 2018

Create React App cannot find tests

I recently started a new project using create-react-app. I moved the App.test.js from outside the /src folder into a root level /tests folder so my folder structure looks like this now:

> node_modules
> public
> src
   ...
   App.js
> tests
   App.test.js
...

And here's the entire App.test.js file:

import React from 'react';
import ReactDOM from 'react-dom';
import App from "../src/App";

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

So when I try npm run test, no tests get executed. It says that no tests can be found. How can I get create-react-app to recognize the new /tests folder as the new location for all tests and run them?

Aucun commentaire:

Enregistrer un commentaire