Skip to content

Commit 480c16e

Browse files
author
Oskar Karlsson
committed
✨ Add test-helper as a start up file
1 parent 8d0287d commit 480c16e

4 files changed

+23
-11
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"karma-webpack": "^1.8.0",
4949
"lodash.isequal": "^4.4.0",
5050
"mocha": "^3.0.2",
51+
"null-loader": "^0.1.1",
5152
"protractor": "^4.0.0",
5253
"rxjs": "5.0.0-beta.11",
5354
"simple-spy": "^2.0.3",

unit-test.bundle.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ require('core-js/es7/reflect');
55
require('zone.js/dist/zone');
66
require('zone.js/dist/long-stack-trace-zone');
77

8-
// Require all modules ending in ".spec" from the
9-
// current directory and all subdirectories
10-
var testContext = require.context('./test', true, /\.test\.ts/);
11-
12-
// For each module, call the context function
13-
// that will require the file and load it up here.
14-
testContext.keys().forEach(testContext);
8+
if (window.__karma__) {
9+
require('./unit-test.karma.bundle');
10+
}

unit-test.karma.bundle.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Require all modules ending in ".spec" from the
2+
// current directory and all subdirectories
3+
var testContext = require.context('./test', true, /\.test\.ts/);
4+
5+
// For each module, call the context function
6+
// that will require the file and load it up here.
7+
testContext.keys().forEach(testContext);

wallaby.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ const wallabyWebpack = require('wallaby-webpack');
44
const webpackPostprocessor = wallabyWebpack({
55
entryPatterns: [
66
'unit-test.bundle.js',
7+
'test/helpers/test-helper.js',
78
'test/**/*.test.js'
8-
]
9+
],
10+
module: {
11+
loaders: [
12+
{test: /unit-test\.karma\.bundle\.js/, loader: 'null'}
13+
]
14+
},
15+
devtool: 'source-map'
916
});
1017

1118
module.exports = () => {
1219

1320
return {
1421

1522
files: [
16-
{pattern: 'test/helpers/test-helper.ts', load: false},
17-
{pattern: 'unit-test.bundle.js', load: false},
23+
{pattern: 'test/helpers/test-helper.ts', load: false, instrument: false},
24+
{pattern: 'unit-test.bundle.js', load: false, instrument: false},
25+
{pattern: 'unit-test.karma.bundle.js', load: false, instrument: false},
1826
{pattern: 'src/**/*.ts', load: false},
19-
{pattern: 'test/**/*.ts', load: false},
27+
{pattern: 'test/helpers/**/*.ts', load: false, instrument: false},
2028
{pattern: 'test/**/*.test.ts', ignore: true}
2129
],
2230

0 commit comments

Comments
 (0)