test: use Node's test runner for significant speedup #617
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr:
node --test
instead ofbrittle
to speed up tests. Only affects the runner;brittle
is still imported in tests.We use Brittle for tests, which has two distinct pieces:
brittle
command)brittle
import)These pieces can be used independently. For example,
node /path/to/my-brittle-test.js
runs an individual file without using thebrittle
command; it only uses thebrittle
module. You can also runbrittle /path/to/file.js
, which might not import thebrittle
module.We eventually want to drop Brittle entirely. We can start with the easier part: dropping the test runner.
node --test
is typically used with thenode:test
module, but it doesn't have to be. From Node's docs:This replaces
npm run test:unit
andnpm run test:e2e
withnode --test
. In addition to being a step towards our eventual goal, it is also much faster (presumably because it runs concurrently). On my machine,test:unit
goes from about 51 seconds to about 12.5, andtest:e2e
went from ~2.3 minutes to about ~1.9. On CI,npm test
started at 2m24s and is now 1m48s.