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

Created on 10 Jun 2020  路  5Comments  路  Source: mochajs/mocha

Prerequisites

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

All 5 comments

I'll look at this

I have a fix and will release soon

Ref: #4328

Fixed in v8.0.1

That was fast. Confirmed, fixed. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Swivelgames picture Swivelgames  路  3Comments

smithamax picture smithamax  路  4Comments

eschwartz picture eschwartz  路  3Comments

niftylettuce picture niftylettuce  路  3Comments

danielserrao picture danielserrao  路  3Comments