Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ava fails to run in watch mode via CLI #3285

Closed
rglover opened this issue Jan 5, 2024 · 2 comments · Fixed by #3287
Closed

Ava fails to run in watch mode via CLI #3285

rglover opened this issue Jan 5, 2024 · 2 comments · Fixed by #3287
Labels
bug current functionality does not work as desired

Comments

@rglover
Copy link

rglover commented Jan 5, 2024

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"
  }
});
@rglover
Copy link
Author

rglover commented Jan 8, 2024

Appears to have been resolved. Didn't change any of the code above so I'm guessing it was due to some of my test cases failing. Running fine w/ [email protected] against Node v16, v20, and v21.

@rglover rglover closed this as completed Jan 8, 2024
@novemberborn novemberborn reopened this Jan 11, 2024
novemberborn added a commit that referenced this issue Jan 11, 2024
Don't emit the 'touched-files' event, since the watcher assumes that comes with a files value.

Fixes #3285
@novemberborn
Copy link
Member

I'm guessing it was due to some of my test cases failing

Yes, I found a code path where this may occur.

@novemberborn novemberborn added bug current functionality does not work as desired and removed needs triage labels Jan 11, 2024
novemberborn added a commit that referenced this issue Jan 11, 2024
Don't emit the 'touched-files' event, since the watcher assumes that comes with a files value.

Fixes #3285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants