EduFlow
Testing JavaScript Apps

Checkpoint: Why and What to Test

Five questions on this section. Answer all of them, then see your score and why each answer is right or wrong.

Question 1 of 5

A user reports that splitting a $100.00 dinner between three people leaves the balances one cent off. Which test do you write first?

Question 2 of 5

Assuming the imports are in place, what happens when this test runs?

JavaScript
test('formats cents', () => {
  expect(formatMoney(1234)).toEqual('$12.34');
  expect(formatMoney(5)).toBe('$0.05');
});
Question 3 of 5

Your package.json has "test": "vitest", and the GitHub Actions job runs npm test. What happens after the tests finish in CI?

Question 4 of 5

A test fails with this output. What is the most likely bug?

Text
FAIL  src/tip.test.js > withTip > adds a 15% tip
AssertionError: expected { tipCents: 300, totalCents: 2000 }
  to deeply equal { tipCents: 300, totalCents: 2300 }
Question 5 of 5

Your project has 300 tests of pure money logic and 5 test files that render DOM. How should you configure the environment?

5 questions unanswered