Top "Jestjs" questions

Jest is a JavaScript unit testing framework made by Facebook based on Jasmine and provides automated mock creation and a jsdom environment.

How do you test for the non-existence of an element using jest and react-testing-library?

I have a component library that I'm writing unit tests for using Jest and react-testing-library. Based on certain props or …

reactjs jestjs react-testing-library
How to mock a constructor like new Date()

I have a method which depends on new Date to create a date object and then manipulates it. I'm testing …

javascript jestjs
Jest: how to mock console when it is used by a third-party-library?

I am trying to mock console.warn/error but i can't. I use a third-party-library which calls console.warn inside …

javascript unit-testing tdd jestjs
Watch and rerun Jest JS tests

The Jest documentation suggests using npm test to execute tests. Is there a way of watching your source and tests …

npm jestjs
Can I mock functions with specific arguments using Jest?

I would like to mock a function with Jest, but only if it is called with specific arguments, for example: …

javascript unit-testing jestjs
How do I test a jest console.log

I'm using create-react-app and trying to write a jest test that checks the output of a console.log. My function …

javascript reactjs jestjs
How do I get an attribute of an element nested in a React component using Jest and/or Enzyme?

I want to test to see whether an image has properly loaded in a React app. I have decided to …

javascript reactjs jestjs enzyme
How to unit test API calls with mocked fetch() in react-native with Jest

In React Native I use fetch to perform network requests, however fetch is not an explicitly required module, so it …

unit-testing react-native jestjs
Jest gives an error: "SyntaxError: Unexpected token export"

I'm using Jest to test my React app. Recently, I added DeckGL to my app. My tests fail with this …

jestjs
Jest how to assert that function is not called

In Jest there are functions like toeCalled or toBeCalledWith to check if a particular function is called. Is there any …

jestjs