Node.js Testing
Testing protects your Node code from regressions. Keep tests close to behavior and run them often.
Checks
- Verify one function with a known input and output.
- Check one server route returns the expected status.
- Test one async path with a predictable result.
Package scripts
{
"scripts": {
"test": "node test.js"
}
}
Practice
- Add one test script to a small project.
- Make the test fail once, then fix the code.
- Write one sentence about what the test proved.