Josh Petitt
Josh Petitt

Reputation: 9589

Meteor with QUnit

I am trying to use QUnit with a Meteor app. Should this be possible? Any recommended patterns?

I was trying to make an app that was "self testing" by making a route for "/test" but it doesn't appear that QUnit is running my tests (no test output appears).

Upvotes: 5

Views: 488

Answers (2)

2wav
2wav

Reputation: 148

The answer to this question was a little more involved for me.

I found no discernible difference between putting qunit in a package, and just including qunit sources in my /client files. My difficulty was that sometimes tests seemed to run, sometimes not at all, and frequently a mysterious "global error" would appear in my test results.

This was called by qunit attempting to automatically launch the test run before my own code had loaded tests. I found no good solution to prevent the automatic behavior. My eventual solution was to let qunit finish its (empty) automatic test run, and then to call Qunit.init(), load tests, then Qunit.start().

Upvotes: 0

Josh Petitt
Josh Petitt

Reputation: 9589

@Tom, sure here ya go:

I've added a package for qunit with meteor here:

https://github.com/jpmec/meteor/commit/786b93153d94c0e2291ac210f64587dbbbad23d6

Some facts and disclaimers:

  • I didn't to the branch right, I branched from master not devel.
  • I'm not spending much time trying to keep my meteor branch up to date.
  • This meteor branch is truely fubar'ed wrt the main meteor project, so don't branch from it.

Your best bet is to download, and go look in the packages folder for qunit. That part I think I did right. You'll probably just want to drop this in your meteor packages folder and see if it helps you.

After trying it out some, here are my thoughts to other would-be qunit with meteor users:

  • I cannot figure out how to easily have a "test site" and "production site" with meteor. It seems like it is all or nothing out of the box, so you can have a self-testing site, but all users get to run the tests. (What I would like is to serve up one site on one port and another site on another port, while maintaining a consistent folder tree for my "app").

  • The hot-push of meteor is really cool with qunit. As you write your tests you see them go from red to green in semi-real time. No need to keep switching to the test page and refreshing. This is by far the coolest part of meteor, and using qunit with meteor.

Upvotes: 3

Related Questions