Questions tagged [babel-jest]

A Babel transpiler to assist with the conversion of ES6 to ES5 for the Jest testing framework.

A Babel plugin to assist ES6 to ES5 transpilation for the Jest testing framework.

607 questions
13
votes
3 answers

Jest from create-react-app not running on Windows

I have a problem running Jest from a clean installed app created using create-react-app on Windows 8.1. After the installation, running the command npm run test, I get the error: No tests found related to files changed since last commit. Running…
Dimitris Damilos
  • 2,363
  • 5
  • 23
  • 46
13
votes
3 answers

Jest, Unexpected Token Import

I start a new react project and I wand to use Jest as testing platform. Despite docs, blogs and many others resources like stackoverflow, I have always an "unexpected token import" error related probably to a babel problem, but my conf seem to be…
Jerome
  • 603
  • 2
  • 5
  • 15
13
votes
8 answers

jest: Test suite failed to run, TypeError: Cannot read property 'bind' of undefined

we were using jest from unit testing in react-native. It was working well. We just deleted npm and installed it again and then when we tried to run unit test(npm test) we are getting following error and we are not able to run test cases. What might…
Harish_N
  • 2,249
  • 3
  • 23
  • 34
12
votes
1 answer

Jest encountered an unexpected token when working with React TypeScript

I am building a reusable react component without using react-app and I am very new to Jest. I keep on getting this message. I have tried several post solutions on Stackoverflow but I am stuck at the moment: ● Test suite failed to run Jest…
rockon_d
  • 1,094
  • 2
  • 8
  • 21
12
votes
7 answers

jest test fails after installing react-native-async-storage

In my react native project, I have recently installed node module react-native-async-storage as I received warnings about the native package from 'react-native' being deprecated and moved out to an individual module. After installing the…
Rasmus Puls
  • 3,009
  • 7
  • 21
  • 58
12
votes
1 answer

Partially mock React module with Jest

I'm trying to mock only one function in imported React module, keep the rest of the module unmocked and do this at top level for all tests. I'm using fresh create-react-app project with a single test to observe the problem. Steps to…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
12
votes
2 answers

Jest - SyntaxError: Unexpected identifier

Doing some testing of some NodeJS functions using Jest, but it doesn't like import statements, e.g. import DatabaseController from '../util/database-controller'. I've doing some reading and people suggested installing babel-jest and updating my…
mfisher91
  • 805
  • 1
  • 8
  • 23
12
votes
2 answers

Unexpected identifier with jest + vuejs + vuetify

I've searched high and low for an answer. I suspect that it is a .babelrc issue, but I can't find an answer that works. The app runs just fine, but as I found out, both Jest and Rollup really depend on .babelrc. The other possible culprit is…
ControlManDan
  • 181
  • 2
  • 9
12
votes
1 answer

jest + typescript + es6 modules (yet again, 2019) - SyntaxError: Unexpected token export

I'm still facing problems trying to use jest, typescript and es6 modules. My test are written in Typescript, I'm trying to import objects from js-file which uses es6 modules. To do that, I've followed jest documentation and have the following in my…
Anton Pilyak
  • 1,050
  • 2
  • 15
  • 34
12
votes
5 answers

setupTests.js not loading automatically in CRA react app

I have read that src/setupTests.js is supposed to load before every test but I still get every test failing with the error: "Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none." this is my src/setupTests.js import…
Travis
  • 388
  • 1
  • 5
  • 11
12
votes
2 answers

Requires Babel "^7.0.0-0", but was loaded with "6.26.0"

I have migrated my app to babel 7 beta and everything seems to work except the tests. I think I've read everything out there but I'm still getting this error: ● Test suite failed to run Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If…
Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166
11
votes
2 answers

Jest fails Cannot find module 'react/lib/React' from 'ReactShallowRenderer.js' after React 16 upgrade

Just upgraded to react v16.0.0 from v15.6.2 (via a rebase) Problem Running my jests tests gives the following error ● Test suite failed to run Cannot find module 'react/lib/React' from 'ReactShallowRenderer.js' at…
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81
11
votes
2 answers

babel-jest with ES6 modules

I'm happily using node 8.6 with the experimental ES6 modules option (--experimental-modules) turned on. This allows me to perfectly write plain ES2015 code for node without the need of babel. The problem is when I try to create some tests with jest,…
Jack
  • 1,689
  • 1
  • 13
  • 20
11
votes
2 answers

How to test DOM manipulation in JEST

I'm trying to test a ES6 function which updates the dom element whenever it is being executed. Currently I'm getting empty nodelist since the HTML page is not loaded. What is approach to test this purely with…
loganathan
  • 5,838
  • 8
  • 33
  • 50
11
votes
2 answers

Jest snapshots work locally but consistently fail on Travis CI

My Jest snapshot tests consistently fail on Travis with the following difference: - "_instance": Constructor { + "_instance": { Dev dependencies include: "babel-jest": "^19.0.0", "jest": "^19.0.2", "react-addons-test-utils":…
Jared Silver
  • 161
  • 1
  • 7
1 2
3
40 41