jestjs Questions

4

Solved

let's say I have a module that needs to be initialized once in the start of the app (to pass on configuration). module will look something like this : MyModule.js let isInitiazlied; const myMod...
Veilleux asked 26/2, 2018 at 13:25

1

Solved

I have a project that has some script to build typescript web-component in it (here). I use rollup and typescript to build my web-components and my web-component file is like this: import HTML from...

15

I wonder if there is a better way to disable console errors inside a specific Jest test (i.e. restore the original console before/after each test). Here is my current approach: describe("Some ...
Kephart asked 9/6, 2017 at 22:50

3

Solved

I'm Aadarshvelu! Recently Started Testing My WebApp Code Using Jest With Puppeteer. So I Have Page Which All Credentials Have Been Filled With Puppeteer.But When SummitButton('signBtn') Clicked POS...
Brachial asked 1/11, 2019 at 16:22

30

I have a React application (not using Create React App) built using TypeScript, Jest, Webpack, and Babel. When trying to run yarn jest, I get the following error: I have tried removing all package...
Plantain asked 29/10, 2019 at 18:35

9

When I run my jest tests, the amount of memory used per test increases over time. The issue wasn't apparent on my local machine; instead, I found this out when running my tests on CircleCI. I got t...
Backward asked 13/7, 2020 at 22:41

16

I am using Jest to test an angular app and it is taking a really long time for simple tests to run and I can not seem to figure out why. My Jest setup in package.json: "jest": { "modulePaths": ...
Catalinacatalo asked 13/7, 2017 at 17:4

7

Solved

I have header component like below: import { useLocation } from "react-router-dom"; const Header = () => { let route = useLocation().pathname; return route === "/user" ? <ComponentA /&gt...
Tan asked 28/1, 2020 at 12:44

10

I've having a strange problem with this test: deal.test.js import Deal from "../src/models/Deal"; import apiProducts from "../__mocks__/api/products"; describe("Deal"...
Retro asked 1/7, 2019 at 17:16

12

Solved

Is it possible to load environment variables from an env file for unit testing purposes in Jest? I'm looking to run a series of tests on it like so: // unit tests for env file describe('env', () =...
Protuberate asked 9/5, 2018 at 17:31

2

Solved

Error: This error was only popping up for me when running CI for jest. I could not catch it locally in any way. Error text: FAIL src/utils/message.test.ts ● Test suite failed to run TypeError: C...
Tartlet asked 20/12, 2023 at 23:17

5

Solved

I want to assert that an element never appears in my document. I know I can do this: import '@testing-library/jest-dom/extend-expect' it('does not contain element', async () => { const { query...
Perdita asked 15/7, 2021 at 20:37

26

Solved

I'm trying to write tests for my simple React App that creates a UI for a dog Shelter using API etc. I have imported the modules shown below and ran the following command npm install jest-dom react...
Plebeian asked 9/9, 2019 at 21:5

16

In my app I use React and TypeScript. I tried to run jest tests I get following error: C:\Users\e-KDKK\workspace\konrad\mikskarpety\src\images\icons\Sock.svg:1 ({"Object.<anonymous>":functi...
Wulfila asked 29/10, 2019 at 7:49

3

hej, maybe someone can help me with this? I try to mock a zustand store with custom values and actions. I'd like to do the mocking within my test file. But I fail miserably. This is a simplified ex...
Aleppo asked 20/12, 2022 at 10:38

20

Solved

I couldn't get rid of this SyntaxError: Cannot use import statement outside a module error no matter what I have tried and it got so frustrating. Is there anybody out here solved this issue? I have...
Aberdare asked 13/5, 2020 at 17:41

3

I have a test file called integration.test.js import app from "../app"; import request from "supertest"; describe("testing /users", () => { const app = request(ap...
Keitloa asked 24/4, 2022 at 3:34

16

I have updated some of the dependencies today in my project, but it went through really smoothly. Now, when I'm about to push it, I started my tests. And boom. All of them throw: Your test suite m...
Manchineel asked 13/6, 2018 at 18:0

2

I am creating next.js app with tests inside the page directory. For this I have added config to next.config.js const { i18n } = require('./next-i18next.config'); const nextConfig = { reactStrictM...
Sinusitis asked 1/3, 2022 at 8:16

3

Solved

I've seen some other answers and GitHub issues that describe this, but I haven't been able to find a solution in my case. I'm getting the dreaded SyntaxError: Unexpected token export when trying to...
Frans asked 4/10, 2018 at 16:54

4

Solved

I was taking a look to the waitFor documentation and I was wondering if there is any way to configure it globally, for example in the jest.config or in the command used to launch the test suite? I ...
Peltier asked 5/7, 2021 at 5:27

4

Solved

I'm getting these warnings when I run my expo / jest project and I'm not sure why, seemed to not come up when googled. console.warn The "EXNativeModulesProxy" native module is not export...
Loraineloralee asked 11/12, 2021 at 3:1

13

Solved

Edit: Run npm install @types/jest --save-dev To fix Just trying to type it() and the auto suggestion is isTag I've tried adding a jsconfig.json { "compilerOptions": { "target"...
Tarsuss asked 10/9, 2019 at 15:38

11

I'm using Enzyme's shallow method to test a component which uses the useParams hook to get an ID from the URL params. I'm trying to mock the useParams hook so that it does't call the actual method...
Liederman asked 15/11, 2019 at 19:33

2

Solved

I'm trying to test a component that uses react-redux for state management. To test quickly I want to mock useSelector, like this: const templates = [ { id: ..., name: ..., ... }, { id: ..., ...

© 2022 - 2024 — McMap. All rights reserved.