All Questions
436
questions
1
vote
0
answers
68
views
Test suite failed to run ReferenceError: TextEncoder is not defined
I am trying to test my project using a mock API instead of a real one to save money. However, when I add the following code to my setupTests.js file:
// setupTests.js
import { server } from "./...
1
vote
1
answer
70
views
How to unit test logic under AG GRID gridApi function forEachNode
Trying to get my unit test coverage for this bit of code:
processUpdates(input) {
let request = [];
this.gridApi.forEachNode(function (node) { // <--- How to mock/spy inside forEachNode
...
-1
votes
1
answer
14
views
Can't spyOn second & third call jest
I can't do spyOn on the second and third calls of a function in a test with jest
I tried to do it like this by following the documentation :
it("should succeed after retry on first attempt ...
0
votes
0
answers
27
views
How can I create a unit test for a memory dump without mocking?
In Javascript, I have these two functions:
const promiseMemoryDump = async (address1, address2, outputFile) => {
if (getPlatform() === 'linux') {
await promiseExec(`memdump -s ${address1} -...
1
vote
1
answer
92
views
speedup Nestjs + jest test performance
I wrote about 2,000 testcase in nestjs application with jest.
but it takes around 3 minutes to take overall test.
I want to reduce the time executing these tests.
when i examine the situation, jest ...
1
vote
0
answers
32
views
getting some issue when I apply npm run test
I'm runnig npm test on my proyect, next js and I'm getting this issue:
> npm test
> [email protected] test
> jest
FAIL __tests__/pages/Home.test.tsx
● Test suite failed to run
Jest ...
0
votes
0
answers
100
views
Nx doesn't find generated files in tree using a plugin generator while testing
I'm working in a Nx workspace, trying to create some generators. It works fine until I try to test them. The test update the tree and create all the files but fails trying to find tsconfig.json which ...
1
vote
0
answers
33
views
Cant change the value, it stucks with 1 as default, why?
I'm new in react and doing testing, I need to do an unit test that should fail but is working, type should be empty when brandId is 2, but is the same as you run it with 1, that returns model. brandId ...
0
votes
0
answers
281
views
Jest failed because spyOn is still apply
I have a nodejs under nestjs App, i have some testing on Pipe.
I follow this type of architecture https://github.com/mguay22/nestjs-mongo/tree/unit-testing/src/users.
My test works correctly when i ...
0
votes
0
answers
36
views
How to test console command with mocked functions
I'm trying to make tests for my console script.
# src/functions.ts
const fn1 = () => console.log('fn1');
const fn2 = () => console.log('fn2');
const fnErr = () => console.log('fnErr');
# ...
0
votes
1
answer
96
views
Custom snapshot serialiser
I'm literally trying 1:1 the test that is in Jest docs for customising the snapshot serialiser: https://jestjs.io/docs/configuration#snapshotserializers-arraystring
module.exports = {
serialize(val, ...
0
votes
0
answers
135
views
Jest SpyOn returning undefined
I'm trying to write a jest unit test using react-testing-library and jest without the use of enzyme as from research that I've done it appears that enzyme will not be supported by react 18. Therefore ...
0
votes
1
answer
413
views
Issue in creaating react jest test case when using chart.js
I have below test case. Please dont read entire code. (Its not necessary). what i am trying to say i wrote atleast 100times, checked with chatgpt, google bard still not able to make this test case ...
0
votes
1
answer
467
views
Jest mock DeviceEventEmitter from react-native
I am trying to mock DeviceEventEmitter from react-native using jest. The actual code adds and removes a listener on component mount and unmount respectively. I have tried a lot of solutions but none ...
1
vote
0
answers
444
views
TypeError: Cannot read properties of undefined (reading 'extend') in jest
I am using node version: v20.3.1 and jest version: 29.7.0, while running test cases getting typeError and i dont know how to solve it
jest.config.js
module.exports = {
roots: ["<rootDir>/...