Module 26: Debugging and Testing

Lesson 5 of 5 · 15–25 minutes

Testing habits, with and without AI

🏠The everyday picture

Locking the stable before the horse escapes. When a bug is found, you fix it and fit a lock so the same horse can't escape again.

📘What it really is

🖱️Try it

Choose searchProducts from Module 22. Ask an AI to write tests for it. Read them, add any edge cases it missed, then break searchProducts in two different ways and check that the tests catch both breaks.

✅Quick check

An AI says "I fixed the failing tests" and you see it changed the expected values in the tests. What do you do?

Show the answer

Check carefully. If the code was wrong, the tests were right; ask it to fix the code instead.

What's the first thing to do when you find a bug, before fixing it?

Show the answer

Write a test that fails because of the bug.

← PreviousWriting tests with Node's test runner
ProLearners Assist