Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3d50174

Browse files
committedSep 9, 2016
Add example use of karma (+ jasmine and chai)
1 parent 0bcf4b0 commit 3d50174

File tree

8 files changed

+1000
-0
lines changed

8 files changed

+1000
-0
lines changed
 
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'angular2-universal-polyfills';
2+
import { assert } from 'chai';
3+
import { Counter } from '../components/counter/counter';
4+
5+
describe('Counter component', () => {
6+
it('should start with value 0', () => {
7+
const instance = new Counter();
8+
assert.equal(instance.currentCount, 0);
9+
});
10+
11+
it('should increment the counter by 1 when requested', () => {
12+
const instance = new Counter();
13+
instance.incrementCounter();
14+
assert.equal(instance.currentCount, 1);
15+
instance.incrementCounter();
16+
assert.equal(instance.currentCount, 2);
17+
});
18+
});

‎templates/Angular2Spa/karma.conf.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = function(config) {
2+
config.set({
3+
frameworks: ['jasmine', 'chai'],
4+
reporters: ['progress'],
5+
logLevel: config.LOG_INFO,
6+
browsers: ['Chrome'],
7+
autoWatch: true,
8+
autoWatchBatchDelay: 300,
9+
10+
files: [
11+
// Note: you must have already run 'webpack --config webpack.config.vendor.js' for this file to exist
12+
'./wwwroot/dist/vendor.js',
13+
14+
'./ClientApp/tests/*.ts',
15+
'./ClientApp/tests/**/*.ts'
16+
],
17+
18+
preprocessors: {
19+
'./ClientApp/tests/*.ts': ['webpack'],
20+
'./ClientApp/tests/**/*.ts': ['webpack']
21+
},
22+
23+
webpack: require('./webpack.config.js'),
24+
webpackMiddleware: { stats: 'errors-only' }
25+
});
26+
};

‎templates/Angular2Spa/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
"devDependencies": {
55
"aspnet-webpack": "^1.0.6",
66
"bootstrap": "^3.3.6",
7+
"chai": "^3.5.0",
78
"css-loader": "^0.23.1",
89
"expose-loader": "^0.7.1",
910
"extendify": "^1.0.0",
1011
"extract-text-webpack-plugin": "^1.0.1",
1112
"file-loader": "^0.8.5",
13+
"jasmine-core": "^2.5.1",
1214
"jquery": "^2.2.1",
15+
"karma": "^1.2.0",
16+
"karma-chai": "^0.1.0",
17+
"karma-chrome-launcher": "^2.0.0",
18+
"karma-jasmine": "^1.0.2",
19+
"karma-webpack": "^1.8.0",
1320
"raw-loader": "^0.5.1",
1421
"style-loader": "^0.13.0",
1522
"ts-loader": "^0.8.1",

‎templates/Angular2Spa/tsd.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
},
1111
"es6-shim/es6-shim.d.ts": {
1212
"commit": "c0d876601e0f8236fd6b57626eb62c4e485f1563"
13+
},
14+
"chai/chai.d.ts": {
15+
"commit": "15d88ee05780bd6bbc4e376c5202b160895017f5"
16+
},
17+
"assertion-error/assertion-error.d.ts": {
18+
"commit": "15d88ee05780bd6bbc4e376c5202b160895017f5"
19+
},
20+
"jasmine/jasmine.d.ts": {
21+
"commit": "15d88ee05780bd6bbc4e376c5202b160895017f5"
1322
}
1423
}
1524
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Type definitions for assertion-error 1.0.0
2+
// Project: https://github.com/chaijs/assertion-error
3+
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
declare module 'assertion-error' {
7+
class AssertionError implements Error {
8+
constructor(message: string, props?: any, ssf?: Function);
9+
name: string;
10+
message: string;
11+
showDiff: boolean;
12+
stack: string;
13+
}
14+
export = AssertionError;
15+
}

0 commit comments

Comments
 (0)
This repository has been archived.