AssertionError - output is noisy. How do I show only Assertion

145 Views Asked by At

When running the Intern Unit test example from Getting Started, when I changed the Hello unit script and ran it so it assert, it appears to be showing more detail (noisy) than what I need. Is this output correct? Is there a way to only show the AssertionError line and maybe the file / line where this assertion occurred?

unit_hello.js:

define([
    'intern!object',
    'intern/chai!assert',
    'app/hello'
], function (registerSuite, assert, hello) {
registerSuite({
    name: 'hello',

    greet: function () {
        assert.strictEqual(hello.greet('Name'), 'Hello, Name!',
            'hello.greet should return a greeting for the person name in the first argument');
        assert.strictEqual(hello.greet(), 'Hello, World!',
            'hello.greet with no arguments should return a greeting to "world"');
        }
    });
});

Output:

user@pcname:~/intern_example$ ./node_modules/.bin/intern-client config=tests/intern_unit
FAIL: main - hello - greet (1ms)
AssertionError: hello.greet with no arguments should return a greeting to "world":  expected 'Hello, world!' to equal 'Hello, World!'
  at Function.assert.strictEqual  <node_modules/intern/node_modules/chai/chai.js:2487:32>
  at Test.registerSuite.greet [as test]  <tests/unit/unit_hello.js:13:20>
  at Test.run  <node_modules/intern/lib/Test.js:169:19>
  at <node_modules/intern/lib/Suite.js:237:13>
  at signalListener  <node_modules/intern/node_modules/dojo/Deferred.js:37:21>
  at Promise.then.promise.then  <node_modules/intern/node_modules/dojo/Deferred.js:258:5>
  at runTest  <node_modules/intern/lib/Suite.js:236:46>
  at <node_modules/intern/lib/Suite.js:249:7>
  at process._tickCallback  <node.js:419:13>
1/1 tests failed
1/1 tests failed
2

There are 2 best solutions below

0
On BEST ANSWER

You can write and load your own custom reporter to output whatever information you want or don’t want. The standard reporters will always provide a full stack trace.

0
On

There is filterErrorStack configuration option that tells Intern to clean up error stack traces by removing non-application code.

It is there from version 3.4 (released 18.11.2016).