Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Commit f2fe239

Browse files
committed
#39 Changes for faster headless unit tests + better testing sourcemaps on watch
1 parent cb0880f commit f2fe239

File tree

4 files changed

+61
-60
lines changed

4 files changed

+61
-60
lines changed

commands/initial/templates/karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = function (config) {
3131
autoWatch: true,
3232
browsers: ['Chrome', 'PhantomJS'],
3333
singleRun: false,
34-
webpack: require('./webpack/webpack.test.js'),
3534
webpackServer: { noInfo: true }
3635
});
3736
};

commands/initial/templates/tasks/test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ function getHeadlessConfig() {
4242
}
4343

4444
function getWatchConfig() {
45-
let config = getAllConfig();
45+
let config = getAllConfig(true);
4646

4747
config.browsers = ['Chrome'];
4848

4949
return config;
5050
}
5151

52-
function getAllConfig() {
52+
function getAllConfig(watch) {
5353
return {
54-
configFile: path.resolve(process.cwd(), './karma.conf.js')
54+
configFile: path.resolve(process.cwd(), './karma.conf.js'),
55+
webpack: require('./webpack/webpack.test.js')(watch),
5556
};
5657
}
5758

commands/initial/templates/tsconfig.test.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
"compilerOptions": {
44
"emitDecoratorMetadata": true,
55
"experimentalDecorators": true,
6-
"inlineSourceMap": true,
76
"lib": ["es6", "dom"],
87
"module": "commonjs",
98
"moduleResolution": "node",
109
"removeComments": false,
11-
"sourceMap": false,
10+
"sourceMap": true,
1211
"target": "es5",
1312
"typeRoots": [
1413
"./node_modules/@types"

commands/initial/templates/webpack/webpack.test.js

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,61 @@ const SourceMapDevToolPlugin = webpack.SourceMapDevToolPlugin;
99

1010
const rootDir = process.cwd();
1111

12-
module.exports = {
13-
devtool: 'inline-source-map',
14-
module: {
15-
loaders: [
16-
{
17-
exclude: /node_modules/,
18-
test: /\.ts$/,
19-
loaders: [
20-
'awesome-typescript-loader?configFileName=' + path.resolve(rootDir, 'tsconfig.test.json'),
21-
'angular2-template-loader?keepUrl=true'
22-
],
23-
},
24-
{
25-
loaders: ['raw-loader', 'css-loader', 'sass-loader'],
26-
test: /\.s?css$/
27-
},
28-
{ loader: 'raw-loader', test: /\.html$/ },
29-
{
30-
enforce: 'pre',
31-
exclude: /node_modules/,
32-
loader: 'tslint-loader',
12+
module.exports = (watch) => {
13+
return {
14+
devtool: watch ? 'inline-source-map' : 'cheap-module-eval-source-map',
15+
module: {
16+
loaders: [
17+
{
18+
exclude: /node_modules/,
19+
test: /\.ts$/,
20+
loaders: [
21+
'awesome-typescript-loader?configFileName=' + path.resolve(rootDir, 'tsconfig.test.json'),
22+
'angular2-template-loader?keepUrl=true'
23+
],
24+
},
25+
{
26+
loaders: ['raw-loader', 'css-loader', 'sass-loader'],
27+
test: /\.s?css$/
28+
},
29+
{ loader: 'raw-loader', test: /\.html$/ },
30+
{
31+
enforce: 'pre',
32+
exclude: /node_modules/,
33+
loader: 'tslint-loader',
34+
test: /\.ts$/
35+
},
36+
{
37+
enforce: 'post',
38+
exclude: [
39+
/node_modules/,
40+
/\.(e2e|spec\.)ts$/
41+
],
42+
loader: 'istanbul-instrumenter-loader?esModules=true',
43+
test: /\.ts$/
44+
}
45+
]
46+
},
47+
performance: { hints: false },
48+
plugins: [
49+
new ContextReplacementPlugin(
50+
/angular(\\|\/)core(\\|\/)((esm(\\|\/)src|src)(\\|\/)linker|@angular)/,
51+
__dirname
52+
),
53+
new LoaderOptionsPlugin({
54+
options: {
55+
emitErrors: true
56+
}
57+
}),
58+
new SourceMapDevToolPlugin({
59+
filename: null,
3360
test: /\.ts$/
34-
},
35-
{
36-
enforce: 'post',
37-
exclude: [
38-
/node_modules/,
39-
/\.(e2e|spec\.)ts$/
40-
],
41-
loader: 'istanbul-instrumenter-loader?esModules=true',
42-
test: /\.ts$/
43-
}
44-
]
45-
},
46-
performance: { hints: false },
47-
plugins: [
48-
new ContextReplacementPlugin(
49-
/angular(\\|\/)core(\\|\/)((esm(\\|\/)src|src)(\\|\/)linker|@angular)/,
50-
__dirname
51-
),
52-
new LoaderOptionsPlugin({
53-
options: {
54-
emitErrors: true
55-
}
56-
}),
57-
new SourceMapDevToolPlugin({
58-
filename: null,
59-
test: /\.ts$/
60-
})
61-
],
62-
resolve: {
63-
extensions: ['.js', '.ts'],
64-
modules: [path.resolve('.', 'src'), path.resolve(rootDir, 'node_modules')],
65-
moduleExtensions: ['-loader']
61+
})
62+
],
63+
resolve: {
64+
extensions: ['.js', '.ts'],
65+
modules: [path.resolve('.', 'src'), path.resolve(rootDir, 'node_modules')],
66+
moduleExtensions: ['-loader']
67+
}
6668
}
67-
};
69+
};

0 commit comments

Comments
 (0)