Skip to content

Instantly share code, notes, and snippets.

@dfkaye
Last active August 29, 2015 13:55
Show Gist options
  • Save dfkaye/8773266 to your computer and use it in GitHub Desktop.
Save dfkaye/8773266 to your computer and use it in GitHub Desktop.
Configure and run multiple framework launchers for testem
I was looking at how to override the default framework I kept getting now matter how I
defined the launchers in testem.json.
testem.json is used by the testem command
But if we use an npm run script (as defined in "scripts" in package.json) to call testem
with various args (like custom test_page) we get the test_page's framework via its script
tags.
testem generates its own test pages unless you specify your own - to do that, it's best
to follow the mustache templates at [https://github.com/airportyh/testem/blob/master/views/]
(NOTE: have to include path to your own directories, not testem's, when working with
framework versions other than testem's.)
First, define corresponding launchers in testem.json - these run the tests on node.js:
{
"launchers": {
"jasmine" : {
"command": "jasmine-node --verbose ./test/jasmine-where.spec.js",
},
"mocha" : {
"command": "node ./test/mocha/mocha-suite.js"
},
"qunit" : {
"command": "node ./test/qunit/qunit-suite.js"
},
"tape" : {
"command": "node ./test/tape/tape-suite.js",
}
}
}
Next, define scripts in package.json with the -t flag to load your test page in a browser testem watches:
"scripts" : {
"testem-jasmine": "testem -l jasmine -t ./test/jasmine/browser/suite.html",
"testem-mocha": "testem -l mocha -t ./test/mocha/browser-suite.html",
"testem-qunit": "testem -l qunit -t ./test/qunit/browser-suite.html",
"testem-tape": "testem -l tape -t ./test/tape/browser-suite.html"
...
}
Test 'em out with npm run <name>:
npm run testem-jasmine
npm run testem-mocha
npm run testem-qunit
npm run testem-tape
Works on my machine.
MORE TO COME...
@airportyh
Copy link

Very interesting. It sounds like you are trying to unify the node and browser experiences - which is a UX win. I am currently working on rewriting testem to have pluggable everything, so this topic is very relevant. What I am trying to achieve is so that people can npm install testem-jasmine, and then it just works, it would be ultra cool if it also just worked for node.

@airportyh
Copy link

Alternatively use separate testem config files.

@dfkaye
Copy link
Author

dfkaye commented Feb 6, 2014

Thanks, Toby ~ Yes, I had started a bullpen repo for testem configuration where - eventually - all this learning would go ~ https://github.com/dfkaye/testem-bullpen

I do have a bunch of this worked out in my still-in-progress https://github.com/dfkaye/where.js repo in which I spell out a lot of this detail for node v. browser and testem v standalone.

Some day, some day...

@airportyh
Copy link

There's just to much variation still in what people are doing, given that not everyone is on board with a module system. If you are not using CommonJS within the browser, having those conditional requires just isn't practical. If you are doing require.js then even harder to get JS working in both environments. Everyone still has to figure it out on their own, so Testem should be very hands off about it still at this point.

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