Complete the code to import the testing framework.
const { test, expect } = require('[1]');We use jest as the testing framework here. It provides test and expect functions.
Complete the code to define a test case with a description.
test('[1]', () => { expect(2 + 2).toBe(4); });
The test description should explain what the test checks. Here, it checks addition, so 'Check addition' fits best.
Fix the error in the assertion to check if the value is true.
test('Check boolean', () => { expect(true).[1](true); });
toBeTrue which does not exist in Jest.toBeTruthy which checks truthiness, not exact true.The correct Jest matcher to check exact equality is toBe. toBeTrue is not a valid Jest matcher.
Fill both blanks to create a test that checks if a function throws an error.
test('Throws error', () => { expect(() => [1]()).[2](); });
toBe.The function to test is myFunction. To check if it throws an error, use the toThrow matcher.
Fill all three blanks to write a test that checks if an async function resolves with a value.
test('Async resolves', async () => { const result = await [1](); expect(result).[2]([3]); });
The async function is getData. We check if the result equals the string 'success' using toEqual.