Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

stubConsole prevents mocha reporter output #214

Closed
grayside opened this issue Jul 17, 2019 · 1 comment
Closed

stubConsole prevents mocha reporter output #214

grayside opened this issue Jul 17, 2019 · 1 comment
Assignees

Comments

@grayside
Copy link

I'm retrofitting some tests to use ava + sinon to mocha + nodejs-repo-tools.

For tests where I'm using stubConsole, the mocha reporter fails to print output to the terminal.

Environment details

  • OS: macOS
  • node v10.16.0
  • npm version: v6.9.0
  • @google-cloud/nodejs-repo-tools version: 3.3.0
  • mocha version: 6.1.4

Steps to reproduce

  1. Run mocha test/*.test.js
  2. Test code as follows:
describe('should succeed', () => {
    beforeEach(tools.stubConsole);
    afterEach(tools.restoreConsole);

    it(`with style`, async () => {
      await requestObj
        .post('/')
        .type('json')
        .send({message: true})
        .expect(204)
        .expect(() => assert.ok(console.log.calledWith('Hello World!')));
    });
});
  1. The output from this test is hidden by the stub.

It looks like mocha itself has some code in an attempt to avoid this kind of problem but it's not helping.

Based on the behavior I'm seeing, unless this is a bug in a newer version of mocha or in nodejs-repo-tools, any tests using mocha + stubConsole are not able to output a full report such as:

  Unit Tests
    should fail
error: invalid Pub/Sub message format
      ✓ on a Bad Request with an empty payload
error: invalid Pub/Sub message format
      ✓ on a Bad Request with an invalid payload
error: invalid Pub/Sub message format
      ✓ on a Bad Request with an invalid mimetype

the it() output is swallowed.

@fhinkel
Copy link
Contributor

fhinkel commented Oct 27, 2020

Closing as we're archiving this repository.

@fhinkel fhinkel closed this as completed Oct 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants