mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Make it possible to only run one test file each time
This commit is contained in:
parent
a2168efcda
commit
7a821ce9d1
@ -11,11 +11,18 @@ var fs = require('fs');
|
|||||||
* If you run karma in multi-run mode (with `npm run test-multi`), it will watch
|
* 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
|
* the tests for changes, and webpack will rebuild using a cache. This is much quicker
|
||||||
* than a clean rebuild.
|
* 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';
|
process.env.PHANTOMJS_BIN = 'node_modules/.bin/phantomjs';
|
||||||
|
|
||||||
function fileExists(name) {
|
function fileExists(name) {
|
||||||
@ -33,6 +40,7 @@ if (!fileExists(gsCss)) {
|
|||||||
gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
|
gsCss = 'node_modules/react-gemini-scrollbar/'+gsCss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (config) {
|
module.exports = function (config) {
|
||||||
config.set({
|
config.set({
|
||||||
// frameworks to use
|
// frameworks to use
|
||||||
@ -41,15 +49,15 @@ module.exports = function (config) {
|
|||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [
|
||||||
'test/tests.js',
|
testFile,
|
||||||
gsCss,
|
gsCss,
|
||||||
],
|
],
|
||||||
|
|
||||||
// list of files to exclude
|
// list of files to exclude
|
||||||
//
|
//
|
||||||
// This doesn't work. It turns out that it's webpack which does the
|
// This doesn't work. It turns out that it's webpack which does the
|
||||||
// watching of the /test directory (possibly karma only watches
|
// watching of the /test directory (karma only watches `testFile`
|
||||||
// tests.js itself). Webpack watches the directory so that it can spot
|
// itself). Webpack watches the directory so that it can spot
|
||||||
// new tests, which is fair enough; unfortunately it triggers a rebuild
|
// new tests, which is fair enough; unfortunately it triggers a rebuild
|
||||||
// every time a lockfile is created in that directory, and there
|
// every time a lockfile is created in that directory, and there
|
||||||
// doesn't seem to be any way to tell webpack to ignore particular
|
// doesn't seem to be any way to tell webpack to ignore particular
|
||||||
@ -63,7 +71,7 @@ module.exports = function (config) {
|
|||||||
// available preprocessors:
|
// available preprocessors:
|
||||||
// https://npmjs.org/browse/keyword/karma-preprocessor
|
// https://npmjs.org/browse/keyword/karma-preprocessor
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'test/tests.js': ['webpack', 'sourcemap']
|
'test/**/*.js': ['webpack', 'sourcemap']
|
||||||
},
|
},
|
||||||
|
|
||||||
// test results reporter to use
|
// test results reporter to use
|
||||||
@ -139,7 +147,7 @@ module.exports = function (config) {
|
|||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'matrix-react-sdk': path.resolve('src/index.js'),
|
'matrix-react-sdk': path.resolve('test/skinned-sdk.js'),
|
||||||
'sinon': 'sinon/pkg/sinon.js',
|
'sinon': 'sinon/pkg/sinon.js',
|
||||||
},
|
},
|
||||||
root: [
|
root: [
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
// tests.js
|
// all-tests.js
|
||||||
//
|
//
|
||||||
// Our master test file: uses the webpack require API to find our test files
|
// Our master test file: uses the webpack require API to find our test files
|
||||||
// and run them
|
// and run them
|
||||||
|
|
||||||
// this is a handly place to make sure the sdk has been skinned
|
|
||||||
var sdk = require("matrix-react-sdk");
|
|
||||||
sdk.loadSkin(require('./test-component-index'));
|
|
||||||
|
|
||||||
var context = require.context('.', true, /-test\.jsx?$/);
|
var context = require.context('.', true, /-test\.jsx?$/);
|
||||||
context.keys().forEach(context);
|
context.keys().forEach(context);
|
@ -1,12 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* test-component-index.js
|
* skinned-sdk.js
|
||||||
*
|
*
|
||||||
* Stub out a bunch of the components which we expect the application to
|
* Skins the react-sdk with a few stub components which we expect the
|
||||||
* provide
|
* application to provide
|
||||||
*/
|
*/
|
||||||
var components = require('../src/component-index.js').components;
|
|
||||||
|
var sdk = require("../src/index");
|
||||||
|
|
||||||
|
var skin = require('../src/component-index.js');
|
||||||
var stubComponent = require('./components/stub-component.js');
|
var stubComponent = require('./components/stub-component.js');
|
||||||
|
|
||||||
|
var components = skin.components;
|
||||||
components['structures.LeftPanel'] = stubComponent();
|
components['structures.LeftPanel'] = stubComponent();
|
||||||
components['structures.RightPanel'] = stubComponent();
|
components['structures.RightPanel'] = stubComponent();
|
||||||
components['structures.RoomDirectory'] = stubComponent();
|
components['structures.RoomDirectory'] = stubComponent();
|
||||||
@ -18,4 +22,6 @@ components['views.messages.DateSeparator'] = stubComponent({displayName: 'DateSe
|
|||||||
components['views.messages.MessageTimestamp'] = stubComponent({displayName: 'MessageTimestamp'});
|
components['views.messages.MessageTimestamp'] = stubComponent({displayName: 'MessageTimestamp'});
|
||||||
components['views.messages.SenderProfile'] = stubComponent({displayName: 'SenderProfile'});
|
components['views.messages.SenderProfile'] = stubComponent({displayName: 'SenderProfile'});
|
||||||
|
|
||||||
module.exports.components = components;
|
sdk.loadSkin(skin);
|
||||||
|
|
||||||
|
module.exports = sdk;
|
Loading…
Reference in New Issue
Block a user