Tip Top Testing in JavaScript
summary
Practical rules for reliable JS tests: every unit test has setup invocation assertion and tests the public contract not internals, use jest and enzyme (or react testing library) with mocks and spies to isolate calls like Thread events logging or window.location.assign, clear mocks between tests, keep factories (eg test data bot) for realistic fixtures, write failing tests first then red green refactor, and prefer user-visible assertions so refactors don’t break otherwise brittle tests.
AI-written summary · about
chapters (22)
- 0:00Intro
- 0:26Tip top JavaScript Testing @Jack_Franklin
- 0:45How to write good tests
- 1:29It's important your application code is well written and maintainable.
- 2:11Unless you write tests for your tests
- 2:24What makes a great unit test?
- 4:04Tests should have no external dependencies
- 4:32If your tests can fail without any of the code you're testing changing, your test is not properly isolated.
- 8:25don't test things twice
- 10:57Mocks are an essential tool in a developers testing toolkit
- 14:27Avoiding brittle tests
- 15:50You should be able to rewrite code without changing all your tests.
- 16:14When writing new tests, check that they fail!
- 17:02Many test frameworks will pass a test without an assertion!
- 17:17If you write a test and it passes first time, try to break it
- 17:33small feedback loops
- 19:082. Fix the bug without changing the test
- 19:34Confident refactoring
- 21:11Testing React
- 22:42A React component's contract is what it shows to the user.
- 25:05Remember what makes a good test: setup, invocation, assertion
- 25:19When it comes to React, the framework doesn't matter if you test like a user
related talks
01h 02mWriting better tests for your JavaScript app
37mTesting in the Node.js World
45mWriting Tests That Don't Suck: TDD in JavaScript
39mTesting, Testing, 1, 2, NaN
21mTesting Javascript: Building JavaScript applications you won't hate
41mTesting that the code does what the code does
29mTesting Is All About Principles
42mSurviving the JS Testing Tools Jungle
