mocha icon indicating copy to clipboard operation
mocha copied to clipboard

🐛 Bug: Tests default to full stacktrace on Windows, rather than shortened

Open Vannevelj opened this issue 9 years ago • 8 comments

I'm using mocha 2.3.3 which should have the shortened stacktraces by default yet I am still receiving them in full:

2) conditionBuilder greater_than_condition returns false with smaller input:
 AssertionError: expected undefined to equal false
  at evaluateCondition (C:\Users\jeroen\Documents\Github\MyPackage\tests\conditionBuilderTests.js:44:11)
  at Context.<anonymous> (C:\Users\jeroen\Documents\Github\MyPackage\tests\conditionBuilderTests.js:31:4)
  at callFn (C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runnable.js:286:21)
  at Test.Runnable.run (C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runnable.js:279:7)
  at Runner.runTest (C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:421:10)
  at C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:528:12
  at next (C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:341:14)
  at C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:351:7
  at next(C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:283:14)
  at Immediate._onImmediate(C:\Users\jeroen\Documents\Github\MyPackage\node_modules\mocha\lib\runner.js:319:5)

npm show mocha version returns 2.3.3 and I execute my tests using mocha myTestFile (so there is no full-trace flag specified).

Does anyone else notice this? Did I make a mistake anywhere? I would show a test but I don't think its contents are relevant.

Vannevelj avatar Nov 11 '15 12:11 Vannevelj

:+1: also getting this

$ npm test

> [email protected] test c:\projects\project
> mocha test/index.js



  foo
    1) should not be equal to bar


  0 passing (32ms)
  1 failing

  1) foo should not be equal to bar:

      AssertionError: 'foo' == 'bar'
      + expected - actual

      -foo
      +bar

      at Context.<anonymous> (c:\projects\project\test\index.js:6:12)
      at callFn (c:\projects\project\node_modules\mocha\lib\runnable.js:286:21)
      at Test.Runnable.run (c:\projects\project\node_modules\mocha\lib\runnable.js:279:7)
      at Runner.runTest (c:\projects\project\node_modules\mocha\lib\runner.js:421:10)
      at c:\projects\project\node_modules\mocha\lib\runner.js:528:12
      at next (c:\projects\project\node_modules\mocha\lib\runner.js:341:14)
      at c:\projects\project\node_modules\mocha\lib\runner.js:351:7
      at next (c:\projects\project\node_modules\mocha\lib\runner.js:283:14)
      at Immediate._onImmediate (c:\projects\project\node_modules\mocha\lib\runner.js:319:5)

spec


'use strict';
const assert = require('assert');
describe('foo', function() {
  it('should not be equal to bar', function() {
    assert.equal('foo', 'bar');
  });
});

punmechanic avatar Nov 11 '15 12:11 punmechanic

I'm also getting long stacktraces using version 2.3.4, running my tests with mocha from the cli.

Stacktraces are up to ~45 lines long.

ewendel avatar Dec 29 '15 12:12 ewendel

Looks like this might be specific to windows? If you clone this repo and run make test-all, do tests fail?

Updating var slash to be path.sep when is.node is true should hopefully fix it.

danielstjules avatar Dec 29 '15 15:12 danielstjules

I'm on Ubuntu 14.04, all tests passing with make test-all

ewendel avatar Dec 29 '15 16:12 ewendel

Can you post an example stack trace? The stack traces are a bit longer, as they no longer hide frames from your dependencies. But they still try to hide those from mocha.

danielstjules avatar Dec 29 '15 16:12 danielstjules

Here are two:

Long stack trace: https://gist.github.com/ewendel/eb4958034cfb945efcd0 Shorter but still long: https://gist.github.com/ewendel/317e12165be61c65b6b6

The long one is ridiculously long and caused by Babel when there's a syntax error present (added import in a function). The one is more normal but seems to have more than one Mocha-related line

ewendel avatar Dec 29 '15 16:12 ewendel

I am a bot that watches issues for inactivity. This issue hasn't had any recent activity, and I'm labeling it stale. In 14 days, if there are no further comments or activity, I will close this issue. Thanks for contributing to Mocha!

stale[bot] avatar Oct 17 '17 04:10 stale[bot]

cc @danielstjules was this ever fixed? I haven't used Mocha in a long while

punmechanic avatar Oct 17 '17 15:10 punmechanic