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
0
votes
1 answer

Trying to whitelist node module in jest config

I'm hoping this is just a simple mistake on my part, but here's what I'm doing. I have a react native project, and I'm importing via url another react native project that's going to become a common library. Because it's early days, I've not…
jaucourt
  • 566
  • 4
  • 19
0
votes
0 answers

Failing test with message 'OTransitionProperty'

I trying to run jest test on react app without --env=jsdom. Problem is that I mock all information in setupTests.js but still something is missing. At the moment when running test getting error: TypeErrorL Cannot use 'in' operator to search for…
MarJano
  • 1,257
  • 2
  • 18
  • 39
0
votes
1 answer

Jest Mock inside a JSX Unit Test

I have one JSX file to write jest Unit Test. ../dist/container/index constructor(props) { super(props); this.state = { showName: null } } componentWillMount() {         Request             .get('/api')             .end((err, res) => {          …
user3686652
  • 805
  • 1
  • 6
  • 11
0
votes
1 answer

Jest unit test case for componentDidMount const ternary operator

I have componentDidMount which have one const. I am trying to cover unit test case for const which have ternary operator. Can anyone please help me on this how to cover ternary operator condition. componentDidMount() { const learnerId =…
0
votes
2 answers

Resemblejs in jest hangs

I'm using ResembleJS for image comparison. I can get it to run when I run it in a standalone script. Here's the code: var compareImages = require('resemblejs/compareImages'); var fs = require('fs'); var path = require('path'); // The…
ajohnson
  • 51
  • 5
0
votes
1 answer

React testing through jest gives an unexpected error

I'm using JEST to test my react app. I get the error and some text as in the image below. Also, the code for my test case(named: TodoApp.test.jsx) is as : it("should add todo ...", () => { // const text = "Suzal is trying react"; // I…
Pramesh Bajracharya
  • 2,153
  • 3
  • 28
  • 54
0
votes
1 answer

Jest Unit Class with Dependencies

I'm trying to unit test this class that has a dependency of AppDB and createStudy that I need to mock. To get started I'm attempting to unit test the simple method startLoadingData which happens to be a MobX action import { observable, action } from…
spakmad
  • 880
  • 6
  • 15
0
votes
1 answer

Unexpected token import when using custom transformer of babel-jest

When I run npm test (jest --watch), I get: C:\sites\YDR\branches\trunk\development\app\static\js\_modules\marketplace\postbacks\Components\Form.js:44 import('Form').then(function (m) { ^^^^^^ SyntaxError: Unexpected token import at…
van_folmert
  • 4,257
  • 10
  • 44
  • 89
0
votes
3 answers

Testing fetch using Jest- React Native

I have a common api class that i use for handling api calls in React Native. It will make the call and get the json/ error and return it. See the code below. // General api to acces data from web import ApiConstants from './ApiConstants'; export…
Victor
  • 4,171
  • 1
  • 29
  • 37
0
votes
1 answer

Jest ES6 Error unexpected token import?

Hello how can I use ES6 with Jest. Because they send me a mistake in spread (operator) and export. How to modify jest? export default function reducer(state={ open:false }, action) { switch (action.type) { case…
vale ale
  • 11
  • 6
0
votes
2 answers

jest test case failing for React Component

I'm getting below error, when i try to mock my React Component. ? Test suite failed to run C:\UBS\Dev\workspace\topcat-ui\node_modules\antd\lib\style\index.css:9 html { ^ SyntaxError: Unexpected token { at…
user4900074
  • 1,695
  • 4
  • 18
  • 24
0
votes
1 answer

What is Expect function to validate schema in JEST and Supertest?

like in chakram testing expect(WallObject).to.have.schema(expectedSchema). Similarly which function is there in Jest? I am using jest with supertest.
0
votes
1 answer

Unable to run Jest tests. Getting Error unexpected token {

I am unable run tests using jest. Writing tests for react application. Getting following error :- node_modules\bootstrap\dist\css\bootstrap.min.css:5 *//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css …
Kunal
  • 887
  • 1
  • 8
  • 15
0
votes
0 answers

React Jest Unexected token Import

I am getting an import error when trying to run a simple test: Error: FAIL Root\wwwroot\Scripts\__tests__\list_tests.js ● Test suite failed to run Root\wwwroot\Scripts\__tests__\list_tests.js:3 import List from '../General/list'; …
user2589339
  • 91
  • 10
0
votes
1 answer

React & Jest global.confirm not updating between tests

I have an existing application that I am trying to write tests for. I have a component function that uses a window.confirm box to get user input (not my code) like this: if (window.confirm('Are you sure to unassign?')) { …
Gremash
  • 8,158
  • 6
  • 30
  • 44