mocha-parallel / mocha-parallel-tests

Parallel test runner for mocha tests. Looking for maintainer.
MIT License
199 stars 45 forks source link

Fix not showing actual/expected #293

Closed thespecial closed 4 years ago

thespecial commented 4 years ago

This PR fixes issue https://github.com/mocha-parallel/mocha-parallel-tests/issues/215

data.err was missing actual/expected image

where test.err wasn't image

Nested describes were tested as well.

When tests throw an exception (new Error(..)) then: testErrors is empty:

{}

And data.err is not:

{ message: 'some error',
  name: 'Error',
  stack:
   'Error: some error\n    at Context.<anonymous> (test/parallel-order/tests/parallel2.js:9:14)' }

Then when tests assert some result using nodejs assert lib we get:

testErrors:

{ generatedMessage: true,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: 'false',
  expected: 'true',
  operator: '==' }

data.err

{ message:
   'The expression evaluated to a falsy value:\n\n  assert(false)\n',
  name: 'AssertionError [ERR_ASSERTION]',
  stack:
   'AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:\n\n  assert(false)\n\n    at Context.<anonymous> (test/parallel-order/tests/parallel2.js:10:9)' }

And when using chai assertion lib:

testErrors

{ name: 'AssertionError',
  message: 'expected false to deeply equal true',
  showDiff: true,
  actual: 'false',
  expected: 'true',
  stack:
   'AssertionError: expected false to deeply equal true\n    at Context.<anonymous> (test/parallel-order/tests/parallel2.js:11:26)' }

data.err

{ message: 'expected false to deeply equal true',
  name: 'AssertionError',
  stack:
   'AssertionError: expected false to deeply equal true\n    at Context.<anonymous> (test/parallel-order/tests/parallel2.js:11:26)' }