jest Flashcards

1
Q

to run tests in create-react-app, you type

A

npm test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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')
})
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

To create a jest mock function

A

const myFuncName = jest.fn(()=> “string”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly