Recall & Review
beginner
What is the Node.js built-in test runner?
It is a simple testing tool included with Node.js that lets you write and run tests without installing extra packages.
Click to reveal answer
beginner
How do you run tests using the Node.js built-in test runner?
Use the command
node --test in your terminal to run test files automatically detected by Node.js.Click to reveal answer
beginner
Which module do you import to write tests with Node.js built-in test runner?You import the <code>test</code> function from the <code>node:test</code> module to define your tests.Click to reveal answer
beginner
What is the purpose of assertions in Node.js built-in test runner?
Assertions check if your code behaves as expected. If an assertion fails, the test fails and shows an error.
Click to reveal answer
intermediate
How do you write an asynchronous test using Node.js built-in test runner?
You define the test function as async and use
await inside it. The test runner waits for the async code to finish.Click to reveal answer
Which command runs tests using the Node.js built-in test runner?
✗ Incorrect
The correct command is
node --test which runs tests using the built-in test runner.Which module provides the test function in Node.js built-in test runner?
✗ Incorrect
The
node:test module provides the test function for writing tests.What happens if an assertion fails in a Node.js built-in test runner test?
✗ Incorrect
If an assertion fails, the test fails and the error is reported.
How do you write an asynchronous test with Node.js built-in test runner?
✗ Incorrect
You write async tests by marking the test function async and using await inside it.
Which of these is NOT a feature of Node.js built-in test runner?
✗ Incorrect
The built-in test runner does not have a graphical user interface; it runs tests in the terminal.
Explain how to write and run a simple test using the Node.js built-in test runner.
Think about the steps from writing code to running it in terminal.
You got /4 concepts.
Describe how asynchronous code is tested using the Node.js built-in test runner.
Consider how async/await works in JavaScript tests.
You got /4 concepts.