mocha coffeescript example #82

Closed
andreineculau opened this Issue Nov 8, 2012 · 7 comments

Projects

None yet

2 participants

@andreineculau

I've found out that the coffeescript example (using jasmine as framework)
would benefit from a Mocha version

I don't know if this is Mocha specific, but this is what happens in different scenarios

Scenario 1

framework: mocha
before_tests: coffee -c src test
on_exit: rm src/*.js test/*.js
src_files:
- src/*.coffee
- test/*.coffee
launchers:
  Mocha:
    command: mocha -R tap test/*.coffee
    protocol: tap
launch_in_dev:
  - Mocha
launch_in_ci:
  - Mocha
  • tests will start running and fail (coffee compiler still not done)
  • tests will run again and pass (coffee compiler finished)

Same happens with mocha -r coffee-script

Scenario 2

framework: mocha
before_tests: coffee -c src test
on_exit: rm src/*.js test/*.js
src_files:
- src/*.coffee
- test/*.coffee
launchers:
  Mocha:
    command: mocha --compilers coffee:coffee-script -R tap test/*.coffee
    protocol: tap
launch_in_dev:
  - Mocha
launch_in_ci:
  - Mocha
  • tests run twice, and pass both times

Scenario 3

remove before_tests and on_exit for a smooth one-time passing tests


I have Scenario 3 with commented out before_tests and on_exit in live.

But I like Scenario 2 when testing locally, because of the line-numbers reported onto the JS compiled source, rather than the coffee source.

@airportyh
Collaborator

Interesting, I'll check that out. As I understand it, there are several ways to run CoffeeScript on the Node side.

@airportyh
Collaborator

@andreineculau did changing on_quit to on_exit fix this?

@andreineculau

@airportyh no, but it's true - I should update the issue to remove confusion.

Scenario 1: it just looks like Mocha is started before coffee -c finishes
Scenario 2: I couldn't pinpoint the issue either, but Mocha is doing a watch on something (despite no --watch) that gets touched on before_tests: coffee -c src test so Mocha restarts

@airportyh
Collaborator

I tried reproducing this but had no luck. Here are the examples I used:

https://github.com/airportyh/testem/tree/mocha_coffee/examples/mocha_coffee_1
https://github.com/airportyh/testem/tree/mocha_coffee/examples/mocha_coffee_2

Just in case - make sure you have latest version of Testem, because I've changed something in this area not too long ago. If that fails, let me know your OS and node version. Thanks.

@andreineculau

the examples are 99% in line with what I have
npm install growl and add -G to the mocha launcher
you will then see that tests are being ran twice (resulting in 2 growl notifications)

I don't know what has changed with testem meanwhile (bad of me to file this issue without a version info), but now your mocha examples work the same (trigger two consecutive test runs), while going with the example I had in scenario 1 (no --compilers, nor -r) -> tests fail.

FYI running testem@0.2.24, mocha@1.7.0, node@0.8.12, os@osx.10.7.5

@airportyh airportyh closed this Nov 21, 2012
@airportyh
Collaborator

Thanks for the additional details. It should be sorted, please verify.

@andreineculau

I verified :) Thank you. Good work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment