Closed vjpr closed 3 years ago
I think I found the issue. ava@4.0.0-alpha.2
has a check to see if its being run from the CLI - which I think might break Wallaby - unless you are already working around this somehow...
https://github.com/avajs/ava/blob/v4.0.0-alpha.2/lib/worker/base.js#L8-L20
// Check if the test is being run without AVA cli
if (!isRunningInChildProcess && !isRunningInThread) {
const chalk = require('chalk'); // Use default Chalk instance.
if (process.argv[1]) {
const fp = path.relative('.', process.argv[1]);
console.log();
console.error(`Test files must be run with the AVA CLI:\n\n ${chalk.grey.dim('$')} ${chalk.cyan('ava ' + fp)}\n`);
process.exit(1);
} else {
throw new Error('The ’ava’ module can only be imported in test files');
}
}
Wallaby Console
console.error: Test files must be run with the AVA CLI:
$ ava ../../../wallaby/server.js
~I think the issue might have been that I am setting runner
as a shell file:~
#!/bin/sh
node \
--no-warnings \
--experimental-loader=$pkgdir/node_modules/@live/esm-loader/index.js \
--experimental-specifier-resolution=node \
--experimental-import-meta-resolve \
--experimental-vm-modules \
--conditions=$CONDITIONS \
"$@"
The env.params.runner
is not the same as the args passed into the Node worker process. Maybe env.params.runner
are not simply appended to runner
as I first thought...
I think the problem is related to overriding the --experimental-loader
with anything. If I remove this, it works.
Ah, so I found it:
execArgv:
[ '--experimental-vm-modules',
'--experimental-specifier-resolution=node',
'--experimental-import-meta-resolve',
'--experimental-loader', 'file:///Users/Vaughan/Library/Application%20Support/JetBrains/IntelliJIdeaVaughan/system/wallaby/wallaby/runners/node/ava@1.0.0/hooks.mjs' ]
Wallaby uses a custom hook for ava.
Running ava
with esm
is described in our docs. Was it not working for you? If not, would you mind sharing your Wallaby configuration so we can double check that Wallaby is doing what it should?
I am working in a pnpm monorepo, and workspace dependencies need to be resolved manually, because node_modules
are not present in the projectCacheDir
(nor do I want to copy them there).
So I needed a custom loader for that.
I got it working by copying hooks.mjs
into my loader's getSource
.
I assume that this is related to https://github.com/wallabyjs/public/issues/2813? Do you still need help? If you have a sample, we'd love to be able to include it (or share the relevant information) for others.
Issue description or question
See: https://github.com/avajs/ava/issues/2850
I original opened the issue in Ava, but I think it might be more of a Wallaby issue.
Does Wallaby do anything custom in setting up the comms channel between itself and Ava workers?
When Wallaby run's ava:
However Ava doesn't expect it to be a main thread, so handle is never set.