Closed fregante closed 1 year ago
The infrastructure we use for @ava/babel
and @ava/typescript
could work for this.
How would you select a test file from inside the bundle though?
If you precompile AVA can load ESM test files though. https://github.com/avajs/ava/issues/2347#issuecomment-698499005 shows how you could do it on the fly with ts-node
as well (I've been meaning to get that added to the docs).
FWIW in my TypeScript projects, running a separate tsc
in watch mode works well enough with AVA's watch mode and @ava/typescript
.
How would you select a test file from inside the bundle though?
I never tried. I suppose if the bundle is set up to have multiple outputs AVA would still see each test file.
#2347 (comment) shows how you could do it on the fly with
ts-node
as well
I'll try replacing https://github.com/sindresorhus/refined-github/pull/3206 with that solution perhaps, but with all those experimental flags it looks like a time bomb :(
in my TypeScript projects, running a separate
tsc
in watch mode
Can you point me to one such example? I'd like to see how you're configuring the built folder
How would you select a test file from inside the bundle though?
I never tried. I suppose if the bundle is set up to have multiple outputs AVA would still see each test file.
Test file selection is driven by the file system. What the TypeScript provider does is provide a way to map that to a different file at runtime. Presumably we could select a bundle entrypoint or something like that.
with all those experimental flags it looks like a time bomb :(
I think from AVA's side it'll be OK — you're really dependent on the behavior in Node.js.
in my TypeScript projects, running a separate
tsc
in watch modeCan you point me to one such example? I'd like to see how you're configuring the built folder
Have a look at https://github.com/avajs/cooperate.
Closing because those issues have since been resolved (https://github.com/refined-github/refined-github/pull/4002 and https://github.com/vadimdemedes/dom-chef/pull/86) and I started using Vitest where I want to avoid ESM issues
Recently I found myself having to bundle the tests to overcome all the hurdles caused by combinations of AVA, TypeScript and
type: "module"
(https://github.com/vadimdemedes/dom-chef/pull/68 and https://github.com/sindresorhus/refined-github/pull/3206), so having AVA support some kind of build step might be helpful.Advantages over
rollup && ava
ava
without having to run an npm script firstava --watch
would trigger the build as wellAdditionally, it could automatically handle the creation of a temporary build folder
Additional advantages