Skip to content
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 opened this issue Apr 28, 2021 · 0 comments · May be fixed by #237
Open

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

samouri opened this issue Apr 28, 2021 · 0 comments · May be fixed by #237
Assignees

Comments

@samouri
Copy link

samouri commented Apr 28, 2021

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!

@samouri samouri changed the title Karma-mocha adapter swallows failures that occur after test complete adapter.js swallows failures that occur after test complete Apr 28, 2021
@jginsburgn jginsburgn assigned samouri and unassigned gjyalpha and jginsburgn Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants