describe("foo", () => {
describe("called with true", () => {
it("returns 1", () => {
assert(foo(someComplicatedThing, true) === 1)
})
})
describe("called with false", () => {
it("returns 12", () => {
assert(foo(someOtherIndecipherableThing, false) === 12)
})
})
})
It's the same problem as comments that repeat what the code says, rather than what it means, why it's being done that way, etc. It's more annoying in tests, since useless comments can just be deleted, whilst changing those tests would require discovering better names (i.e. investigating what it means, why it's being done that way, etc.). The latter is especially annoying when a new change causes such tests to fail.Tests with such names are essentially specifying the function's behaviour as "exactly what it did when first written", which is ignoring (a) that the code may have bugs and (b) that most codebases are in flux, as new features get added, things get refactored, etc. They elevate implementation details to the level of specification, which hinders progress and improvement.