Skip to content

react-scripts test fails on react-script@3.0.0  #6868

@orkideh

Description

@orkideh

Is this a bug report?

Yes, react-scripts test does not work since upgrading to version 3.0.0.

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Cannot find module '/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault' from 'App.test.js'

Environment

Environment Info:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 11.14.0 - ~/.nvm/versions/node/v11.14.0/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.14.0/bin/npm
  Browsers:
    Chrome: 73.0.3683.103
    Firefox: Not Found
    Safari: 12.0.3
  npmPackages:
    react:  16.8.6
    react-dom:  16.8.6
    react-scripts:  3.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

(Write your steps here:)

  1. yarn install
  2. yarn test(runs react-scripts test)

Expected Behavior

Expected to pass all the tests but all of them are failing with same error, previously I used react-scripts@3.0.0-next.68 and it works with no problem but as I changed it to 3.0.0 error appeared everywhere.

UPDATED::
Errors are on both 3.0.0 and 3.0.0-next.68

UPDATE 2::
If I install babel-preset-react-app@7.0.2 in root of project all the tests will pass.

Actual Behavior

All the tests fails with errors


FAIL src/app/components/home/Home.spec.js
  ● Test suite failed to run

    Cannot find module '../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault' from 'Home.spec.js'

      1 | import React from 'react';
      2 | import renderer from 'react-test-renderer';
    > 3 | import {MemoryRouter} from 'react-router-dom'
        |                              ^
      4 |
      5 | import Home from './Home';
      6 |

      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:229:17)
      at Object.<anonymous> (src/app/components/home/Home.spec.js:3:30)

FAIL src/App.test.js
  ● Test suite failed to run

    Cannot find module '../node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault' from 'App.test.js'

      1 | import React from 'react';
      2 |
    > 3 | test('Simple general test', () => {
        |                              ^
      4 |   expect(true).toBe(true);
      5 | });

      at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:229:17)
      at Object.<anonymous> (src/App.test.js:3:30)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions