Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Duplicate test fail messages for multiline strings #40

Closed
lucassus opened this issue Aug 1, 2014 · 2 comments · Fixed by #46
Closed

Duplicate test fail messages for multiline strings #40

lucassus opened this issue Aug 1, 2014 · 2 comments · Fixed by #46

Comments

@lucassus
Copy link
Contributor

lucassus commented Aug 1, 2014

When the assertion raises message with multiline strings in the stacktrace this message is duplicated.

For instance consider the following code snippet:

  describe('an exmaple', function() {

    it('throws', function() {
      // works fine
      throw new Error('foo');
    });

    it('throws', function() {
      // message will be duplicated
      throw new Error('foo\nbar');
    });

  });

for the first example I have nice error message:

PhantomJS 1.9.7 (Linux) Module chaiMatchers karma-mocha blows FAILED
        Error: foo
            at /home/lucassus/Projects/OpenSource/glossary/test/client/spec/chaiMatchersSpec.js:73
            at callFn (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4338)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4331
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4728
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4819
            at next (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4653)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4663
            at next (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4601)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4630
            at timeslice (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:5763)

but when I'm trying to ouptup multiline message I get:

PhantomJS 1.9.7 (Linux) Module chaiMatchers karma-mocha blows FAILED
        foo
        bar
        Error: foo
        bar
            at /home/lucassus/Projects/OpenSource/glossary/test/client/spec/chaiMatchersSpec.js:77
            at callFn (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4338)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4331
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4728
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4819
            at next (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4653)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4663
            at next (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4601)
            at /home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:4630
            at timeslice (/home/lucassus/Projects/OpenSource/glossary/node_modules/mocha/mocha.js:5763)

I have simillar results google-chrome, on firefox I don't see duplicated messagtes.
This problem affects also tests with $httpBackend, for example:

PhantomJS 1.9.7 (Linux) Controller: list.FormCtrl #submit() when the list is persisted does the magic FAILED
        Expected PUT /api/lists/123 with different data
        EXPECTED: {"foo":"bar"}
        GOT:      {"_id":123,"name":"New List Name"}
        Error: Expected PUT /api/lists/123 with different data
        EXPECTED: {"foo":"bar"}
        GOT:      {"_id":123,"name":"New List Name"}

On bare mocha everything works fine. I guess it could be related with #16

@pkozlowski-opensource
Copy link
Member

OK, after looking into a bit the problem is that Chrome adds the error message as part of the err.stack itself, ex:

Error: foo
bar
at Context. (http://localhost:9876/base/test/foo.spec.js?c18bd8f72cdb7888f972c8a2778af80d93db0906:3:11)

There is error type as well here... Oh, joy of cross-browsers compatibility :-/

@lucassus
Copy link
Contributor Author

On PhantomJS I have same results. Message is added as a part of the stack tace.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants