-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aec4fba
commit 9dfa5f1
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const webpack = require('webpack'); | ||
|
||
const webpackConfig = { | ||
module: { | ||
loaders: [{ | ||
test: /\.ts$/, | ||
loader: 'ts-loader', | ||
exclude: /node_modules/ | ||
}], | ||
postLoaders: [{ | ||
test: /src\/.+\.ts$/, | ||
exclude: /(node_modules|\.spec\.ts$)/, | ||
loader: 'sourcemap-istanbul-instrumenter-loader?force-sourcemap=true' | ||
}] | ||
}, | ||
plugins: [ | ||
new webpack.SourceMapDevToolPlugin({ | ||
filename: null, | ||
test: /\.(ts|js)($|\?)/i | ||
}) | ||
], | ||
resolve: { | ||
extensions: ['', '.ts', '.js'] | ||
} | ||
}; | ||
|
||
module.exports = config => { | ||
config.set({ | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: './', | ||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ['mocha'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'test/test.spec.ts' | ||
], | ||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'test/test.spec.ts': ['webpack', 'sourcemap'] | ||
}, | ||
|
||
webpack: webpackConfig, | ||
|
||
remapIstanbulReporter: { | ||
reports: { | ||
html: 'coverage/html', | ||
'text-summary': null | ||
} | ||
}, | ||
|
||
phantomjsLauncher: { | ||
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom) | ||
exitOnResourceError: true | ||
}, | ||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['dots', 'coverage', 'karma-remap-istanbul'], | ||
|
||
// web server port | ||
port: 9876, | ||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: ['PhantomJS'], | ||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "karma-remap-istanbul-example", | ||
"private": true, | ||
"version": "1.0.0", | ||
"description": "Karma remap istanbul example", | ||
"scripts": { | ||
"test": "karma start" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/chai": "~3.4.32", | ||
"@types/mocha": "~2.2.31", | ||
"chai": "~3.5.0", | ||
"karma": "~1.2.0", | ||
"karma-coverage": "~1.1.1", | ||
"karma-mocha": "~1.1.1", | ||
"karma-phantomjs-launcher": "~1.0.2", | ||
"karma-remap-istanbul": "~0.2.1", | ||
"karma-sourcemap-loader": "~0.3.7", | ||
"karma-webpack": "~1.8.0", | ||
"mocha": "~3.0.2", | ||
"sourcemap-istanbul-instrumenter-loader": "~0.2.0", | ||
"ts-loader": "~0.8.2", | ||
"typescript": "~2.0.2", | ||
"webpack": "~1.13.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export class Foo { | ||
|
||
bar(): boolean { | ||
return true; //covered | ||
} | ||
|
||
baz(): boolean { | ||
return false; // not covered | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {expect} from 'chai'; | ||
import {Foo} from './../src/example'; | ||
|
||
describe('Foo', () => { | ||
|
||
it('should return true', () => { | ||
const foo: Foo = new Foo(); | ||
expect(foo.bar()).to.be.true; | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES5", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"removeComments": false, | ||
"noImplicitAny": false | ||
}, | ||
"compileOnSave": false | ||
} |