Questions tagged [ts-jest]
A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.
ts-jest
1,647
questions
0
votes
0
answers
12
views
Why are my NestJS Guards not included in Jest code coverage?
I have written unit tests for my Nest Guards, and then run just fine and pass, but when I check my code coverage they are not included in that! You can see in my console output the *.guard.ts files ...
0
votes
0
answers
14
views
NestJS & Jest: The presence of jest.config.ts causes "strange behavior" during build
I have a Nestjs service inside my monorepo project with the following structure:
/
- package.json
- packages/
- - frontend/
- - backend/
- - backend/package.json
backend is the nestjs service, ...
0
votes
1
answer
24
views
Code coverage not working as expected on Linux and Mac
I have a Next.js project which uses React, MUI and TypeScript and Jest (with RTL) for testing.
I have achieved 100% test coverage on Windows, but when I run the test coverage on a Mac or my Ubuntu CI ...
0
votes
0
answers
31
views
ts-jest unable to process a file
I am new to jest and am trying to implement unit tests in a sharepoint framework solution. I am using ts-jest to process my typescript files and am currently struggling to get a self built package to ...
0
votes
0
answers
19
views
Jest has different behavior in watch mode
I'm writing a extension for chrome omnibox. And I'm using jest to write testing, but I found that the behavior of npx jest and npx jest --watchAll are different.
Detailly, npx jest works fine and it ...
0
votes
1
answer
31
views
Nest can't resolve dependencies of the I18nService
getting error when i try to run test cases
import { Test } from '@nestjs/testing';
import { appConfig } from '../app.config';
import { CommonBotModule } from '../common/common-bot.module';
import { ...
0
votes
0
answers
13
views
Unit test with NestJS, Jest and GraphQL : import module fail
I'm new to TDD and Jest, and trying to test the CRUD routes for my app created with NestJS.
The tricky part is that I use GraphQL and could not find any help online that works, at least for me.
I have ...
0
votes
1
answer
18
views
Nestjs jest unit test returns this.userModel is not a constructor
I am down to one failed unit test and for the past 3 days I have not been able to pass it. I am getting the followning error in the console related to the jest test:
FAIL src/user/user.service.spec....
-1
votes
0
answers
27
views
How to run multiple test cases from single directory using Jest
I have the following directory structure:
parent
dummy
runas
src
__tests__
packages
runas
src
__tests__
jest.config.js
package.json
I want to run all ...
0
votes
0
answers
25
views
"Error during clean up of this component" in nx angular jest testing
Problem: All unit tests for my-angular.component.ts throw : "1 component threw errors during cleanup"
Testing Environment: nx, angular v17, jest v29.4.1
cli command used: npx nx test <...
-2
votes
0
answers
39
views
Unable to run Jest test cases in nx workspace
I am using nx workspace and encountered the following error messages while attempting to run Jest test cases.
Jest encountered an unexpected token
Jest failed to parse a file. This happens e....
0
votes
2
answers
75
views
Ts-jest SyntaxError: Cannot use import statement outside a module
Issue
I'm running into error SyntaxError: Cannot use import statement outside a module for my jest unit tests after switching one of the packages in our dependencies. The package is a hard requirement ...
0
votes
0
answers
17
views
(Jest/ ts-jest) Mocking exported function is not working
I'm trying to mock a simple exported function in a test with Jest.
The problem is that the mocked function is not being called.
example.ts
export const exampleFn = () => {
return 'example'
}
...
0
votes
1
answer
53
views
Mocking fetch return response using Jest in Typescript
I have a function that calls fetch() and handles different cases of its response data.
When trying to mock the global fetch function using Jest I am having trouble with the Response type.
I only need ...
1
vote
1
answer
28
views
Jest. The original function is called instead of the mock function
I'm facing an issue with function mocking in Jest, especially when one function calls another within itself. I'm using Jest to test the tools module where testBar calls testBar1. I'm trying to mock ...