You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.
Description
With a simple typescript project, mocha in watch mode works correctly at first, but after the second source code change detection, it loses compiled information.
Steps to Reproduce
Create a simple typescript project with a static class that exposes a single function to return a string and a test for that function. (.zip attached)
run npm run testwatch (Result: there will be a passing test and a 'waiting for changes...' message
Edit the tested function to return "hi1" and save.
Edit the tested function again to return "hi2" and save.
Edit the tested function again to return "hi3" and save.
Expected behavior:
Starting with step 3, should see a normal test failure after each edit and save.
Actual behavior: [What actually happens]
After first edit: Normal test failure
After second edit: Fails with: TypeError: Cannot read properties of undefined (reading 'getMessage')
After third edit: Compile failure: src/FooClass.spec.ts:2:26 - error TS2306: File 'src/FooClass.ts' is not a module.
I don't reproduce this issue locally on macOS Ventura 13.2 with Node 16.14.2 or 20.11.0. Maybe it's a transient issue in a nested dependency? Maybe it's Windows-specific?
I'm charging an old Surface laptop to try on Windows 11 😄 . Will come back to this soon.
Aside: in general, it's not great practice to upload a .zip. Downloading and extracting arbitrary files from the internet is kind of scary for us maintainers 😄. I'd appreciate an isolated GitHub repository, Gist, Stackblitz, or other more transparent environment next time.
Ok, yes, this doesn't reproduce for me on Windows 11 in stock cmd either. That, coupled with the lack of other reports on this area makes me suspect it was a transient issue in some other dependency. Closing as non-actionable.
Please do post back if it's still happening for you & you can provide an isolated reproduction with it. We'd be happy to take a look. Cheers!
Prerequisites
faq
labelnode_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
With a simple typescript project, mocha in watch mode works correctly at first, but after the second source code change detection, it loses compiled information.
Steps to Reproduce
npm run testwatch
(Result: there will be a passing test and a 'waiting for changes...' messageExpected behavior:
Starting with step 3, should see a normal test failure after each edit and save.
Actual behavior: [What actually happens]
After first edit: Normal test failure
After second edit: Fails with: TypeError: Cannot read properties of undefined (reading 'getMessage')
After third edit: Compile failure: src/FooClass.spec.ts:2:26 - error TS2306: File 'src/FooClass.ts' is not a module.
Reproduces how often:
100%
Versions
(I have also tried with earlier versions of mocha(8) and ts-node(9))
Node: 16.14.2
OS: Windows 11, 64 bit
mochaWatchFailure.zip
The text was updated successfully, but these errors were encountered: