Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha-parallel-tests doesn't show full AssertionError message for nested objects #215

Open
thespecial opened this issue Feb 6, 2019 · 4 comments

Comments

@thespecial
Copy link

thespecial commented Feb 6, 2019

Stack:
mocha, nodejs, chai (expect)
Mac OS X, Linux (Jenkins)

Code to run tests in parallel programmatically:

const fs = require('fs');
const Mocha = require('mocha-parallel-tests').default

const mocha = new Mocha({
  ui: 'bdd',
  reporter: 'mocha-spec-json-output-reporter',
  timeout: 200000
});

files = fs.readdirSync(`${__dirname}/test1`);
files.forEach((file) => {
  if (file.match(/(\S+.js)$/)) {
    mocha.addFile(`${__dirname}/test1/${file}`);
  }
})

mocha.run((failures) => {
  process.on('exit', () => {
    process.exit(failures);
  });
});

Test itself:

const expect = require('chai').expect;

describe('Test 2', function () {
    it(`is expected response`, () => {
        expect({a:3, b:4, c: [ {a: "b", c: "d"}, {a: "b", c: "d"}]}).to.eql({a:1, b:2});
    });
});

For example, if in my tests I assert using chai objects expect({a:3, b:4, c: [ {a: "b", c: "d"}, {a: "b", c: "d"}]}).to.eql({a:1, b:2});, then I get such log (2) so for nested objects assertion error is cut (the same goes to json output).

   Test 1
      1) is expected pprod response to equal prod response


    Test 2
      2) is expected pprod response to equal prod response


  0 passing (6s)
  2 failing

  1)
       Test 1
         is expected pprod response to equal prod response:
     AssertionError: expected { a: 3, b: 4 } to deeply equal { a: 1, b: 2 }
      at Context.it (test1/test1.js:23:31)

  2)
       Test 2
         is expected pprod response to equal prod response:
     AssertionError: expected { Object (a, b, ...) } to deeply equal { a: 1, b: 2 }
      at Context.it (test1/test2.js:22:73)

I would expect getting normal log as when run sequentially:

Test 2
    1) is expected pprod response to equal prod response


  0 passing (1s)
  1 failing

  1) Test 2
       is expected pprod response to equal prod response:

      AssertionError: expected { Object (a, b, ...) } to deeply equal { a: 1, b: 2 }
      + expected - actual

       {
      -  "a": 3
      -  "b": 4
      -  "c": [
      -    {
      -      "a": "b"
      -      "c": "d"
      -    }
      -    {
      -      "a": "b"
      -      "c": "d"
      -    }
      -  ]
      +  "a": 1
      +  "b": 2
       }

Could someone suggest what to do in such case? Thanks in advance.

@1999
Copy link
Collaborator

1999 commented Feb 14, 2019

@thespecial did you try --full-trace option?

@thespecial
Copy link
Author

thespecial commented Feb 15, 2019

@1999 yes, that didn't help.

I did smth like this:

node_modules/.bin/mocha-parallel-tests --full-trace test1.js

@thespecial
Copy link
Author

@1999 please, check the PR.

@rhor-bgl
Copy link

rhor-bgl commented Jun 8, 2021

Hi there, how do i get a new mocha-parallel-tests version which got this issue fixed?

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

No branches or pull requests

3 participants