Category "jestjs"

React Testing library custom setup import test-utils: module not installed. Unable to resolve path

I'm trying to configure jest absolute path for my custom test-utils directory (https://testing-library.com/docs/react-testing-library/setup#configuring-jest-wit

How to mock $nuxt object in vue-test-utils and jest

I am using vue-test-utils and jest in order to test my code. My test run without any problem except if it pass through the code below $nuxt.$store.commit("devi

Jest: ReferenceError: global is not defined

So I am writing unit test using "react-testing-library" on Jest and I have this error: Test suite failed to run ReferenceError: global is not defined

How do I use Vue3 with vue-jest?

I have the following dependency... "vue-jest": "latest", But when I run npm install I get... npm WARN ERESOLVE overriding peer dependency npm WARN Found: vue@3

How to turn off logs from winston for jest

Currently I am testing a NodeJS app using jest. Particularly the system looks like this: NodeJS v13.4.0 Jest 25.4.0 winston@next 3.2.1 When I run tests, I lik

Is it is possible to test only one function from component with Jest?

I have react component, for example something like this: const MyComponent = (props) => { const [state, setState] = useState(true); const {data} = useCon

Playwright JS - How to globally define/change timeout if element/selector not found?

Basically I want playwright to wait for each element 5 seconds if element not found. There is a way to change timeout individually as given below: await page.wa

Number Matcher Error even though values are of type Number

I am having trouble with the third test case in my describe case. More specifically, I get the error with the line expect(secondResult._body.length).toHaveLengt

NestJS cookie-parser is not a function error during e2e test

I have tried to add cookie-parser - https://www.npmjs.com/package/cookie-parser to my NestJS app: import * as cookieParser from 'cookie-parser'; consumer .appl

How to debug Jest Tests when using Yarn 2 / Yarn PnP

I'd like to use the node --debug-brk feature described in a previous answer and the jest docs to debug in npm/yarn 1 based projects, but node_modules/ is not pr

How to mock uuid with Jest

so on my search for an answer to my problem I found this post: Jest: How to globally mock node-uuid (or any other imported module) I already tried the answer b

@react-native-firebase breaking unit tests

I installed v6 of @react-native-firebase, it's working as expected but when I try to run a unit test I get the following error: Jest encountered an unexpected

Jest Cannot read property 'createEvent' of null

I was trying to mock rejected value and got this error. It's weird that this construction works in the case of "success" addUser.mockImplementation(value =>

Unexpected token 'import' error while running Jest tests?

I realize this question has been asked several times but all of the solutions I've come across don't seem to work for me. I'm running into the following error w

How to do Parameter Validation while using aws-sdk-mock

I am using aws-sdk-mock with Jest for testing AWS Lamda. My lambda uses AWS Polly Service to convert text to speech. Following is the piece of code which I want

How to mock react custom hook returned value?

Here is my custom hook: export function useClientRect() { const [scrollH, setScrollH] = useState(0); const [clientH, setClientH] = useState(0); c

How to pass in the done() parameter on an async jest test.each case

I'm trying write a jest test case that tests an async method, I want to pass in the done() parameter so jest waits for it to be fired before it ends the test, h

Testing functions with arguments in React with Jest Enzyme

I have a function named toggleFilter() in a react component which looks like this: toggleFilter = (filterType, filterName) => { const filterApplied

"istanbul ignore next" command seems to be ignored

I'm trying to use Jest to test my code. It was working quite fine until I tried to exclude a class method from the tests. The querySelector() call is the reason

aws cdk 2.0 init app fails to build with prettier issues, which is from jest-snapshot

node: v16.7.0cdk: 2.0.0 (build 4b6ce31) package.json: "devDependencies": { "@types/jest": "^26.0.10", "@types/node": "10.17.27", "aws-cdk": "2.0.0