testdouble / testdouble/testdouble.js

following the "game of life" example, td.verify with _.isEquality

Open
#295 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.4k
Forks
140
Avg merge
22h
Merged PRs (30d)
1

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the game of life example and the second test shown, then inspect td.verify and _.isEquality behavior for seedWorld and seedWorldSecond. Done means the expected comparison behavior is established with a focused test or a clear explanation of how this case should be verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.