Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

adapter.js swallows failures that occur after test complete #236

Open
@samouri

Description

summary
As rarely used as it is, Mocha currently supports marking a test as failed after it has already completed.

As an example, here is a unit test from mocha's own suite (src):

describe('fail the test from the "after each" hook', function() { 
   it('should fail', function() { 
     // but not here 
   }); 
  
   afterEach(function() { 
     this.test.error(new Error('failing from after each')); 
   }); 
 }); 

This code branch needs to call karma.report in the case of test.type === 'test':

karma-mocha/src/adapter.js

Lines 164 to 171 in 537ef7b

if (test.type === 'hook') {
test.$errors = isDebugPage ? [error] : [simpleError]
test.$assertionErrors = assertionError ? [assertionError] : []
reportTestResult(tc, test)
} else {
test.$errors.push(isDebugPage ? error : simpleError)
if (assertionError) test.$assertionErrors.push(assertionError)
}

Is this something maintainers would be willing to accept a PR on?

Thanks!

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions