When running from push to master, test fails with this message:
> react-scripts test
PASS src/App.spec.js
FAIL src/layout/Navbar/Navbar.test.jsx
● Test suite failed to run
Cannot find module 'react-test-renderer' from 'src/layout/Navbar/Navbar.test.jsx'
5 | import React from 'react';
6 | import { BrowserRouter as Router } from "react-router-dom";
> 7 | import renderer from 'react-test-renderer';
| ^
8 |
9 | import Navbar from "./Index";
10 |
at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
at Object.<anonymous> (src/layout/Navbar/Navbar.test.jsx:7:1)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.705 s
Ran all test suites.
Exited with code exit status 1
CircleCI received exi
The test complete successfully when locally. Here is the test file:
/**
*@jest-environment jsdom
*/
import React from 'react';
import { BrowserRouter as Router } from "react-router-dom";
import renderer from 'react-test-renderer';
import Navbar from "./Index";
describe('Navbar', () => {
test('snapshot render', () => {
const component = renderer.create(
<Router>
<Navbar />
</Router>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
})
})