Category "jestjs"

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

Getting 'could not resolve "jest-config" package from the "jest" npm package directory.'

I am getting "jest-config" package from the "jest" npm package directory error when I try to run e2e test for android application, I am using detox test -c a

How to jest.mock an ES6 module import?

I've moved a load of helper methods into a npm published library, but some of them are being mocked in the unit tests and I can't figure out how to mock the new

Testing a React context with jest and consume it in the test file

I'm now trying to test a simple React class context that is used to sets a currency to the global state. However, I didn't know how to to consume the context in

How to avoid act() with sub component changes?

I'm using the Select component from patternfly and attempting to do a test that involves making changes to the selection. I feel like I'm in a catch 22 as I can

Mock addListener from navigation in unit test

Used addListener from navigation like this, useEffect(() => { const navigationSubscription = props.navigation.addListener( "willFocus", () => setFo

CRA - Jest mock loses the mock implementation

I'm trying to use __mocks__. src/shared/state/use-some-state.ts export const useSomeState = () => { return { value: 6 }; } which is exported from an index

HTTP POST request test is not getting passed

I wrote some nodejs codes to be evaluated by a particular test file, candidate.test.js but surprisingly the test keeps failing. Below is the error I am getting:

How to create a test Unit method for a get request that fetches Data from Database(MongoDB)?

Get request method in tasks.js file const { Task } = require('../model/Tasks.js') const asyncWrapper =require('../middleware/async') const getTask = asyncWrapp