jest Flashcards
1
Q
to run tests in create-react-app, you type
A
npm test
2
Q
to create a basic react unit test (tests one thing), type
A
import { myFuncName } from ‘./App’
test('testName', ()=> { const myFuncResult = myFuncName('my_test_param') expect(myFuncName).toBe('value') })
3
Q
some common assertions are
A
expect(myFuncName).toBeTruthy() expect(myFuncName).toBe(param) expect(myFuncName).toEqual(param) expect(myFuncName).toBeGreaterThan(param) expect(myFuncName).toBeInstanceOf(param)
4
Q
To create a jest mock function
A
const myFuncName = jest.fn(()=> “string”)