Category "jestjs"

How to Unit Test a method inside a module in NestJs (Jest)

I'm adding tests on a project and improving coverage. I would like to know how can I test a method defined inside a module definition in NestJs. import { Middle

Jest Testing - mockReset does not clear the already set values

I have a lambda which calls an interface. Am trying to mock the functions imported from the interface. In each test case, I have to mock different values. When

Can I mock one function exported from a typescript module that uses ES6 import style

I have been struggling with some specific ES6 importing-style and using with Jest mocking in typescript. It's very specific, so I wrote this example puzzle to

React/Jest - How to simulate touch "swipe" event

I have a component that triggers a function call whenever a swipe interaction was done. This swipe interaction can either be executed by touchEvent or mouseEven

Jest test error: ...subscribe is not a function

I'm using Jest to test my Angular app (using Nx workspaces). I have a component that uses a service that I'm trying to mock. Here's the code: myDummyService.per

Test functions cannot both take a 'done' callback

I'm trying to create a simple test with nestjs, and I'm get this error Test functions cannot both take a 'done' callback and return something. Either use a 'do

NestJs e2e returns 201 created response though required form data is missing, expected 400 bad request

I'm trying to write a test that checks if request body does not have proper data, it should return an error, and the status code should be 400. Which I think is

Why does jest mock test give me undefined?

I am new to learning jest mocks. I am trying out a very simple test. I have a folder greeter. This folder has a file 'greeter.js' and a subfolder called 'test'.

TypeError: _API.default is not a constructor with Jest tests

I have an API class that I am trying to use in a React app. // API file class API { ... } export default API; // Other file import API from "utils/API"; con

Express Route Testing - req.parameter

How would one test an express route such as app.get('/myapp/:parameter') How would I use jest to test that no parameter was passed? I have an error that will re

Cannot find module '@babel/runtime/helpers/interopRequireDefault' from 'node_modules/react-native/jest/setup.js' when I run tests

I'm trying to build a mobile application with typescript, react-native, expo and jest. When I'm trying to run tests: FAIL src/components/Button/tests/Button.t

react testing library: can't acquire context from the given item

I have this component, which uses react-chartjs-2 to render a Doughnut chart: const CompliancyChart = ({data}): JSX.Element => { ... return ( <Cha

supertest gets timeout error when I use await in a controller

const express = require('express'); const router = express.Router(); const Product = require('./../model/product'); router .route('/api/product') .get(async

Jest test passes but .. has console message You are trying to access a property or method of the Jest environment after it has been torn down

My test passes but has a console refrenceError: You are trying to access a property or method of the Jest environment after it has been torn down. Test: import

Mocking a function in jest which returns Promise<string[] | never>

I'm using React+JEST to test an existing component. It has a function filterDeliveries like so : const filterEmptyDeliveries = (arr): Promise<string[] | neve

Jest test sometimes fails (DynamoDB integration tests)

I have Serverless application (node:14.19.1-bullseye-slim) with almost 400 tests. There are mostly functional tests with using of local DynamoDb. The problem is

Testing async methods in jest gets mock resolved values mixed up

I'm writing some jest tests to test an async method. If I run each test individually, it works! However, when I run the whole suite, they fail. The mock values

Jest done callback is not assignable to parameter of type ProvidesCallback or undefined

I am trying to create a test with jest and I want to use done() callback but Typescript is not accepting it, I tried to use type any, jest.DoneCallback or leavi

No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?

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 "EXNativeModulesProx

Using Vue Test Utils, how can I check if a button is disabled?

I'm testing a Vue component but I'm having trouble testing a button's disabled state. How can I access a button's disabled status in my tests? I've tried using