Skip to content

Commit d69b175

Browse files
committed
chore(test): setup karma test runner against chrome browser
- initial bootstrap config for karma runner against chrome - ci server is not configured yet relates to ReactiveX#998
1 parent d22a14d commit d69b175

File tree

4 files changed

+110
-20
lines changed

4 files changed

+110
-20
lines changed

karma.conf.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Karma configuration
2+
// Generated on Tue Dec 08 2015 23:01:01 GMT-0800 (Pacific Standard Time)
3+
4+
module.exports = function (config) {
5+
config.set({
6+
7+
// base path that will be used to resolve all patterns (eg. files, exclude)
8+
basePath: '',
9+
10+
// frameworks to use
11+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
12+
frameworks: ['browserify', 'jasmine'],
13+
14+
// list of files / patterns to load in the browser
15+
files: [
16+
'spec/helpers/marble-testing.js',
17+
'spec/helpers/test-helper.js',
18+
'spec/**/*-spec.js'
19+
],
20+
21+
// list of files to exclude
22+
exclude: [
23+
],
24+
25+
// preprocess matching files before serving them to the browser
26+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
27+
preprocessors: {
28+
'spec/**/*.js': ['browserify']
29+
},
30+
31+
// test results reporter to use
32+
// possible values: 'dots', 'progress'
33+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
34+
reporters: ['progress'],
35+
36+
// web server port
37+
port: 9876,
38+
39+
// enable / disable colors in the output (reporters and logs)
40+
colors: true,
41+
42+
// level of logging
43+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
44+
logLevel: config.LOG_INFO,
45+
46+
// enable / disable watching file and executing tests whenever any file changes
47+
autoWatch: false,
48+
49+
// start these browsers
50+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
51+
browsers: ['Chrome'],
52+
53+
// Continuous Integration mode
54+
// if true, Karma captures browsers, runs the tests and exits
55+
singleRun: true,
56+
57+
// Concurrency level
58+
// how many browser should be started simultanous
59+
concurrency: 1
60+
});
61+
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,13 @@
9898
"istanbul": "0.3.22",
9999
"jasmine": "2.4.1",
100100
"jasmine-core": "2.4.1",
101+
"karma": "0.13.15",
102+
"karma-browserify": "4.4.2",
103+
"karma-chrome-launcher": "0.2.2",
104+
"karma-jasmine": "0.3.6",
101105
"lodash": "3.10.1",
102-
"markdown-doctest": "^0.3.0",
103106
"madge": "^0.5.3",
107+
"markdown-doctest": "^0.3.0",
104108
"mkdirp": "^0.5.1",
105109
"platform": "1.3.0",
106110
"promise": "7.0.3",

spec/helpers/test-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//Fail timeouts faster
22
//Individual suites/specs should specify longer timeouts if needed.
3-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
3+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
44

55
var _ = require('lodash');
66
var root = require('../../dist/cjs/util/root').root;

spec/observables/from-promise-spec.js

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,49 @@ describe('Observable.fromPromise', function () {
109109
});
110110
});
111111

112-
it('should globally throw unhandled errors', function (done) {
113-
var invoked = false;
114-
process.on('uncaughtException', function (reason, p) {
115-
if (invoked) {
116-
return;
117-
}
118-
invoked = true;
119-
expect(reason).toBe('fail');
120-
done();
112+
if (typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]') {
113+
it('should globally throw unhandled errors on process', function (done) {
114+
var invoked = false;
115+
process.on('uncaughtException', function (reason, p) {
116+
if (invoked) {
117+
return;
118+
}
119+
invoked = true;
120+
expect(reason).toBe('fail');
121+
done();
122+
});
123+
124+
Observable.fromPromise(Promise.reject('bad'))
125+
.subscribe(
126+
done.fail,
127+
function (e) {
128+
expect(e).toBe('bad');
129+
throw 'fail';
130+
},
131+
done.fail);
121132
});
133+
} else if (typeof window === 'object' && Object.prototype.toString.call(window) === '[object global]') {
134+
it('should globally throw unhandled errors on window', function (done) {
135+
var invoked = false;
136+
function onException(e) {
137+
if (invoked) {
138+
return;
139+
}
140+
invoked = true;
141+
expect(e).toBe('Uncaught fail');
142+
done();
143+
}
122144

123-
Observable.fromPromise(Promise.reject('bad'))
124-
.subscribe(
125-
done.fail,
126-
function (e) {
127-
expect(e).toBe('bad');
128-
throw 'fail';
129-
},
130-
done.fail);
131-
});
145+
window.onerror = onException;
146+
147+
Observable.fromPromise(Promise.reject('bad'))
148+
.subscribe(
149+
done.fail,
150+
function (e) {
151+
expect(e).toBe('bad');
152+
throw 'fail';
153+
},
154+
done.fail);
155+
});
156+
}
132157
});

0 commit comments

Comments
 (0)