Skip to content

Successful retries don't let test pass #128

Description

@Magomogo

Mocha test runner has--retries flag that makes failed tests to retry. However successful try doesn't make chakram think that the test suite is successful.

example, this test will pass only with the second attempt (file ./retries.js):

const chakram = require('chakram'),
    expect = chakram.expect;

let tryNumber = 0;

beforeEach(() => {
    tryNumber++;
});

it('will pass on second try', () => {
    const response = chakram.get(
        'http://example.com/' + (tryNumber === 2 ? '' : '/notexisting')
    );

    return expect(response).to.have.status(200)
});

execution log:

$ mocha --retries 1 ./retries.js


  1) will pass on second try
  ✓ will pass on second try (300ms)

  1 passing (669ms)
  1 failing

  1) will pass on second try:
     Error: Some expectation promises were not fulfilled before the test finished. Ensure you are waiting for all the expectations to run
      at Context.warnUser (node_modules/chakram/lib/chakram.js:148:25)
      at Context.checkForUnfulfilledExpectations (node_modules/chakram/lib/chakram.js:155:22)
      at Context.<anonymous> (node_modules/chakram/lib/chakram.js:162:37)

I expect that this test suite will be successful, in other case --retries feature is useless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions