Skip to content

Commit

Permalink
Merge pull request #1 from hinhengchan/fix/diff-message
Browse files Browse the repository at this point in the history
fix mocha-parallel#284: missing diff message from assertion failure
  • Loading branch information
hinhengchan authored Mar 25, 2020
2 parents 2babcd3 + 1f876f3 commit 2b4e164
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ export interface Suite extends MochaSuite, MochaParallelTestsRunnerObject {
}

export interface Test extends MochaTest, MochaParallelTestsRunnerObject {}

export interface FailedTestError extends Error {
showDiff?: boolean;
actual: string;
expected: string;
}
7 changes: 5 additions & 2 deletions src/subprocess/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IRunner } from 'mocha';
import CircularJSON from 'circular-json';

import { Test, Suite, Hook } from '../mocha';
import { Test, Suite, Hook, FailedTestError } from '../mocha';
import { getMessageId } from './util';
import { RUNNABLE_MESSAGE_CHANNEL_PROP, SUBPROCESS_RETRIED_SUITE_ID } from '../config';
import MessageChannel from './message-channel';
Expand Down Expand Up @@ -119,12 +119,15 @@ export const getReporterFactory: ReporterFactory = (channel, debugSubprocess) =>
});
}

private onRunnerFail = (test: Test, err: Error) => {
private onRunnerFail = (test: Test, err: FailedTestError) => {
this.notifyParent('fail', {
err: {
message: err.message,
name: err.name,
stack: err.stack,
showDiff: err.showDiff,
actual: err.actual,
expected: err.expected
},
id: test[RUNNABLE_MESSAGE_CHANNEL_PROP],
});
Expand Down

0 comments on commit 2b4e164

Please sign in to comment.