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

Commit

Permalink
#39 Changes for faster headless unit tests + better testing sourcemap…
Browse files Browse the repository at this point in the history
…s on watch
  • Loading branch information
gonzofish committed Jun 22, 2017
1 parent cb0880f commit f2fe239
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 60 deletions.
1 change: 0 additions & 1 deletion commands/initial/templates/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = function (config) {
autoWatch: true,
browsers: ['Chrome', 'PhantomJS'],
singleRun: false,
webpack: require('./webpack/webpack.test.js'),
webpackServer: { noInfo: true }
});
};
7 changes: 4 additions & 3 deletions commands/initial/templates/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ function getHeadlessConfig() {
}

function getWatchConfig() {
let config = getAllConfig();
let config = getAllConfig(true);

config.browsers = ['Chrome'];

return config;
}

function getAllConfig() {
function getAllConfig(watch) {
return {
configFile: path.resolve(process.cwd(), './karma.conf.js')
configFile: path.resolve(process.cwd(), './karma.conf.js'),
webpack: require('./webpack/webpack.test.js')(watch),
};
}

Expand Down
3 changes: 1 addition & 2 deletions commands/initial/templates/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"lib": ["es6", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"removeComments": false,
"sourceMap": false,
"sourceMap": true,
"target": "es5",
"typeRoots": [
"./node_modules/@types"
Expand Down
110 changes: 56 additions & 54 deletions commands/initial/templates/webpack/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,61 @@ const SourceMapDevToolPlugin = webpack.SourceMapDevToolPlugin;

const rootDir = process.cwd();

module.exports = {
devtool: 'inline-source-map',
module: {
loaders: [
{
exclude: /node_modules/,
test: /\.ts$/,
loaders: [
'awesome-typescript-loader?configFileName=' + path.resolve(rootDir, 'tsconfig.test.json'),
'angular2-template-loader?keepUrl=true'
],
},
{
loaders: ['raw-loader', 'css-loader', 'sass-loader'],
test: /\.s?css$/
},
{ loader: 'raw-loader', test: /\.html$/ },
{
enforce: 'pre',
exclude: /node_modules/,
loader: 'tslint-loader',
module.exports = (watch) => {
return {
devtool: watch ? 'inline-source-map' : 'cheap-module-eval-source-map',
module: {
loaders: [
{
exclude: /node_modules/,
test: /\.ts$/,
loaders: [
'awesome-typescript-loader?configFileName=' + path.resolve(rootDir, 'tsconfig.test.json'),
'angular2-template-loader?keepUrl=true'
],
},
{
loaders: ['raw-loader', 'css-loader', 'sass-loader'],
test: /\.s?css$/
},
{ loader: 'raw-loader', test: /\.html$/ },
{
enforce: 'pre',
exclude: /node_modules/,
loader: 'tslint-loader',
test: /\.ts$/
},
{
enforce: 'post',
exclude: [
/node_modules/,
/\.(e2e|spec\.)ts$/
],
loader: 'istanbul-instrumenter-loader?esModules=true',
test: /\.ts$/
}
]
},
performance: { hints: false },
plugins: [
new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)((esm(\\|\/)src|src)(\\|\/)linker|@angular)/,
__dirname
),
new LoaderOptionsPlugin({
options: {
emitErrors: true
}
}),
new SourceMapDevToolPlugin({
filename: null,
test: /\.ts$/
},
{
enforce: 'post',
exclude: [
/node_modules/,
/\.(e2e|spec\.)ts$/
],
loader: 'istanbul-instrumenter-loader?esModules=true',
test: /\.ts$/
}
]
},
performance: { hints: false },
plugins: [
new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)((esm(\\|\/)src|src)(\\|\/)linker|@angular)/,
__dirname
),
new LoaderOptionsPlugin({
options: {
emitErrors: true
}
}),
new SourceMapDevToolPlugin({
filename: null,
test: /\.ts$/
})
],
resolve: {
extensions: ['.js', '.ts'],
modules: [path.resolve('.', 'src'), path.resolve(rootDir, 'node_modules')],
moduleExtensions: ['-loader']
})
],
resolve: {
extensions: ['.js', '.ts'],
modules: [path.resolve('.', 'src'), path.resolve(rootDir, 'node_modules')],
moduleExtensions: ['-loader']
}
}
};
};

0 comments on commit f2fe239

Please sign in to comment.