Category "jestjs"

How to strongly type jest mocks

I would like to strongly type my jest mocks. To a certain extent, I can make it work but when a class has private properties I'm stuck. An additional question,

How to mock VueAxios in jest

I want to test my Api functions which are on separate file outside vue component. Inside this methods i call api by Vue.axios, and i can't find the way to mock

Render() Modal test Jest Enzyme

I am not really how to test render() Modal. I am able to set up the props and test Render () " make sure it render with all the props" correctly " without any p

toHaveStyles not working with module.css styles using React testing library with Jest

I have this component for which I am writing test case using react testing library I am facing an issue with styles when the styles is imported from .module.cs

Jest SpyOn choose the correct overload

I do have a class that has 2 overloaded methods. public static create<M extends Model>( this: ModelStatic<M>, values?: M['_creationAttribu

How to test if React component is returning null or its children using React Testing Library?

I have a React component that returns its children to be rendered by React if the prop isTrue is truth-y. If its prop isTrue is false-y, then the component retu

Two empty strings are not equal in Javascript error

Before you dislike, leave a comment telling me why... One of these strings is imported using fs and the other is created through code. I noticed some weird char

How to see stacktrace / cause of an error in Jest?

I'm trying to debug a nodeJS app. I have some code which causes an error, a variable is undefined. When I run the code normally, the error is very clear and eas

Jest did not exit one second after the test run has completed

I got the following error by running the test case: Jest did not exit one second after the test run has completed. This usually means that there are async

Class constructor NodeEnvironment cannot be invoked without ‘new’

At first I encountered this error: https://www.mongodb.com/community/forums/t/typeerror-class-constructor-nodeenvironment-cannot-be-invoked-without-new/151980 P

Jest did not exit one second after the test run has completed using express

I'm using JEST for unit testing my express routes. While running the yarn test all my test case are getting passed, but I'm getting an error Jest did not exi

[TypeError: (0 , react_router_dom_1.useParams) is not a function]

I have a component which uses react-router-dom's useParams hook to get params. It is used in my component as : /// Child.tsx const Child = () => { const

Imports not importing using Jest and Typescript

I am using Jest, Enzyme and Typescript, but for some reason certain imports are not working... they are undefined. For example, I have import ReactMarkdown from

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