Skip to content

Commit

Permalink
tests(): use sourcemap-istanbul-instrumenter-loader
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
blaugold committed Nov 29, 2016
1 parent af50664 commit 1be2540
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 251 deletions.
12 changes: 1 addition & 11 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 46 additions & 23 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
'use strict';
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');

let firebaseConfig = process.env.FIREBASE_CONFIG ||
fs.readFileSync('./firebase.config.local.json', {encoding: 'utf8'})
Expand All @@ -10,6 +10,36 @@ if (firebaseConfig === '') {
throw new Error('Failed to load Firebase config.')
}

const coverage = !!process.env['COVERAGE'];
if (coverage) {
console.log('Running tests with coverage!');
}

const reporters = ['mocha'];

if (coverage) {
reporters.push('karma-remap-istanbul')
}

const rules = [{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/
}];

if (coverage) {
rules.push({
enforce: 'post',
test: /\.(ts|js)$/,
loader: 'sourcemap-istanbul-instrumenter-loader',
exclude: [
/\.(spec|e2e|bundle)\.ts$/,
/node_modules/
],
query: {'force-sourcemap': true}
})
}

module.exports = function (karma) {
karma.set({
basePath: __dirname,
Expand All @@ -22,7 +52,7 @@ module.exports = function (karma) {
'tests.bundle.ts': ['webpack']
},

reporters: ['mocha', 'karma-remap-istanbul'],
reporters,

remapIstanbulReporter: {
reports: {
Expand All @@ -46,29 +76,22 @@ module.exports = function (karma) {
},

module: {
loaders: [
{
test: /\.ts$/,
loader: 'awesome-typescript',
exclude: /node_modules/
},
{
enforce: 'post',
test: /\.(ts|js)$/,
loader: 'istanbul-instrumenter',
include: path.resolve(__dirname, 'src'),
exclude: [
/\.(spec|e2e|bundle)\.ts$/,
/node_modules/
]
}
]
rules,
},

plugins: [
new webpack.DefinePlugin({
firebaseConfig
}),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve(__dirname, './src')
),
new webpack.SourceMapDevToolPlugin({
filename: null, // if no value is provided the sourcemap is inlined
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
})
]
}
})
}
};
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"predoc": "rimraf docs",
"doc": "npm run typedoc -- --options typedoc.json index.ts",
"upload-coverage": "coveralls < coverage/lcov.info",
"fix": "cpy karma-remap-istanbul-fix/index.js node_modules/karma-remap-istanbul",
"karma": "karma start",
"test": "npm run karma -- --single-run",
"test": "COVERAGE=true npm run karma -- --single-run",
"copy": "cpy package.json README.md release",
"ngc": "ngc -p aot.tsconfig.json",
"clean:pre": "rimraf release",
Expand Down Expand Up @@ -53,7 +52,6 @@
"core-js": "^2.4.1",
"coveralls": "^2.11.14",
"cpy-cli": "^1.0.1",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine": "^2.5.2",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
Expand All @@ -63,6 +61,7 @@
"karma-webpack": "^1.8.0",
"rimraf": "^2.5.4",
"rxjs": "5.0.0-beta.12",
"sourcemap-istanbul-instrumenter-loader": "^0.2.0",
"standard-version": "^3.0.0",
"typedoc": "^0.5.1",
"typescript": "^2.0.6",
Expand Down
13 changes: 2 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
{
"compilerOptions": {
"inlineSourceMap": true,
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"rootDir": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": false,
"outDir": "./release",
"rootDir": ".",
"lib": ["es2015", "dom"],
"target": "es5",
"skipLibCheck": true,
"types": [
"node",
"jasmine"
]
},
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
]
}
Loading

0 comments on commit 1be2540

Please sign in to comment.