bloat-free-testrunner for node.js
npx bft test.js test/foobar.js path/to/test/file.js
// test.js
const assert = require('assert').strict;
test('this a test case', () => {
assert.strictEqual(42, 42);
});
test('another test', async () => {
const expected = 'foobar';
const actual = await yourCodeUnderTest();
assert.strictEqual(actual, expected);
});
test('i do not like the built-in assert module', () => {
throw new Error('no problem; just thrown an execption and this testcase will fail');
});
watch mode - onchange
npx onchange -i -k '*.test.js' -- npx bft *.test.js
coverage - c8
npx c8 --all npx bft *.test.js
-
Can I use the module without messing up with
global
?- Yes! see example.test.js
-
Where are the
setup
andteardown
functions?- In the bloated testrunner ;-)
bft
encourages you to use AAA - Arrange Act Assert pattern.
- In the bloated testrunner ;-)
-
"If bloat-free, then color-free please"
NO_COLOR=1 npx bft test.js
is your friend.
balazs4 - https://twitter.com/balazs4
MIT