Skip to content

Commit 7425a5f

Browse files
committed
Replaced karma/jasmine with mocha/chai for faster testing
1 parent 319f7a0 commit 7425a5f

15 files changed

+201
-211
lines changed

gulpfile.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ gulp.task('exceptionless.test.umd', ['typescript.test'], function () {
116116
});
117117

118118
gulp.task('test', ['exceptionless.test.umd'], function(done) {
119-
var Server = require('karma').Server;
120-
new Server({
121-
configFile: __dirname + '/karma.conf.js'
122-
}, done).start();
119+
var mocha = require('gulp-mocha');
120+
return gulp.src('dist/temp/exceptionless-spec.js', { read: false })
121+
.pipe(mocha({
122+
require: ['source-map-support/register']
123+
}))
124+
.once('end', function () {
125+
process.exit();
126+
});
123127
});
124128

125129
gulp.task('format', function () {

karma.conf.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,21 @@
2727
},
2828
"devDependencies": {
2929
"bower": "1.6.5",
30+
"chai": "^3.4.1",
3031
"del": "2.1.0",
3132
"es5-shim": "4.3.1",
3233
"es6-shim": "0.33.13",
3334
"gulp": "3.9.0",
3435
"gulp-concat": "2.6.0",
3536
"gulp-exec": "^2.1.2",
37+
"gulp-mocha": "^2.2.0",
3638
"gulp-replace": "0.5.4",
3739
"gulp-sourcemaps": "1.6.0",
3840
"gulp-tslint": "3.6.0",
3941
"gulp-uglify": "1.5.1",
4042
"gulp-wrap-umd": "0.2.1",
41-
"jasmine-core": "2.3.4",
42-
"karma": "0.13.15",
43-
"karma-chrome-launcher": "^0.2.1",
44-
"karma-cli": "0.1.1",
45-
"karma-jasmine": "0.3.6",
46-
"karma-phantomjs-launcher": "0.2.1",
47-
"phantomjs": "^1.9.18",
4843
"rimraf": "2.4.3",
44+
"source-map-support": "^0.3.3",
4945
"tracekit": "0.3.1",
5046
"tsproject": "1.0.5",
5147
"typescript": "1.6.2",

src/ExceptionlessClient-spec.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
import { ExceptionlessClient } from './ExceptionlessClient';
22
import { EventPluginContext } from './plugins/EventPluginContext';
3+
import { expect } from 'chai';
34

45
describe('ExceptionlessClient', () => {
56
it('should use event reference ids', (done) => {
67
let error = new Error('From Unit Test');
78

89
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
9-
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
10+
expect(client.config.lastReferenceIdManager.getLast()).to.be.null;
1011
client.submitException(error, (context: EventPluginContext) => {
11-
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
12+
expect(client.config.lastReferenceIdManager.getLast()).to.be.null;
1213
});
1314

1415
let numberOfPlugins = client.config.plugins.length;
1516
client.config.useReferenceIds();
16-
expect(client.config.plugins.length).toBe(numberOfPlugins + 1);
17+
expect(client.config.plugins.length).to.equal(numberOfPlugins + 1);
1718

1819
client.submitException(error, (context: EventPluginContext) => {
1920
if (!context.cancelled) {
20-
expect(client.config.lastReferenceIdManager.getLast()).not.toBe(null);
21+
expect(client.config.lastReferenceIdManager.getLast()).not.to.be.null;
2122
} else {
22-
expect(client.config.lastReferenceIdManager.getLast()).toBe(null);
23+
expect(client.config.lastReferenceIdManager.getLast()).to.be.null;
2324
}
2425

2526
done();
27+
done = () => { };
2628
});
27-
}, 5000);
29+
});
2830

2931
it('should accept null source', () => {
3032
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
3133
let builder = client.createLog(null, 'Unit Test message', 'Trace');
3234

33-
expect(builder.target.source).toBeUndefined();
34-
expect(builder.target.message).toBe('Unit Test message');
35-
expect(builder.target.data['@level']).toBe('Trace');
35+
expect(builder.target.source).to.be.undefined;
36+
expect(builder.target.message).to.equal('Unit Test message');
37+
expect(builder.target.data['@level']).to.equal('Trace');
3638
});
3739

3840
it('should accept source and message', () => {
3941
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
4042
let builder = client.createLog('ExceptionlessClient', 'Unit Test message');
4143

42-
expect(builder.target.source).toBe('ExceptionlessClient');
43-
expect(builder.target.message).toBe('Unit Test message');
44-
expect(builder.target.data).toBeUndefined();
44+
expect(builder.target.source).to.equal('ExceptionlessClient');
45+
expect(builder.target.message).to.equal('Unit Test message');
46+
expect(builder.target.data).to.be.undefined;
4547
});
4648

4749
it('should accept source and message', () => {
4850
let client = new ExceptionlessClient('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', 'http://localhost:50000');
4951
let builder = client.createLog('Unit Test message');
5052

51-
expect(builder.target.source).toBeUndefined();
52-
expect(builder.target.message).toBe('Unit Test message');
53-
expect(builder.target.data).toBeUndefined();
53+
expect(builder.target.source).to.be.undefined;
54+
expect(builder.target.message).to.equal('Unit Test message');
55+
expect(builder.target.data).to.be.undefined;
5456
});
5557
});

src/Utils-spec.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { Utils } from './Utils';
2+
import { expect } from 'chai';
23

34
describe('Utils', () => {
45
it('should add range', () => {
56
let target: string[];
6-
expect(Utils.addRange(target)).toEqual([]);
7-
expect(target).toBeUndefined();
7+
expect(Utils.addRange(target)).to.eql([]);
8+
expect(target).to.be.undefined;
89

9-
expect(Utils.addRange(target, '1', '2')).toEqual(['1', '2']);
10-
expect(Utils.addRange(target, '1', '2')).toEqual(['1', '2']);
10+
expect(Utils.addRange(target, '1', '2')).to.eql(['1', '2']);
11+
expect(Utils.addRange(target, '1', '2')).to.eql(['1', '2']);
1112

1213
target = ['3'];
13-
expect(Utils.addRange(target, '1', '2')).toEqual(['3', '1', '2']);
14-
expect(target).toEqual(['3', '1', '2']);
14+
expect(Utils.addRange(target, '1', '2')).to.eql(['3', '1', '2']);
15+
expect(target).to.eql(['3', '1', '2']);
1516
});
1617

1718
describe('stringify', () => {
@@ -61,53 +62,53 @@ describe('Utils', () => {
6162
'tags': []
6263
};
6364

64-
expect(Utils.stringify(error)).toBe(JSON.stringify(error));
65-
expect(Utils.stringify([error, error])).toBe(JSON.stringify([error, error]));
65+
expect(Utils.stringify(error)).to.equal(JSON.stringify(error));
66+
expect(Utils.stringify([error, error])).to.equal(JSON.stringify([error, error]));
6667
});
6768

6869
it('circular reference', () => {
6970
let afoo: any = { a: 'foo' };
7071
afoo.b = afoo;
7172

72-
expect(Utils.stringify(afoo)).toBe('{"a":"foo"}');
73-
expect(Utils.stringify([{ one: afoo, two: afoo }])).toBe('[{"one":{"a":"foo"}}]');
73+
expect(Utils.stringify(afoo)).to.equal('{"a":"foo"}');
74+
expect(Utils.stringify([{ one: afoo, two: afoo }])).to.equal('[{"one":{"a":"foo"}}]');
7475
});
7576

7677
it('should behave like JSON.stringify', () => {
77-
expect(Utils.stringify(user)).toBe(JSON.stringify(user));
78+
expect(Utils.stringify(user)).to.equal(JSON.stringify(user));
7879
});
7980

8081
describe('with exclude pattern', () => {
8182
it('pAssword', () => {
82-
expect(Utils.stringify(user, ['pAssword'])).toBe('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}');
83+
expect(Utils.stringify(user, ['pAssword'])).to.equal('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}');
8384
});
8485

8586
it('*password', () => {
86-
expect(Utils.stringify(user, ['*password'])).toBe('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}');
87+
expect(Utils.stringify(user, ['*password'])).to.equal('{"id":1,"name":"Blake","passwordResetToken":"a reset token","myPasswordValue":"123456","customValue":"Password","value":{}}');
8788
});
8889

8990
it('password*', () => {
90-
expect(Utils.stringify(user, ['password*'])).toBe('{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}');
91+
expect(Utils.stringify(user, ['password*'])).to.equal('{"id":1,"name":"Blake","myPasswordValue":"123456","myPassword":"123456","customValue":"Password","value":{}}');
9192
});
9293

9394
it('*password*', () => {
94-
expect(Utils.stringify(user, ['*password*'])).toBe('{"id":1,"name":"Blake","customValue":"Password","value":{}}');
95+
expect(Utils.stringify(user, ['*password*'])).to.equal('{"id":1,"name":"Blake","customValue":"Password","value":{}}');
9596
});
9697

9798
it('*Address', () => {
9899
let event = { type: 'usage', source: 'about' };
99-
expect(Utils.stringify(event, ['*Address'])).toBe(JSON.stringify(event));
100+
expect(Utils.stringify(event, ['*Address'])).to.equal(JSON.stringify(event));
100101
});
101102
});
102103
});
103104

104105
it('should parse version from url', () => {
105-
expect(Utils.parseVersion('https://code.jquery.com/jquery-2.1.3.js')).toBe('2.1.3');
106-
expect(Utils.parseVersion('//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css')).toBe('3.3.4');
107-
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css')).toBe('2.0');
108-
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.min.js')).toBe('0.3.0');
109-
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/angular-google-maps/2.1.0-X.10/angular-google-maps.min.js')).toBe('2.1.0-X.10');
110-
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/2.1.8-M1/swagger-ui.min.js')).toBe('2.1.8-M1');
111-
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/BLAH/BLAH.min.js')).toBe(null);
106+
expect(Utils.parseVersion('https://code.jquery.com/jquery-2.1.3.js')).to.equal('2.1.3');
107+
expect(Utils.parseVersion('//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css')).to.equal('3.3.4');
108+
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.css')).to.equal('2.0');
109+
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.min.js')).to.equal('0.3.0');
110+
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/angular-google-maps/2.1.0-X.10/angular-google-maps.min.js')).to.equal('2.1.0-X.10');
111+
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/2.1.8-M1/swagger-ui.min.js')).to.equal('2.1.8-M1');
112+
expect(Utils.parseVersion('https://cdnjs.cloudflare.com/BLAH/BLAH.min.js')).to.equal(null);
112113
});
113114
});
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,64 @@
11
import { Configuration } from './Configuration';
22
import { EventPluginContext } from '../plugins/EventPluginContext';
3+
import { expect } from 'chai';
34

45
describe('Configuration', () => {
56
it('should override configuration defaults', () => {
67
let config = new Configuration();
7-
expect(config.apiKey).toBe(null);
8+
expect(config.apiKey).to.equal(null);
89

910
config.apiKey = 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw';
10-
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
11+
expect(config.apiKey).to.equal('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
1112

1213
Configuration.defaults.apiKey = 'test';
1314
config = new Configuration();
14-
expect(config.apiKey).toBe('test');
15+
expect(config.apiKey).to.equal('test');
1516

1617
config = new Configuration({ apiKey: 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl: 'http://localhost:50000' });
17-
expect(config.apiKey).toBe('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
18+
expect(config.apiKey).to.equal('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
1819

1920
config = new Configuration({ apiKey: null });
20-
expect(config.apiKey).toBe('test');
21+
expect(config.apiKey).to.equal('test');
2122
});
2223

2324
it('should not add duplicate plugin', () => {
2425
let config = new Configuration({ apiKey: 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl: 'http://localhost:50000' });
25-
expect(config.plugins).not.toBe(null);
26+
expect(config.plugins).not.to.equal(null);
2627
while (config.plugins.length > 0) {
2728
config.removePlugin(config.plugins[0]);
2829
}
2930

3031
config.addPlugin('test', 20, (context: EventPluginContext) => { });
3132
config.addPlugin('test', 20, (context: EventPluginContext) => { });
32-
expect(config.plugins.length).toBe(1);
33+
expect(config.plugins.length).to.equal(1);
3334
});
3435

3536
it('should generate plugin name and priority', () => {
3637
let config = new Configuration({ apiKey: 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl: 'http://localhost:50000' });
37-
expect(config.plugins).not.toBe(null);
38+
expect(config.plugins).not.to.equal(null);
3839
while (config.plugins.length > 0) {
3940
config.removePlugin(config.plugins[0]);
4041
}
4142

4243
config.addPlugin(null, null, (context: EventPluginContext) => { });
43-
expect(config.plugins.length).toBe(1);
44-
expect(config.plugins[0].name).not.toBe(null);
45-
expect(config.plugins[0].priority).toBe(0);
44+
expect(config.plugins.length).to.equal(1);
45+
expect(config.plugins[0].name).not.to.equal(null);
46+
expect(config.plugins[0].priority).to.equal(0);
4647
});
4748

4849
it('should sort plugins by priority', () => {
4950
let config = new Configuration({ apiKey: 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw', serverUrl: 'http://localhost:50000' });
50-
expect(config.plugins).not.toBe(null);
51+
expect(config.plugins).not.to.equal(null);
5152
while (config.plugins.length > 0) {
5253
config.removePlugin(config.plugins[0]);
5354
}
5455

5556
config.addPlugin('3', 3, (context: EventPluginContext) => { });
5657
config.addPlugin('1', 1, (context: EventPluginContext) => { });
5758
config.addPlugin('2', 2, (context: EventPluginContext) => { });
58-
expect(config.plugins.length).toBe(3);
59-
expect(config.plugins[0].priority).toBe(1);
60-
expect(config.plugins[1].priority).toBe(2);
61-
expect(config.plugins[2].priority).toBe(3);
59+
expect(config.plugins.length).to.equal(3);
60+
expect(config.plugins[0].priority).to.equal(1);
61+
expect(config.plugins[1].priority).to.equal(2);
62+
expect(config.plugins[2].priority).to.equal(3);
6263
});
6364
});
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Configuration } from './Configuration';
22
import { SettingsManager } from './SettingsManager';
3+
import { expect } from 'chai';
34

45
describe('SettingsManager', () => {
56
it('should call changed handler', (done) => {
67
SettingsManager.onChanged((configuration: Configuration) => {
7-
expect(configuration.settings).toBeDefined();
8+
expect(configuration.settings).not.to.be.undefined;
89
done();
10+
done = () => { };
911
});
1012

1113
let config = new Configuration('LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw');
1214
SettingsManager.applySavedServerSettings(config);
13-
}, 250);
15+
});
1416
});

0 commit comments

Comments
 (0)