yeoman / yeoman-test

Test utilities for Yeoman generators
MIT License
44 stars 17 forks source link

Bun support #242

Open suuunly opened 5 days ago

suuunly commented 5 days ago

Hey, I wanted to use the latest yeoman-test library, but when I run it I get the following error:

# Unhandled error between tests
-------------------------------
error: Cannot find package "node:test" from "/Users/my-path/generator-bun-app/node_modules/yeoman-test/dist/adapter.js"
-------------------------------

The project is written in Bun 1.1.24. Do you have any plans for supporting bun? Or perhaps you know of a clever solution around this issue, where I can add node:test to the package? 😁

Thank you, any help is much appreciated! ❤️

mshima commented 5 days ago

Have you followed node requirements? https://github.com/yeoman/yeoman-test/blob/19d6cbb093041194929855b6453f6411255edde1/package.json#L84

mshima commented 5 days ago

node:test is a built-in node module: https://nodejs.org/api/test.html#mockfnoriginal-implementation-options

mock.fn([original[, implementation]][, options])[#](https://nodejs.org/api/test.html#mockfnoriginal-implementation-options)

Added in: v19.1.0, v18.13.0
mshima commented 5 days ago

Ok it's not using node. Another runtime https://bun.sh.

node:test support status https://bun.sh/docs/runtime/nodejs-apis#node-test

mshima commented 5 days ago

See https://github.com/oven-sh/bun/issues/5090. I can drop node: prefix if https://www.npmjs.com/package/test works for you.

suuunly commented 2 days ago

Hey @mshima Thank you for the swift reply! ❤️

I tried installing the suggested default npm test library, which worked fine. I then tried to hop into the node_modules/yeoman-test, and removed the node: prefix on all the node:test references. Which then results in the following error:

error: Cannot find package "yeoman-environment" from "/Users/my-path/generator-bun-app/node_modules/yeoman-test/dist/default-environment.js"

So I think it may be a more integrated issue than just node:test. Which is fair, since you've not focused on Bun 😁

mshima commented 2 days ago

yeoman-environment is an optional dependency. You should install manually.