Testing 101
Or that time i got way too obsessed with testing a package I was building
Hew

@hewIngram
THE BASICS

Avoid bugs
Ensure functionality works
Safely deploy anytime
Reliable, predictable code
Better code?

E2E
Integration
Unit
Linting
Linting


Find possible logic errors

Promote best practice

Promote stylistic consistency

Pssst...
Fail fast
Zero setup
(basically)
Great configs to start with
Customizable
🎉
Accessibility + security
File by file
🤮
Annoying to introduce in legacy codebases
Unit
E2E
Integration
Unit
Linting


Should return 'apples' if inputAnimal is hippo
Should return null if inputAnimal is not in animalConfig










Snapshot tests mean I don't need unit tests anymore... right?


Fast to run
Easy setup
🎉
Promotes good code
Fast to build

Tests only a single function
🤮
Can be fragile
Not all code is unit testable

E2E
Integration
Unit
Linting
More real
Slower
Harder to build
Integration

Closer to 'real' usage
Great as code/team grows
🎉
Hard to setup
🤮
Errors can be hard to pinpoint
Slower to run
E2E

Super real
Tests loads of things at once
🎉
Getting easier to write
SO SLOW
🤮
Hard setup
(historically)
Brittle
Can be hard to find root cause if there are errors


Linting
Unit tests
Integration
End to End
✅
✅


Mutation
E2E
Integration
Unit
Linting
Fuzz testing

F̷̢̧̧̧̧̛͓͚̦̼̺̝̝̞̱̦̟̘͍͈͈͕̩̼̣̩̠͍̥̤̤̹̦̝̺̼͓̤̯̱̳͎͚̺͔̯̯͕͓̝̯͎͔̱̯͖͖̞̊̈́̓̈̒͊̈́̿̀̀̌̈̀̏̄̿̃͗̈́̉̉̆̐̌̒͑̔͑̿̈́̏̾̌͌̏̓̿̐̅̓͗̄̂͌̂̂̂̋͂̈́̄̾̆̐̐̀̈́̀̅̿̑̇̎̿̐̒́̿́͒͗̽̓͒͐̋̍͋̕͘̚͘̚͠͝ͅư̴̢̧̨̨̡̛̬̣͎͔̗̬͖̟̠̤̹͖͙̺̻̹̼̦̬͈̟̰͔̟̹̟̭͉̝̳̩͓̦̙̰͔̣̱͙̣͓͓̻̱̪͓̤̭͙̞̫̗̭̯̖͙̱̠͉̖̺̪̰̬̺͉̝̜̠͎͕̪̭͎͎͖̼͎͇̲̝̰̣͋̾͐͛̃̓́̓͜͜͜͜ẕ̴̨̧̨̡̨̡̰̟̲͔̱͍̬͈̲̬͖̟̦̭̳̣͓̣̖̙̩̺̤̭͓̫͔̬̰̮͙̰̪͍̠̭̲͖̞̰̳͍̲̞̭̥̘͖̫̙̥͉̮̱̮́͋̔̇̅̎̽̾̑͌̏̈́̈̃̈̄̊̎͒̒͂̂̇̏̀͋̉̔̾̓̃̈́́͆̀̓̊̋̈́͐͂͆́͐͂̈́̕̚̚͘͜͜͜͝͝͝͝ͅz̸̛̛̻̯̱̱̺̫͍͔̔̋́͑̉̔̀́̈̈́͗̐̈̀̐͑̋̏͂̈́͐͑̆͐̂̈͊̑̈́̽̈́́̀́̿̇͋́͐̊̏̒́́͂̈́̋́̕̚̕̕̕͝͝͠͝͝ ̴̧̨̡̧̡̟͎̭͔͖̮̺͖͙̼̦̻͍͚̭̠̟̯͔͍̖̝͎̠̭̱̦̱̻̤͚̺̲̞̩͍̭̼̲̻͎͙̝͔̺̖̘̫̰͚̮͉̯̬̩͖̭̞̹̻̻͍͖͉̥̮͖̫͙̦͉̘͙̞̲̼̯̩̞̯̗̗̬̫͍̇́̀̍̎̾̏͋̅̀͌̓̋̾͊̀̃͆̄͋͌̇͆̈́̊̊̆̿́̊͑̏̄̐̎̄̈́̔̐̀̽̃̄̓͊͗̋̇̓̽̐͐͒͒̔̈͌̀͂̆̊̍̉́͑̕̚̕̕͜͜͜͜͝͝ͅͅͅt̷̢̨̡̡̧̛̛̙̱̦̗̹̫̥̭͉̩͙̯̖̖̟̥͕̥̳̥̹̩̳̮̟̝͔̬͇̠̰̠̮̳̖͍̮̬̝̜͇̠̠̱̗̖̩͕̲̤̬̱̲̹̗̳̞̣͕̼̳̯̰̮͆̋́̅̄͂͋̐̐̑̄̿̀̑̿̿̎̆̉̔̅̉̾̈́͛̔̐̈́͐̌͗́͗̀̀̊̄̉̽̉͛̅̽̃̉́̅͒̇̃́̍̈́̄͋̕̚͘̚̚̚̚͜͜͜͜͠͠͝͝͠͝͠͝ͅé̵̡̡̢̡̨̛̤͉̦͈̟̱̜̯͈͎͉͎̹͖͎̘̮͓̻͓̱̫̩̘̥͙̺̖̟̿̑̀̔̑̈́͛̓͌̊̔̔̑̒͗̈͆̂̉̅̏̽̇̚̕͝ͅͅs̷̡̛̙͓̲̱͉̥̩̠͋̓̽͑̃̉͌̐̐͗̀̃̓̌̇̿̓̆͂͗̇̍͘̚̕ţ̴̨̨̢̙̠̝̼̭̗̞͉̲͇̜̙͔̩̻̠̟̯̪̫̯̜̞͚̼͚͚̫̬̪̰͍͎̭̻̳̘̩͇͍̖͕̣̱̤̥͖̫̊̏̄́͑̀i̴̧̦͙͙̱̹̰̲̭͔̤͍̦̼̰̻̱̩̩͍̘̪̘̥͉͓̟̰̳̱̖̍͆̋͆͊̉̉̀̿̑́̇̇͆̎̒͘͘͜͝͝n̶̛̛̬̤̱̼̯̰͖̮̲̦̻͍̯͖̈̒̃͆̌̔̍̿̐̆͒͂͊̂͒̽̈̑̔̊́̃̂̋͒̈́̃͂͆̀̓̂͐̃̔̅̀̊̆̽̆͑̄̅͋̑͋̓̈́̌̏͐̉͌͐͋̓̓̑͒͌́̿̃̋̔͊̿̐̓̔̍̋͛̾̅̄̃̄̈̚͘͘̚̚̕͝͝͠͠͝͝ģ̸̛̮͎͙̱̘̺̝̹̾̓̉͗͗͛͌͆̽̇̃̌̓͊͂̇͗̈́͗̄̎̐̆́̋̊̃́̍̃̏̈́̔̌̈́͐̿̾̋̍̌̒̑̄̈́̊̑̋͗̽̈́̍̇̽̕̕̚̚͘̚͠




REALLY test your code
Get to feel super cool using a weird testing method
🎉
Increased confidence
Can be very slow
🤮
Immature in JS
Only applicable to some things
But... I want to know my tests are good





Tests your tests!
Easy with libraries like Stryker
🎉

CPU intensive
🤮
Immature in JS
Only mutates return values...
Mutation
E2E
Integration
Unit
Linting
Fuzz testing
Thanks
@hewIngram
Testing 101
By hewingram
Testing 101
- 260