Closed
Description
Please provide details about:
- What you're trying to do
Run ava with the --watch
flag via the CLI. I'm using child_process.exec()
to trigger the CLI. Tested against the latest 6.0.1 release and 5.3.1 running on Node v21, v20, v18, and v16. Tests run fine in both standalone (no watch) mode and watch (only the initial run).
- What happened
Ava runs tests, but exits abruptly due to error about evt.files
being undefined in the watcher:
TypeError: Cannot read properties of undefined (reading 'changedFiles')
at file:///Users/rglover/projects/cheatcode/joystick-1.0/blah/node_modules/ava/lib/watcher.js:91:35
at file:///Users/rglover/projects/cheatcode/joystick-1.0/blah/node_modules/emittery/index.js:365:13
at Array.map (<anonymous>)
at RunStatus.emit (file:///Users/rglover/projects/cheatcode/joystick-1.0/blah/node_modules/emittery/index.js:363:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
- What you expected to happen
Tests run and then watch mode waits for changes.
// ava test config (ava_config.js)
const ava_config = {
files: [`tests/**/*.test.js`],
concurrency: 1,
cache: false,
};
export default ava_config;
// call to run CLI via child_process
const ava_path = `${process.cwd()}/node_modules/.bin/ava`;
child_process.exec(`${ava_path} --config ${run_tests_options?.__dirname}/ava_config.js ${run_tests_options?.watch ? '--watch' : ''}`, {
stdio: 'inherit',
env: {
...(process.env),
databases: process.databases,
FORCE_COLOR: "1"
}
});