-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(test): setup karma test runner against chrome browser #1007
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Karma configuration | ||
// Generated on Tue Dec 08 2015 23:01:01 GMT-0800 (Pacific Standard Time) | ||
|
||
module.exports = function (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: ['browserify', 'jasmine'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
'spec/helpers/marble-testing.js', | ||
'spec/helpers/test-helper.js', | ||
'spec/**/*-spec.js' | ||
], | ||
|
||
// list of files to exclude | ||
exclude: [ | ||
], | ||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'spec/**/*.js': ['browserify'] | ||
}, | ||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: ['progress'], | ||
|
||
// 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: ['Chrome'], | ||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultanous | ||
concurrency: 1 | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//Fail timeouts faster | ||
//Individual suites/specs should specify longer timeouts if needed. | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. timeout interval is increased to safely executed under browser. |
||
|
||
var _ = require('lodash'); | ||
var root = require('../../dist/cjs/util/root').root; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,24 +109,49 @@ describe('Observable.fromPromise', function () { | |
}); | ||
}); | ||
|
||
it('should globally throw unhandled errors', function (done) { | ||
var invoked = false; | ||
process.on('uncaughtException', function (reason, p) { | ||
if (invoked) { | ||
return; | ||
} | ||
invoked = true; | ||
expect(reason).toBe('fail'); | ||
done(); | ||
if (typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]') { | ||
it('should globally throw unhandled errors on process', function (done) { | ||
var invoked = false; | ||
process.on('uncaughtException', function (reason, p) { | ||
if (invoked) { | ||
return; | ||
} | ||
invoked = true; | ||
expect(reason).toBe('fail'); | ||
done(); | ||
}); | ||
|
||
Observable.fromPromise(Promise.reject('bad')) | ||
.subscribe( | ||
done.fail, | ||
function (e) { | ||
expect(e).toBe('bad'); | ||
throw 'fail'; | ||
}, | ||
done.fail); | ||
}); | ||
} else if (typeof window === 'object' && Object.prototype.toString.call(window) === '[object global]') { | ||
it('should globally throw unhandled errors on window', function (done) { | ||
var invoked = false; | ||
function onException(e) { | ||
if (invoked) { | ||
return; | ||
} | ||
invoked = true; | ||
expect(e).toBe('Uncaught fail'); | ||
done(); | ||
} | ||
|
||
Observable.fromPromise(Promise.reject('bad')) | ||
.subscribe( | ||
done.fail, | ||
function (e) { | ||
expect(e).toBe('bad'); | ||
throw 'fail'; | ||
}, | ||
done.fail); | ||
}); | ||
window.onerror = onException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. used
happens same in Karma makes think global error is uncaught. I'm feeling I missed some obvious thing and did some dumb thing with code snippet.. :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's right! I was thinking to myself when I was writing that I had learned Good find. |
||
|
||
Observable.fromPromise(Promise.reject('bad')) | ||
.subscribe( | ||
done.fail, | ||
function (e) { | ||
expect(e).toBe('bad'); | ||
throw 'fail'; | ||
}, | ||
done.fail); | ||
}); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to resolve commonjs lookup, using
karma--browserify
to bundling modules. there iskarma-commonjs
does job without bundling, but has some issues of resolving node_modules (karma-runner/karma-commonjs#29) blocks adaptation.