testdouble.js
testdouble.js copied to clipboard
following the "game of life" example, td.verify with _.isEquality
Hello. I'm trying to follow the game of life discovery testing by Justin Searls , with TypeScript.
I added the second test, without changing the code, and it passes:
test('one generation', () => {
const seedWorld = new World()
td.when(generatesSeedWorld.generate()).thenReturn(seedWorld)
const seedWorldSecond = new World()
simulatesConway.simulate(1, 1337)
td.verify(outputsWorld.output(seedWorld))
td.verify(outputsWorld.output(seedWorldSecond))
})
Because seedWorld is at this moment exactly the same as seedWorldSecond (although it is not THE SAME one). When I added this.random = Math.random() to World constructor, the test properly failes. I'm trying to understand the principle behind this kind of testing, which should not be language/framework specific as far as I understand.
How would you write a test like this then, in testdouble? Should I somehow force a different comparison mode? For now for learning purposes I'm going to leave the random there, but "there must be a better way" ;-)
Thanks a lot!