1. React
  2. JSConf Hawaiʻi
  3. 2020
  4. Kill All Mutants! (Introduction to Mutation Testing)

Kill All Mutants! (Introduction to Mutation Testing)

How good are your tests? Would they still pass if the tested code was changed? If so, there may be problems with your code, your tests, or both!

Dave Aronson at JSConf Hawaiʻi 2020

How good are your tests? Would they still pass if the tested code was changed? If so, there may be problems with your code, your tests, or both! Mutation Testing helps reveal these cases.It makes lots of slightly altered versions, called "mutants", of your functions, and runs your functions' unit tests, using each of its mutants instead. If a mutant makes any test fail, that mutant "dies". "Survivors" imply flaws: your code might not be meaningful enough that a slight mutation would change the behavior, your tests might not be strict enough to catch the difference that the mutation made, or both! This talk will tell you how to use mutation testing, its benefits, drawbacks, and pitfalls, and how it works under the hood.There will be several examples(in clear pseudocode), and a list of tools for some popular languages(including of course Javascript). You will come away equipped with a powerful new technique for making sure your tests are strict and your code is meaningful.