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

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