ts-jest Questions

2

Solved

Im trying to create a basic jest test interacting with a npm dependency: react-diagrams The failing test import { DiagramModel } from '@projectstorm/react-diagrams' test('importing react diagrams'...
Querist asked 3/5, 2021 at 18:21

3

This is my first time working with jest. I have a scenario where I want to see if the selected value is in an enum or not. Here is my test case: test('Should be valid', () => { expect(TestCase...
Perbunan asked 13/9, 2022 at 4:9

3

While I've tried to test my form component that uses useFormState and Next14 Server Actions I get this error TypeError: (0 , _reactdom.useFormState) is not a function or its return value is not ite...
Deathblow asked 22/12, 2023 at 19:7

0

I've been trying to resolve this test error for a while now with not success. Recently I upgraded React Native from 0.72.3 to 0.74.3 and got the Android application to build and run, however, I can...
Homicide asked 29/7 at 10:9

4

--- UPDATE---- I can run the test using command line but can't run the test with Jest Runner extension in VSCode. ------Original Question ----------------- I think I have corrupted my npm modules b...
Atlantes asked 10/5, 2022 at 6:37

9

Solved

I'm getting an error when trying to run my test file (I'm using react typescript) ● Test suite failed to run Jest encountered an unexpected token Jest failed to parse a file. This happens e.g....
Quartet asked 25/5, 2022 at 18:2

6

Solved

I have a controller that uses NestJS built-in Logger via dependency injection in constructor of the controller: constructor(private readonly logger: Logger) I want to be able to mock it in my Je...
Chrystel asked 15/7, 2021 at 13:40

4

Solved

I have read many of the questions similar to mine, but none seem to fix my issue. I am using Vue3, TypeScript, Jest, and D3 v7. When I try to import * as d3 from "d3"; I get this error in...
Spiculum asked 17/9, 2021 at 16:27

3

I'm trying to mock one of Typeorm module function in Jest and I want to do it in cleanest possible way. What I managed to create that works: jest.mock("typeorm", () => ({ __esModule: ...
Hufuf asked 12/5, 2021 at 19:18

6

I'm trying to upgrade my project to React 18, everything works in dev and production mode in the browser. But after upgrading to the latest version of @testing-library/react some of my unit tests a...
Villous asked 25/4, 2022 at 17:24

2

I have a typescript project and I setup aliases in ts.config.json { "compilerOptions": { "paths": { "@pkg/*": ["./packages/*"], }, } } in my ts files...
Eustis asked 29/6, 2021 at 20:59

4

I am using Jest with TypeScript. Despite the fact that my code works and I can build my project, Visual Studio Code throws me that error for all Jest methods (describe(), test()...): Cannot find na...
Surra asked 12/10, 2020 at 11:6

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...

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

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

4

import '@testing-library/jest-dom/extend-expect'; expect(screen.getByText('User does not exist.')).toBeInTheDocument() I'm writing the unit test for my web app, I use toBeInTheDocument() in my c...
Arraignment asked 20/10, 2023 at 5:17

8

Solved

I'm running tests with jest in a simple NodeJS app that uses typescript. My test is throwing an error: ReferenceError: structuredClone is not defined. I'm not getting any linter errors and the code...
Orola asked 5/9, 2022 at 9:42

1

I want to test some code which uses the newly added decorators in TypeScript 5.0 (not experimental decorators), how can I make Jest interpret that code? I get SyntaxError: Invalid or unexpected tok...
Penury asked 29/4, 2023 at 15:0

5

I am calling a API in nestjs service like below, import { HttpService, Post } from '@nestjs/common'; export class MyService { constructor(private httpClient: HttpService) {} public myMethod(in...
Weakling asked 22/1, 2020 at 13:28

3

This is a demo code below used to demonstrate failure i am getting in my current project. It tanspiles and runs, just fails to compile with jest with following error Error: error TS1343: The 'impor...
Alehouse asked 20/7, 2022 at 15:12

1

Solved

I'm running npx jest test Getting this error, no matter how I change my configuration: error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esn...
Jeane asked 2/11, 2023 at 7:51

6

Solved

I've reached a dead end trying to fix this issue. I am using the following TypeScript configuration: { "compilerOptions": { "module": "es2022", "moduleResoluti...
Monition asked 15/9, 2022 at 17:24

5

Solved

So I have a project where I am using: Typescript TypeORM Type-graphql Jest I had it working just fine until I started writing my tests. The test files are inside of each entity folder. For exampl...
Utile asked 5/2, 2021 at 1:20

2

when i use react-testing-library, it says that error: invariant expected app router to be mounted , it has no such problem when running in the development environment. the testing logics is here im...
Chymotrypsin asked 8/8, 2023 at 10:46

0

I made the same settings for running vitest like in this article: https://medium.com/@zamin_mirzad/how-to-setup-vite-js-react-js-typescript-vitest-js-6e01b6436c6a But when I run yarn test I h...
Forestry asked 13/12, 2023 at 17:47

© 2022 - 2024 — McMap. All rights reserved.