tl;dr: node --test instead of brittle to speed up tests. Only affects the runner; brittle is still imported in tests.
We use Brittle for tests, which has two distinct pieces:
The runner (the brittle command)
The module (the brittle import)
These pieces can be used independently. For example, node /path/to/my-brittle-test.js runs an individual file without using the brittle command; it only uses the brittle module. You can also run brittle /path/to/file.js, which might not import the brittle 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 the node:test module, but it doesn't have to be. From Node's docs:
Test files must be executable by Node.js, but are not required to use the node:test module internally.
This replaces npm run test:unit and npm run test:e2e with node --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, and test:e2e went from ~2.3 minutes to about ~1.9. On CI, npm teststarted at 2m24s and is now 1m48s.
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.