mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.57k stars 3.01k forks source link

this.callback is a dirty word #259

Closed JamesMaroney closed 12 years ago

JamesMaroney commented 12 years ago

When writing specs (BDD interface), writing to this.callback is apparently a no-no because it is overwritten by mocha for it's internal needs.

describe 'something', ->
  beforeEach ->
    @callback = name: 'good day, sir'
  it 'should be polite', ->
    @callback.name.should.equal 'good day, sir'

this.callback is no longer the object it once was in the beforeEach as one would have expected.

tj commented 12 years ago

why are you calling an object callback

tj commented 12 years ago

also the next release will use a Context so the only "reserved" key is "timeout"

JamesMaroney commented 12 years ago

it was a contrived example. I actually was injecting a spy into my item under test and then asserting on the spy in my spec

@callback seemed the most natural name for it. Everything became clear once I renamed it.

On Sat, Feb 11, 2012 at 4:01 PM, TJ Holowaychuk reply@reply.github.com wrote:

also the next release will use a Context so the only "reserved" key is "timeout"


Reply to this email directly or view it on GitHub: https://github.com/visionmedia/mocha/issues/259#issuecomment-3923470