Example jest testing fails out of the box
See original GitHub issueWhen I run npm test
after installing the example test in App.test.js
is discovered and fails.
I’m running OSX 10.13.6, npm 6.4.1, node 10.11.0
Steps to reproduce
- Go to root directory in terminal and run
npm test
, selecta
option to run all tests from the command line prompt
Expected result
Tests should run and pass.
Actual result
The test is discovered and fails:
● Test suite failed to run
/Users/jfunk/Documents/Code/git/RN-PVP/node_modules/redux-persist/es/integration/react.js:9
import React, { PureComponent } from 'react'; // eslint-disable-line import/no-unresolved
^^^^^
SyntaxError: Unexpected identifier
4 | import { Provider } from 'react-redux';
5 | import { Router, Stack } from 'react-native-router-flux';
> 6 | import { PersistGate } from 'redux-persist/es/integration/react';
| ^
7 |
8 | import { Root, StyleProvider } from 'native-base';
9 | import getTheme from '../../native-base-theme/components';
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (src/native/index.js:6:1)
Test Suites: 1 failed, 1 total
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Jest: mocking console.error - tests fails - Stack Overflow
It's when I test with enzyme/react that I hit this wall after the first test. Sample App.js: import React, { Component } from...
Read more >Jest Tutorial - JavaScript Unit Testing Using Jest Framework
In this Jest tutorial, we will learn about various Jest features, Jest matchers and how to use Jest framework for JavaScript Unit Testing....
Read more >Jest · Delightful JavaScript Testing
Jest aims to work out of the box, config free, on most JavaScript projects. Snapshots. Make tests which keep track of large objects...
Read more >Jest testing: Top features and how to use them - LogRocket Blog
Out-of-the-box ease Some examples: Add coverage when invoking Jest to get coverage reports from your tests with the ability to choose between a ......
Read more >Jest Testing Tutorial: 5 Easy Steps - Testim Blog
Jest Testing: A Helpful, Introductory Tutorial · its definition · very fast to execute · Zero config: “Jest aims to work out of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I eventually worked around this with:
“jest”: { “preset”: “jest-expo”, “transformIgnorePatterns”: [] },
From this issue.
Also add
jest.useFakeTimers();
to the test file.