oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.14k stars 2.68k forks source link

Support the `node:test` built-in API #5090

Open jbergstroem opened 1 year ago

jbergstroem commented 1 year ago

What is the problem this feature would solve?

As part of evaluating/migrating to bun from node, it is cumbersome to use both node:test and bun:test at the same time.

What is the feature you are proposing to solve the problem?

bun should support the node:test built-in API.

What alternatives have you considered?

Maintain a separate suite or use branching logic.

jbergstroem commented 1 year ago

Does it make sense to add a PR about it not being supported in the documentation?

tjx666 commented 7 months ago

My usage is to use one test code to test both bun and node compatibility. Why bun can recogonize the 'test' module?

❯ t

> fetch-github-trending@0.0.1 test
> bun test

bun test v1.0.25 (a8ff7be6)

test/index.test.ts:
error: Cannot find package "test" from "/Users/yutengjing/code/fetch-github-trending/test/index.test.ts"

 0 pass
 1 fail
Ran 1 tests across 1 files. [5.00ms]
image
arthurfiorette commented 5 months ago

Hey @jbergstroem do we have any solution/alias to this?

We are currently trying to run our test suite (written with node:test) using bun to ensure it works on both node.js and bun.js.

I'm not sure, but probably adding support for https://github.com/nodejs/node-core-test should be the aimed solution here.

node core test package in bun throws these two errors:

❯ bun test
bun test v1.0.30 (1424a196)

test/components.test.tsx:

[bun] Warning: async_hooks.executionAsyncId/triggerAsyncId are not implemented in Bun. It will return 0 every time.
[bun] Warning: async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.

 0 pass
 0 fail
Ran 0 tests across 1 files. [601.00ms]