- Arrange - test setup
- Act - calling the tested method
- Assert - comparing with right result
- test runner: mocha, tape, jasmine, karma, jest
- assertion library: chai, alternatively the assert module (for asserting)
- test spies, stubs and mocks: sinon (for test setup).
- Spies - you can use spies to get information on function calls, like how many times they were called, or what arguments were passed to them.
- Stubs - stubs are like spies, but they replace the target function. You can use stubs to control a method's behaviour to force a code path (like throwing errors) or to prevent calls to external resources (like HTTP APIs).
- Mocks - mock is a fake method with a pre-programmed behavior and expectations.
Stubs are dummy and always return hard-coded value whereas Mocks are usually configurable and comes with some internal implementation (for testing purposes).
- E2E - testing of the whole system (simulating the end user)
- Integration - testing of the group of interconnected modules
- Unit - testing each module in isolated environment (using stubs and mocks for the outside world)
- In TDD, I don’t care much about the output. The only thing needed is to carry out the test in a particular way.
- TDD may lack the ability to specify the exact behavior, but you achieve higher quality with software code.
- In BDD, I don’t mind how you come up with the output, only that the output has to be correct under the GIVEN condition.
- In BDD you will come across a better specification since communication between the software developer and product owner is fast and easy.