DEV Community 👩‍💻👨‍💻

Adam Crockett
Adam Crockett

Posted on

✅ node.js Test Framework now in core modules


Good gravy! Node has a test framework, Now what does that actually mean?

You download Jest and test right? well what if you could just

import assert from 'assert';
import test from 'node:test';

test('a description', () => {
  assert.strictEqual(1, 1);

Enter fullscreen mode Exit fullscreen mode


(node:27143) ExperimentalWarning: The test runner is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
TAP version 13
ok 1 - a
  duration_ms: 0.000279472
# tests 1
# pass 1
# fail 0
# skipped 0
# todo 0
# duration_ms 0.050426448
Enter fullscreen mode Exit fullscreen mode

Agh, a reporter only a mother could love!


Thats exactly how Rust handles its tests, there is no framework and usually all tests in the same file as the source which is actually really nice.

What does it mean?

Node.js is shooting for you to forget Jest, will you? maybe one day, now? no!

But it's a step in the right direction standardising testing is a very good idea.

Latest comments (0)

"I made 10x faster JSON.stringify() functions, even type safe"

☝️ Must read for JS devs