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.

test process.env with Jest

I have an app that depends on environmental variables like: const APP_PORT = process.env.APP_PORT || 8080; and I would …

node.js testing environment-variables jestjs
Jest spyOn function called

I'm trying to write a simple test for a simple React component, and I want to use Jest to confirm …

javascript reactjs testing jestjs enzyme
Jest spy on functionality

I am swapping to Jest from Mocha, and I'm wondering if there is a way to spy on a React …

javascript reactjs jestjs
How to clear Jest cache?

Jest is picking up an old version of a package and thus my tests fail unless I use --no-cache. I …

jestjs
How to mock imported named function in Jest when module is unmocked

I have the following module I'm trying to test in Jest: // myModule.js export function otherFn() { console.log('do something'); } …

unit-testing ecmascript-6 jestjs
Run only ONE test with Jest

Very simple, I want to run just one test with Jest. I put it.only or describe.only but it …

javascript unit-testing jestjs
Jest: How to test for object keys and properties

I have a mapModule where I import components and export them: import ComponentName from '../components/ComponentName'; export default { name: …

javascript unit-testing jestjs
How do I set a mock date in Jest?

I'm using moment.js to do most of my date logic in a helper file for my React components but …

momentjs jestjs
Mocking globals in Jest

Is there any way in Jest to mock global objects, such as navigator, or Image*? I've pretty much given up …

javascript unit-testing dependencies jestjs babel-jest
What is the difference between 'it' and 'test' in jest?

I have two tests in my test group. One of the tests use it and the other one uses test. …

javascript unit-testing jestjs