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 Spec Reporter #234

Closed
skbolton opened this issue Apr 30, 2017 · 6 comments
Closed

Mocha Spec Reporter #234

skbolton opened this issue Apr 30, 2017 · 6 comments

Comments

@skbolton
Copy link

I feel like this might be a little OCD but I have noticed something weird when using testdouble and mocha. I am going to put an excerpt of one of my tests.

before(() => { td.replace(console, 'log') })
after(() => { td.reset() })

it('should console.log the state of Model', () => {
      Opportunity
        .fields('.', 'child.name')
        .where({
          id: 5
        })

      Opportunity.explain()

      const callCount = td.explain(console.log).callCount
      expect(callCount).to.equal(1)
    })

The test passes but the spec reporter doesn't show one of the check marks
screen shot 2017-04-29 at 5 55 04 pm

I know things are technically working because if I change something in the test to make it break it does cause Mocha to fail.

screen shot 2017-04-29 at 5 57 21 pm

PS. For what it is worth I love your explain functionality of testdouble and I have a feature in the library I am creating that shows off the influence. 😄

@searls
Copy link
Member

searls commented Apr 30, 2017

I suspect mocking console.log is not going to end well for you, since lots of other libraries (including Mocha) will call console.log. It's likely that's why you get two instead of 1.

I recommend wrapping console.log to your own logger and mocking that. See this article. That's what we do in this lib here

@searls searls closed this as completed Apr 30, 2017
@skbolton
Copy link
Author

skbolton commented Apr 30, 2017

I am totally with you and I just want to point out that I took a photo of that failed test to prove I can make the test fail. In the first photo the tests are 'passing' but no check marks are showing up in the reporter.
Maybe I will do a test not mocking console.log and see if I can get the same behavior

@searls
Copy link
Member

searls commented Apr 30, 2017

I'm sorry, I do not understand what your issue is. I don't know what the checkmarks you're looking for are.

@skbolton
Copy link
Author

skbolton commented Apr 30, 2017

screen shot 2017-04-29 at 10 21 01 pm

To my earlier comment I will mock something other than console.log and see if I can get the same behavior. In the explain test suite I have 3 tests that use testdouble. They are all passing but not showing up in the reporter.
They are still counting as a passed test just not showing up. Weird and nitpicky but I was just seeing if it was something you guys have encountered before.

@searls
Copy link
Member

searls commented Apr 30, 2017

Could you please provide a minimal example project repo

@skbolton
Copy link
Author

Yeah I will make one and follow up if needed. Thanks for your time!

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

2 participants