Make it possible to only run one test file each time

This commit is contained in:
Richard van der Hoff 2016-04-07 17:49:39 +01:00
parent a2168efcda
commit 7a821ce9d1
3 changed files with 28 additions and 18 deletions

View file

@ -11,11 +11,18 @@ var fs = require('fs');
* If you run karma in multi-run mode (with `npm run test-multi`), it will watch
* the tests for changes, and webpack will rebuild using a cache. This is much quicker
* than a clean rebuild.
*
* TODO:
* - can we run one test at a time?
*/
// the name of the test file. By default, a special file which runs all tests.
//
// TODO: this could be a pattern, and karma would run each file, with a
// separate webpack bundle for each file. But then we get a separate instance
// of the sdk, and each of the dependencies, for each test file, and everything
// gets very confused. Can we persuade webpack to put all of the dependencies
// in a 'common' bundle?
//
var testFile = process.env.KARMA_TEST_FILE || 'test/all-tests.js';
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
function fileExists(name) {
@ -33,6 +40,7 @@ if (!fileExists(gsCss)) {
gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
}
module.exports = function (config) {
config.set({
// frameworks to use
@ -41,15 +49,15 @@ module.exports = function (config) {
// list of files / patterns to load in the browser
files: [
'test/tests.js',
testFile,
gsCss,
],
// list of files to exclude
//
// This doesn't work. It turns out that it's webpack which does the
// watching of the /test directory (possibly karma only watches
// tests.js itself). Webpack watches the directory so that it can spot
// watching of the /test directory (karma only watches `testFile`
// itself). Webpack watches the directory so that it can spot
// new tests, which is fair enough; unfortunately it triggers a rebuild
// every time a lockfile is created in that directory, and there
// doesn't seem to be any way to tell webpack to ignore particular
@ -63,7 +71,7 @@ module.exports = function (config) {
// available preprocessors:
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/tests.js': ['webpack', 'sourcemap']
'test/**/*.js': ['webpack', 'sourcemap']
},
// test results reporter to use
@ -139,7 +147,7 @@ module.exports = function (config) {
},
resolve: {
alias: {
'matrix-react-sdk': path.resolve('src/index.js'),
'matrix-react-sdk': path.resolve('test/skinned-sdk.js'),
'sinon': 'sinon/pkg/sinon.js',
},
root: [