TheAlgorithms/JavaScript

[FEATURE]: Switch to Bun or Vitest for running tests

defaude opened this issue ยท 6 comments

Motivation

As you might've heard, Bun has become stable just a few weeks ago. In a nutshell, it's a drop-in replacement for "classic" Node.js that promises faster startup, overall better performance etc.

What do you guys think? Should we

  • brush up & clean up the tooling overall
  • switch the JS runtime to Bun
  • update GitHub actions accordingly
  • (optional) migrate from Jest to Bun (it comes with a Jest-compatible test runner, as well)

Please add your ideas, questions and suggestions here :)

Examples

No response

Possible workarounds

No response

Additional information

No response

Alternatively, we could also say we're sticking with "vanilla" Node.js but we'll update to Node 20 (and potentially update a ton of deps and clean up the codebase a bit).

I'm not opposed to switching to Bun, assuming everything continues working as before, esp. if it helps improve performance (this is more of a small-ish benefit, though, at least for me as a reviewer; it may be more useful for our contributors).

A small concern is that this might make the repo slightly harder to work with for newcomers (Node.js is more common, will typically be available in your package manager / there will be easy install guides, etc.)

I also can't judge the maturity of Bun.

Updating deps & the Node version is a chore which I don't think is necessary yet (but of course I wouldn't mind it). Updating Node also may come at slight contributor inconvenience again (e.g. if the newer Node version hasn't been packaged on their distro yet).

Thanks for your insights! ๐Ÿ™

I've been playing around a bit with Bun in this codebase and here are my two cents: We're not "really" using the runtime other than for executing the tests themselves and therefore might not even be benefiting from a switch to Bun at all.

We could just leave everything as-is and just run Jest with Bun instead of Node.js. In this case, there is no or just a negligible speedup. => I don't see the point in migrating just for the sake of migrating.

We could also try to migrate to using Bun's own test runner - that one is ridiculously fast. But since it's not fully supporting the API provided by Jest (at the moment), this would actually break a lot of our tests. => Absolute no-go.

I'd propose switching to vitest, instead! It's definitely more Jest-compatible and should speed up test execution quite substantially, too. If you want, I'd gladly provide a PR ๐Ÿ˜Ž

Especially thinking about keeping the repo to stay as newcomer-friendly as possible: Agreed that it's most likely more robust to just stick with Node / NPM and utilize awesome stuff like vitest, instead.

Regarding the version of node: Node 20 will be the "active LTS" release starting this October - see the releases page. Defining (i.e. expecting) Node 20 makes total sense. It should be easily available for everyone.

I'd propose switching to vitest, instead! It's definitely more Jest-compatible and should speed up test execution quite substantially, too. If you wand, I'd gladly provide a PR ๐Ÿ˜Ž

Sounds good!