lukeed / uvu

uvu is an extremely fast and lightweight test runner for Node.js and the browser
MIT License
2.97k stars 100 forks source link

SvelteKit is incompatible with uvu #173

Closed Xevinaly closed 2 years ago

Xevinaly commented 2 years ago

SvelteKit (and any other node project which uses esm as the default using the line "type: module") is incompatible with uvu at the moment since uvu will try to load as an esm file. This causes arguments passed in using -r (JSDOM or any code to register .svelte files) to break uvu, giving the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\xevin\OneDrive\Documents\Projects\uvu-issue-replication\tests\setup\register.js require() of ES modules is not supported.

Reproduction can be found here: https://gitlab.com/xevinaly/uvu-issue-replication

Valexr commented 2 years ago

You can use tsm instead esm my config with preprocessing here https://github.com/tilde-lab/svelte-spectre/tree/master/tests

Xevinaly commented 2 years ago

Unfortunately thats only a partial solution as it would require me to switch my project over to using Typescript.

Valexr commented 2 years ago

My project have TS πŸ€·πŸ»β€β™‚οΈ

Valexr commented 2 years ago

Unfortunately thats only a partial solution as it would require me to switch my project over to using Typescript.

It’s not necessary - tsm working with js to πŸ‘ŒπŸ»

lukeed commented 2 years ago

Correct – you don't need to use TypeScript in order for tsm to be useful. It's a great ESM <-> CJS tool on its own.

I'll be putting together an example of using uvu with SvelteKit projects in the near future. Closing as duplicate of #137