A test driven workshop
By
Theryn Groetken
- Stop bugs from going to prod 🐛
- Know that you're shipping your best code 🏆
- Understand exactly what your code is doing ␆
Testing Helps:
Vs.
vs
Always ✅... There is zero reason not to.🚫
Eslint
Prettier
Coveralls
Stryker
Code Climate
Screener
System Under Test
Don't be dogmatic about it.
TDD eradicates fear of change. - Eric Elliott
TDD in one sentence:
You should ALWAYS make sure your tests break before you decide that they are passing.
Live Coding - Yay! 🎉
Want to be amazed by TDD?
Open up `./src/actions/transforms/`
External 🌐
Test Doubles - what are they?
open ./src/components/TodoDetails/
Selenium
WebDriver
Puppeteer
Casper
Zombie
Nightwatch
etc.
✅
Example:
open ./functional-tests
node --inspect-brk node_modules/.bin/jest --runInBandInstead of running our standard `yarn jest` we will run this:
* Uncle Bob - 3 TDD Laws [The Three Laws of TDD (Featuring Kotlin) - YouTube](https://www.youtube.com/watch?v=qkblc5WRn-U)
*Watch* from 0:00 - 24:00, this tells us why TDD is important and how it will help us. Everything after 24:00 is extra credit. Feel free to watch on 2x speed.
* Yoni Goldberg -[Node.js & JavaScript Testing Best Practices – Yoni Goldberg – Medium](https://medium.com/@me_37286/yoni-goldberg-javascript-nodejs-testing-best-practices-2b98924c9347)
*Read* a high level overview of testing, its history, its present, and its future. This is one of the best overall test articles I’ve read that is up to date.
* Kent C. Dodds - Javascript Testing Pyramid [Testing JavaScript with Kent C. Dodds](https://testingjavascript.com/)
*Read* - This is an important adjustment to the 10 year old “testing pyramid”, and now we have a “testing trophy”.
* Martin Fowler - Test Doubles (Definitions)[TestDouble](https://martinfowler.com/bliki/TestDouble.html)
* Martin Fowler - Mocks aren’t stubs [Mocks Aren’t Stubs](https://martinfowler.com/articles/mocksArentStubs.html)
*Read* these to get a good idea of what test doubles are, what their differences are, and when to use them. (Some examples in Java: Shaun Abram - [Test Doubles: mocks, dummies and stubs | Java Code Geeks - 2019](https://www.javacodegeeks.com/2015/11/test-doubles-mocks-dummies-and-stubs.html))
* Torin Billups - Ember Conf TDD [EMBERCONF 2015 - TEST-DRIVEN DEVELOPMENT BY EXAMPLE - YouTube](https://www.youtube.com/watch?v=2b1vcg_XSR8)
*Watch*This is the TDD talk that made everything click for me. It goes over component testing and how useful it can really be.
* Kent C. Dodds - Testing Practices and Principles [Learn Jest Testing Framework – JavaScript Testing Practices and Principles](https://frontendmasters.com/courses/testing-practices-principles/jest-testing-framework/)
*Interactive* - If you want to spend time going through an FEM workshop on how to test, Kent C. Dodds is your guy.
* Yoni Goldberg - 5 new shiny test types [Beyond Unit Tests: 5 Shiny Node.JS Test Types (2019) - YouTube](https://www.youtube.com/watch?v=-2zP494wdUY&feature=youtu.be)
Here are some advanced topics. These are the things that each person should get to know and think about as they move further into the world of testing. These are the things that we should start doing to make better, more comprehensive, and more reliable tests in 2020.