Skip to content

Mocha silently skips tests when an async error is thrown #15658

@rsimha

Description

@rsimha

@jpettitt reported this while running the following test:

it('should require an id', () => {
const el = getUserNotification({
'data-show-if-href': 'https://www.ampproject.org/get/here',
'data-dismiss-href': 'https://www.ampproject.org/post/here',
'layout': 'nodisplay',
});
const impl = el.implementation_;
expect(impl.buildCallback.bind(impl)).to.throw(/should have an id/);
});

The error at the end of the test gets thrown asynchronously, by which time the test has completed. So Mocha makes it look like the test has passed, but the thrown error prevents it from running subsequent tests.

See mochajs/mocha#3223 and mochajs/mocha#3257 for more info on why this is a mocha problem.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions