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

No way to watch .ts tests #1669

Closed
BryanCrotaz opened this issue Feb 2, 2022 · 1 comment
Closed

No way to watch .ts tests #1669

BryanCrotaz opened this issue Feb 2, 2022 · 1 comment

Comments

@BryanCrotaz
Copy link
Contributor

"scripts": {
    "build": "tsc src/index.ts",
    "dev": "tsc src/index.ts --watch",
    "test": "qunit --require ts-node/register --watch 'test/**/*-test.ts'"
  }

Easy to run typescript tests, and pretty well documented. However --watch only reruns tests when .js files change. It ignores .tsfiles.

Suggestion: watch should trigger on both ts and js files.

@Krinkle
Copy link
Member

Krinkle commented Feb 2, 2022

Thanks, I would expect that to work as-is indeed.

The code for this is in src/cli/run.js as called from bin/qunit. We currently evaluate the glob pattern during the runs (initial and re-run from watch), which means that new files matching the pattern are naturally picked up. The watcher subscribes to the working directory as a whole. The watcher does not limit itself to the glob pattern, as we want to react to changed source files as well. It ignores changes within node_modules and to non-JS files.

One way to handle this could be to remember the files list from the last run, and if the watcher tells us about a changed file in that list, always start a re-run. The downside would be that this doesn't cover .ts source files, only test files.

Another way could be to inspect require.extensions keys and take those file extensions into consideration. This would be .js and .json by default, and ts-node will have added .ts to this.

Patch welcome. I might also give it a go myself during the next release in ~12 days.

Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
Change `run.watch()` to also apply the `--require` file, so that we
can observe any changes to `require.extensions`.

Fixes #1669.
@Krinkle Krinkle self-assigned this Feb 15, 2022
Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
Change `run.watch()` to also apply the `--require` file, so that we
can observe any changes to `require.extensions`.

Fixes #1669.
Krinkle added a commit that referenced this issue Feb 15, 2022
And add tests for verifying which files are and aren't reacted to,
including coverage for the existing ignoring of events from
"node_modules".

This is prep for #1669.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants