Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

eps1lon/repro-mocha-root-hook-throw

Repository files navigation

WARNING This bug is fixed as of mocha@^8.1.0. The latest commit on master works as expected since it's using mocha@8.1.0.

Reproduction

$ yarn install
$ yarn test:root-hooks --watch # passes unexpectedly
$ yarn test:local-hooks --watch # fails as expected

Explanation

A thrown error in afterEach behaves differently in watchmode if that hook was a root hook compared to "normal" hooks.

In a single run both yarn test:root-hooks and yarn test:local-hooks will bail out after the first test because afterEach threw. In watchmode yarn test:root-hooks --watch will pass every test and not log any error while yarn test:local-hooks --watch will bail on the first error just like it did in a single run

Motivation

During the test we spy on console.error calls and want to throw if there were any. Throwing directly in that call is not viable with React in JSDOM since the callstack will be unusable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published