TDD in Javascript and WebStorm
Why can't we just run all the unit tests out of an html page?
You can, but consider...
- Back-end Javascript such as Node ("headless" testing)
- All the different browsers and their versions
- Ability to run ONLY failing tests
- Additional analytics such as coverage, cyclomatic complexity and other specialized reports
- Managing continuous testing, and testing only current failures
So how do we manage all of these issues?
A: use a test runner
Karma (by the AngularJS team) has become the most widely accepted platform
Which test framework?
A: Jasmine still seems to be the favorite, but Mocha is catching up quickly
Jasmine has a lot of functionality and the most extensive examples but it forces you into a BDD paradigm, and is clunky when it comes to asynchronous support.
TDD to BDD mapping
TDD |
BDD |
Test Class/Script |
Spec |
Test Group (informal) |
describe() |
Test method |
it() |
assertXYZ(abc,def) |
expect(abc).toBeXYZ(def) |