2. Pre-test: Raise
your hand if…
•You do not have Node checked
out on your computer
•You do not have Node built
•Node isn't working on your
computer right now
•If so, `make -j4` now.
4. NO!* You!
•You will hit bugs.
•You are a Node programmer.
•You can fix those bugs.
•You can achieve immortality
in code.
*well, yes, those people. but ALSO you.
8. tests
•Node's tests are simple
JavaScript programs that
either throw, or don't.
•Not throwing = test pass
•Tests (mostly) go in
tests/simple/test-*.js
•No test = Rejected pull req
9. Running tests
•`make test` or `vcbuild test`
Runs simple tests, and jslint
•`make test-all`
`vcbuild test-all`
Runs ALL the tests,
even slow pummel tests
•./node test/simple/test-x.js
To run a single test
12. Good Test Output
•Should be almost nothing.
•I personally like doing
`console.log('ok')` at the
very end, just so I know it
ran fully.
•More than that is too much!
13. Good Test Speed
•Each test should take less
than 100ms to run in the
normal case.
•Rule of thumb:
If you can read the name
while `make test` runs, it's
taking too long.
14. Good Test Code
•Short and simple
•Entirely self-contained
•Do not use tests/fixtures/
unless ABSOLUTELY necessary
•assert something in
process.on('exit')
15. Always include
the test header
//
// copyright mumbo jumbo
//
var common = require('../common');
var assert = require('assert');
32. net.Server
•TCP server abstraction
•connection cb => gets a
connected net.Socket object
•call listen(cb) to bind to a
port/IP or fs socket path
•listen cb => actually
listening (async)
58. Of course…
•It's silly to add a
response.json() method to
node-core
•This is an example only, it
clearly belongs in userland
•"Real" bug fixes are usually
much trickier