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

Weird error thrown #80

Closed
ghost opened this issue Nov 25, 2011 · 13 comments
Closed

Weird error thrown #80

ghost opened this issue Nov 25, 2011 · 13 comments

Comments

@ghost
Copy link

ghost commented Nov 25, 2011

I have this code in a test:

person.isInState("Mood").should.be.true

The test is passing. But when I change the returned value by person.isInState("Mood") to false I get the following errors:

✖ 2 of 2 tests failed:

  0) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

  at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
      at Array.1 (/usr/local/lib/node_modules/mocha/lib/runner.js:272:7)
      at EventEmitter._tickCallback (node.js:192:40)

  1) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

  at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
      at Array.1 (/usr/local/lib/node_modules/mocha/lib/runner.js:272:7)
      at EventEmitter._tickCallback (node.js:192:40)




  ✖ 2 of 2 tests failed:

  0) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

  at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
      at Array.1 (/usr/local/lib/node_modules/mocha/lib/runner.js:272:7)
      at EventEmitter._tickCallback (node.js:192:40)

  1) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

  at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
      at Array.1 (/usr/local/lib/node_modules/mocha/lib/runner.js:272:7)
      at EventEmitter._tickCallback (node.js:192:40)

It doesn't make much sense. It comes from the runner.

@tj
Copy link
Contributor

tj commented Nov 25, 2011

i think i've seen this a few times now too, i'll check it out tomorrow

@ghost
Copy link
Author

ghost commented Nov 25, 2011

Some info:

Those errors occur when the tests are throwing errors (eg. the lib I am using).

The original error thrown is: [TypeError: Object # has no method 'inState']

But somehow the Mocha runner throws the above [TypeError: Cannot set property 'failed' of undefined] errors as a response.

@tj
Copy link
Contributor

tj commented Nov 25, 2011

hmm i cant seem to reproduce this now

@ghost
Copy link
Author

ghost commented Nov 25, 2011

Try this:

it "should enter states serially", (done) ->
    methodDoesntExit()
    done()

It throws the errors I mentioned above.

@tj
Copy link
Contributor

tj commented Nov 25, 2011

ah ok got it, it's when async

@tj
Copy link
Contributor

tj commented Nov 25, 2011

ahahaha that tricky little bugger.. i got it

@tj tj closed this as completed in 58b3602 Nov 25, 2011
@marty-wang
Copy link

I ran into same issues several times. It is definitely async issue, and the solution I found is that you need to call assertions within the callback, either after done.

Here is my gist, https://gist.github.com/1392471

@tj
Copy link
Contributor

tj commented Nov 25, 2011

I just wasn't returning on the exception so it executed twice

@ghost
Copy link
Author

ghost commented Nov 25, 2011

Is the error 1 and 2 supposed to be there?

✖ 3 of 3 tests failed:

0) Yobiengine should enter states serially: TypeError: Object #<Object> has no method 'inSt
atess'
    at Person.isInState (/Volumes/Private/johnnyluu/Documents/Development/johnnywengluu/yobiengine/lib/yobiengine-api.coffee:38:41)
    at Test.fn (/Volumes/Private/johnnyluu/Documents/Development/johnnywengluu/yobiengine/test/yobiengine-api.coffee:91:14)
    at Test.run (/usr/local/lib/node_modules/mocha/lib/test.js:72:10)
    at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:254:19)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:318:12
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:183:14)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:192:7
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:126:27)
    at Array.0 (/usr/local/lib/node_modules/mocha/lib/runner.js:160:5)
    at EventEmitter._tickCallback (node.js:192:40)

1) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
    at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:262:7)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:318:12
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:183:14)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:192:7
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:126:27)
    at Array.0 (/usr/local/lib/node_modules/mocha/lib/runner.js:160:5)
    at EventEmitter._tickCallback (node.js:192:40)

2) Yobiengine should enter states serially: TypeError: Cannot set property 'failed' of undefined

at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:90:15)
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:294:12)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:319:25
    at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:262:7)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:318:12
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:183:14)
    at /usr/local/lib/node_modules/mocha/lib/runner.js:192:7
    at next (/usr/local/lib/node_modules/mocha/lib/runner.js:126:27)
    at Array.0 (/usr/local/lib/node_modules/mocha/lib/runner.js:160:5)
    at EventEmitter._tickCallback (node.js:192:40)

@tj
Copy link
Contributor

tj commented Nov 25, 2011

hmm i think that might be due to the timer

@tj
Copy link
Contributor

tj commented Nov 25, 2011

yup, reproduced it

@ghost
Copy link
Author

ghost commented Nov 25, 2011

Should/could this also be fixed? It might confuse the users.

@tj
Copy link
Contributor

tj commented Nov 25, 2011

of course

kkaefer pushed a commit to kkaefer/mocha that referenced this issue Mar 30, 2012
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