Search code examples
javascriptdebuggingintern

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


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

Solution

  • 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.