JoshuaKGoldberg / console-fail-test

Gently fails test runs if the console was used during them. 📢
MIT License
15 stars 6 forks source link

🐛 Bug: "ReferenceError: require is not defined in ES module scope" with setup script #597

Closed JoshuaKGoldberg closed 1 month ago

JoshuaKGoldberg commented 1 month ago

Bug Report Checklist

Expected

Referencing console-fail-test/setup as a file to run in, say, a Vitest setupFiles should work.

Actual

From https://github.com/FarazPatankar/fantasy-premier-league-api/actions/runs/9937165801/job/27446897365:

⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/greet.test.ts [ src/greet.test.ts ]
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/fantasy-premier-league-api/fantasy-premier-league-api/node_modules/.pnpm/console-fail-test@0.4.2/node_modules/console-fail-test/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
 ❯ node_modules/.pnpm/console-fail-test@0.4.2/node_modules/console-fail-test/setup.js:1:1

Additional Info

Reported by @FarazPatankar. Thanks for mentioning!

Co-authored-by: @FarazPatankar

github-actions[bot] commented 1 month ago

:tada: This is included in version v0.4.3 :tada:

The release is available on:

Cheers! 📦🚀

JoshuaKGoldberg commented 5 days ago

@all-contributors please add @farazpatankar for bug.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action. Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed. ...and of course, thank you for contributing! 💙

allcontributors[bot] commented 5 days ago

@JoshuaKGoldberg

I've put up a pull request to add @farazpatankar! :tada:

I couldn't determine any contributions to add, did you specify any contributions? Please make sure to use valid contribution names.