Skip to content

Instantly share code, notes, and snippets.

@bbbbruni
Last active July 16, 2018 23:38
Show Gist options
  • Save bbbbruni/edd8a6938f01637af5dd94d59b7f9532 to your computer and use it in GitHub Desktop.
Save bbbbruni/edd8a6938f01637af5dd94d59b7f9532 to your computer and use it in GitHub Desktop.

💡 TDD

TDD Simple Flux

Thinking tests

  • What does the code need to do?
  • Which type of data my method/code receive? (String, Number, Array ...)
  • Which type of data method/code returns?
  • Which action trigger my method/code?

Pattern of a literal test

  • "It should do that when this."

Pattern of coded test

  it('should return 4 when it receives 2,2') {
    expect(sum(2,2)).to.equal(4);
  }

Spies, Stubs & Mocks

  • Spies

    Watch and verify if a method is called in any file or code block.

  • Stubs

    Control test behavior(example: an exeption), skip unecessary part of a code(example: database execution) and simplify asynchronous code test.

  • Mocks

    False methods and pre-coded expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment