Skip to content

mocha 8.0.0 --watch throws "Mocha instance is already disposed" on code change #4327

Closed
@jeremychone

Description

@jeremychone

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 node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

Mocha 8.0.0 does not seems to breaks when using --watch with message Mocha instance is already disposed

Steps to Reproduce

With Mocha 0.7.2 running the command below run the tests once and then on code change, execute again (as epected)

./node_modules/.bin/mocha -p ./test/tsconfig.json ./test/spec/*.spec.ts --watch --watch-files './test/**/*.ts','./src/**/*.ts'

With Mocha 8.0.0, run exact same command, on exact same code, will run the tests once correctly, but doing a code change will throw the following error in the terminal.

(node:8867) UnhandledPromiseRejectionWarning: Error: Mocha instance is already disposed, cannot start a new test run. Please create a new mocha instance. Be sure to set disable `cleanReferencesAfterRun` when you want to reuse the same mocha instance for multiple test runs.
....

Versions

  • mac os latest catalina, zsh, TypeScript 39.5

Addtional information

.mocharc.yaml

require: ts-node/register

Activity

boneskull

boneskull commented on Jun 10, 2020

@boneskull
Member

I'll look at this

boneskull

boneskull commented on Jun 10, 2020

@boneskull
Member

I have a fix and will release soon

added 2 commits that reference this issue on Jun 10, 2020
9f516d2
5d473c1
boneskull

boneskull commented on Jun 10, 2020

@boneskull
Member

Ref: #4328

boneskull

boneskull commented on Jun 10, 2020

@boneskull
Member

Fixed in v8.0.1

jeremychone

jeremychone commented on Jun 10, 2020

@jeremychone
Author

That was fast. Confirmed, fixed. Thanks.

added a commit that references this issue on Feb 28, 2024
66ce143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type: buga defect, confirmed by a maintainer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @jeremychone@boneskull@nicojs

      Issue actions

        mocha 8.0.0 --watch throws "Mocha instance is already disposed" on code change · Issue #4327 · mochajs/mocha