Cookie Consent by Free Privacy Policy Generator 📌 Node Test Runner vs Bun Test Runner (with TypeScript and ESM)


✅ Node Test Runner vs Bun Test Runner (with TypeScript and ESM)


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

I've recently gotten the chance to play with both of these while looking for a long-term testing framework at my job.
I also considered Node-TAP, Vitest, Jest and Mocha, but none truly convinced me as much as these two for a multitude of reasons (annoying config, lack of ESM support, speed, etc), so I'll focus on them.

Node Test Runner

The good

Built-in. That's it, so simple, so nice. Plus it works with ESM too!

Use

It has everything you'd expect (describe/it, mock, test, beforeEach, etc...) and uses assert instead of the usual expect.

assert.equal(id.value, expectedId);

The bad

No TS support out-of-the-box. So much so, that you need to do a hacky workaround in your package.json scripts:

"test" "glob -c \"tsx --test --test-reporter spec \" \"./test/**/*.test.ts\""

You need both a loader (tsx or similar) and a way to tell it where your tests are (in this case, glob).

This snippet comes from the guide I made on setting up Node Test Runner for TypeScript, so check it out if you want more info!

Bun Test Runner

The good

It's fast. Like twice as fast as Node's runner, which was already faster than Jest and Vitest. It also is as easy to set up as Node's Test Runner, and includes TS support as well!

Use

It has a decent compatibility with both Jest and Vitest's APIs (you can track progress here so you can use it as almost a drop-in replacement for either.
Just as Node's, it has describe/it, mock, test and others, but with the expect syntax (which I find more readable). For example:

expect(id.value).toEqual(expectedId);

The bad

Iffy debugging support. It requires the VS Code extension if you use VS Code, and I'm not sure how well other IDEs are supported. It also requires installing Bun as a dependency in package.json if you still use npm/pnpm/yarn to pin the right version.

Verdict

If you already use Bun, or don't mind having to use additional tools for debugging, then Bun is definitely the choice to make. It's easier to use and faster, and has about the same functionality if not more than Node's.

If on the other hand you care about "native" experience, want the best CI installation times, or just want to use all-Node, then the good news is that Node's Test Runner is not far behind, and you won't feel like you're being left out for not using the most blazingly fast™ tool.

In any case, either one should be a good choice as they are seeing active development (Node just released version 22, and Bun announced v1.1 three weeks ago as of the time of writing) and aim to be easy-to-use, fast tools.

Hope this article was of use in helping you decide which one to go for, and don't forget to check all my other stuff for more posts like this one!

...

✅ Node Test Runner vs Bun Test Runner (with TypeScript and ESM)


📈 89.64 Punkte

✅ Vuln: HP ArcSight ESM and ArcSight ESM Express CVE-2017-14356 SQL Injection Vulnerability


📈 39.69 Punkte

✅ ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Apache Tomcat Version Information Disclosure


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Access Control erweiterte Rechte


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Information Disclosure


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Log File Directory Traversal


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Reflected Cross Site Scripting


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Reflected Cross Site Scripting


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 Redirect


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express bis 6.9.1c Patch 3/6.11.0 SQL Injection


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Log File directory traversal


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Reflected cross site scripting


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 information disclosure


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Apache Tomcat Version information disclosure


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Access Control privilege escalation


📈 38.16 Punkte

✅ ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Access Control privilege escalation


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 sql injection


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Open Redirect


📈 38.16 Punkte

✅ HP ArcSight ESM/ArcSight ESM Express up to 6.9.1c Patch 3/6.11.0 Reflected cross site scripting


📈 38.16 Punkte

✅ The ultimate Node Test Runner + TypeScript + ENV variables guide


📈 33.47 Punkte

✅ Bun: An All-in-One Toolkit for JavaScript and TypeScript Apps


📈 32.19 Punkte

✅ Introducing Bun 1.1.1 - Your ultimate JavaScript and TypeScript toolkit


📈 32.19 Punkte

✅ Migrate a 60k LOC TypeScript (NodeJS) repo to ESM and testing become 4x faster (1/2)


📈 31.06 Punkte

✅ How to publish an npm package for ESM and CommonJS with TypeScript


📈 31.06 Punkte

✅ Dissecting the hell that is Jest setup with ESM and Typescript


📈 31.06 Punkte

✅ How to publish an npm package for ESM and CommonJS with TypeScript


📈 31.06 Punkte

✅ Unlock the Power of Node.js Testing with the New Node Test Runner Feature


📈 30.66 Punkte

✅ heise+ | Bun: Laufzeitumgebung für JavaScript und TypeScript


📈 30.66 Punkte

✅ Writing a simple RESTful TypeScript web service with Bun.js


📈 30.66 Punkte

✅ Bun - The One Tool for All Your JavaScript/Typescript Project's Needs?


📈 30.66 Punkte

✅ Publish pure ESM npm package written in TypeScript to JSR


📈 29.53 Punkte











matomo

Datei nicht gefunden!