- 12 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 3/3/22
Test your React Application with Jest and React Testing Library
Evaluated skills
- Test your React app with Jest and React Testing Library
Question 1
Which of these statements are false?
Careful, there are several correct answers.If the name of your test ends with
.test.js
, you can put your file wherever you like in/src
.Unit testing is the type of test that takes the longest to write.
Tests provide security when modifying a codebase.
You can call your test files whatever you like, as long as you put them in a
_test_
folder.Continuous integration is a solution that triggers testing while you write your code.
Question 2
You’ve written a
timesThree
function that multiplies the number passed as an argument by 3.export function timesThree(numberToMultiply) { return numberToMultiply * 3 }
You create anindex.test.js
file. Which code snippets will test this function for you?Careful, there are several correct answers.it('should multiply by 3', () => { const expected = 6 expect(timesThree(2)).toBe(expected) })
describe('The timesThree function', () => { test('should multiply by 3', () => { const expected = 6 expect(timesThree(2)).toBe(expected) }) })
describe('The timesThree function', () => { test(() => { const expected = 6 expect(timesThree(2)).toBe(expected) }) })
test('should multiply by 3', () => { expect(timesThree(2)) === 6 })
Question 3
Complete the phrase with the correct answers: Code coverage…
Careful, there are several correct answers.should be 100 % for a modification to be considered reliable.
is a good indicator of the lines of code that are covered by tests.
is launched with the command
yarn test -- --coverage
.needs to be installed with yarn add
--dev jest/coverage
.
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring