-
Notifications
You must be signed in to change notification settings - Fork 781
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
Support ESM when watch mode reruns files #1693
Comments
@adamfuhrer Which Node.js version and OS do you use? (e.g. Node.js 14 on Debian Linux). This appears to work for me with QUnit 2.19, so there's something a bit more subtle going on than the watch mode not working at all on subsequent runs. This is also covered by our CI jobs on Windows/Mac/Linux and on multiple Node versions. Node.js 17 on macOS 10.15 (
Node.js 14 on Debian Linux (
|
Appreciate the help. I'm on the LTS of Node 16.5.1. Also tried upgrading to the latest version of Node 18.3, and the issue still occurs unfortunately. I'm running macOS 12.3, so maybe that's where the issue is occuring To give some more context I'm in a fresh project with qunit as the only devDependency and no plugins or config file overrides |
@adamfuhrer Would you mind publishing your directory as a Git repo, a Gist, or attach as a ZIP file to a comment? I don't make a habit of asking this, but I'm unable to reproduce it on the same Node and QUnit version and would like to rule out "everything else", before I suspect the macOS version difference as making an observable difference in how Node.js behaves. Feel free to leave out |
Great, thanks so much! Attached the repo as a zip file here - core.zip |
@adamfuhrer I've reproduced the issue and narrowed it down to the cause that It works fine when you project uses Node.js' default CJS/require mode, as the QUnit CLI clears Node.js' internal require cache between runs. However, Node.js does not yet offer a way for test runners to clear the ES6 module imports cache. It looks like our friends at Mocha have run into the same limitation over at mochajs/mocha#4374. |
Really appreciate the follow up, and looking into this! Good to know that there's a workaround available. |
Eleventy has also run into the same issue. They worked around it by appending a random query string to the imported path. However, that still leaves the bug where any indirectly imported files remain re-used from the cache which means the watcher picks up changes in test files but not e.g. in your project source code. https://www.zachleat.com/web/eleventy-v3-esm/ (from slide 67). I think for QUnit 3.0, what I'll do is switch the QUnit CLI watch mode to spawn a child process and run the tests there, and then we can re-do that cleanly on each run, possibly spawning the "next" process eagerly after the last test (instead of before the first test) for faster response times during re-runs. |
Tell us about your runtime:
What are you trying to do?
Code that reproduces the problem:
Running
qunit -w
. On first run it successfully outputs the results of the tests, upon making a change to the test file, the error occurs:What did you expect to happen?
Test should just re-run. Any help would be appreciated!
The text was updated successfully, but these errors were encountered: