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

Watch fails on typescript after 2nd code recompile #4986

Closed
4 tasks done
nebosite opened this issue May 30, 2023 · 2 comments
Closed
4 tasks done

Watch fails on typescript after 2nd code recompile #4986

nebosite opened this issue May 30, 2023 · 2 comments
Assignees
Labels
invalid not something we need to work on, such as a non-reproducing issue or an external root cause

Comments

@nebosite
Copy link

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • 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

  1. 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)
  2. run npm run testwatch (Result: there will be a passing test and a 'waiting for changes...' message
  3. Edit the tested function to return "hi1" and save.
  4. Edit the tested function again to return "hi2" and save.
  5. 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.

Reproduces how often:

100%

Versions

"chai": "^4.3.4",
"mocha": "^10.2.0",
"ts-node": "^10.9.1",
"typescript": "^3.9.9"

(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

@JoshuaKGoldberg
Copy link
Member

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.

Here's a repro: https://github.com/JoshuaKGoldberg/repros/tree/mocha-typescript-watch-mode

@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jan 18, 2024
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Jan 19, 2024

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!

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2024
@JoshuaKGoldberg JoshuaKGoldberg added invalid not something we need to work on, such as a non-reproducing issue or an external root cause and removed unconfirmed-bug labels Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid not something we need to work on, such as a non-reproducing issue or an external root cause
Projects
None yet
Development

No branches or pull requests

2 participants