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

babel-jest to transform non .js|.jsx extensions

I have Customer.js.flow type file. When I run jest, it fails with this error: Customer.js.flow:1 ({"Object.":function(module,exports,require,__dirname,__filename,global,jest){export type Customer = { …
Mayas
  • 1,434
  • 5
  • 16
  • 25
0
votes
1 answer

React Jest es6 (rest spread operator) babel configuration not working

I am try create app with react-tool-box. Also I try use Jest for testing, but get this test fails. It look like es6 configuration problem for Jest. ● Test suite failed to…
Edgaras Karka
  • 7,400
  • 15
  • 61
  • 115
0
votes
1 answer

jest mock dependency generator function

I am having trouble mocking a simple dependency generator function. //generatorFunction.js export default ()=>({execute: (arg1)=>Promise.resolve(arg1)}) //actualFunction.js import generate from 'generatorFunction' export default…
l2silver
  • 5
  • 1
  • 3
0
votes
1 answer

How to make pre-resolved promises continue the test syncronisely

If I have a bit of code that cause something to happen async but not as a root cause of doing something (can't wait for the callback), something that happens on loop (i.e. testing autosave) how would be the best way todo it. Here is a failing tests…
Saspiron
  • 180
  • 1
  • 10
0
votes
1 answer

What's the right way to use babel-jest?

Per the docs: https://github.com/facebook/jest#babel-integration If you'd like to use Babel, it can easily be enabled: npm install --save-dev babel-jest babel-polyfill So all you have to do is install those two packages and nothing else?…
Joseph Fraley
  • 1,360
  • 1
  • 10
  • 26
0
votes
1 answer

React Jest: How to get the state of checkbox

I'm trying to find the checked status of a checkbox in a React component. This is my component: class Checkboxes extends React.Component { constructor() { super(); console.log('Hello world!'); this.state = { …
Dirty Penguin
  • 4,212
  • 9
  • 45
  • 69
-1
votes
1 answer

After I upgrade "jest-dom" to "react-router-dom", all my Test suite failed. And the error is related to the "Jest encountered an unexpected token"

I updated my React test package from "jest-dom": "^3.2.2" and "react-testing-library": "^7.0.0" to "@testing-library/jest-dom": "^5.16.5" and "@testing-library/react": "^14.0.0". But all the test suite failed and I got below error. "Test suite…
-1
votes
1 answer

jest: unable to mock methods/hooks using `jest.spyOn`

I'm trying to mock the methods & hooks in a file and import those mock functions as I need them, in my test files. useMyHook.jsx const useMyHook = () => { const [val, setVal] = useState(200) return { val } } export { useMyHook…
-1
votes
1 answer

Mocking API calls with authorisation using JEST

I have an API call function that retrieves data from my back end to display. My API call as a header that is required for authorisation when retrieving the data. The session storage is set at login when the application is run. My main code is…
Mehbenmeh
  • 17
  • 5
-1
votes
1 answer

How to fire a click event on a button with classname inside a div using JEST and React-testing-library?

I am creating a test case using JEST and RTL where I have to perform some action on button click event but I'm not able to fire a click event on that button. My component looks like:- const CustomButton = () => { return (
-1
votes
1 answer

Jest.fn().mockReturnValue returns undefined

Below mentioned mocked function when used in a file called useFirestore gives the following error: Cannot read property 'collection' of undefined. firebase.js import Firebase from 'firebase/app'; import 'firebase/storage'; import…
-1
votes
1 answer

Test for a component: How to access to a property of a tag with getByTestId

I'm doing a component test in react (My first) and I want to verify a number, when I pass it the value, it returns undefined and I remove the value to see what it returned and it was fine, find the element import React, { useState } from…
Emocrat3
  • 65
  • 2
  • 9
-1
votes
1 answer

Is this transpilation issue correctly filed against babel-jest?

I raised an issue https://github.com/facebook/jest/issues/11504 against the jest project, which I think is responsible for maintaining babel-jest. Transpilation totally fails after adding apparently harmless and error-free code. However, there are a…
cefn
  • 2,895
  • 19
  • 28
-1
votes
1 answer

React + Jest: Test suite failed to run

I am fixing some tests on our pre-existing project, and I ran into this error: FAIL src/components/changelog/__test__/ChangeLogOverView.test.tsx ● Test suite failed to run TypeError: Cannot create property '__packages__' on boolean 'true' …
JMon
  • 3,387
  • 16
  • 63
  • 102
-1
votes
2 answers

Running test cases to test a function using Jest

I am trying to test few test cases for a function where it takes two parameters. these two parameters along with the result I have defined it in three different files and then exporting it. I am using Jest for the same, but it is throwing…
joy08
  • 9,004
  • 8
  • 38
  • 73
1 2 3
40
41