From 23bbe890891b318b2d2b9741d37ed364340294ba Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 9 Dec 2015 00:02:34 -0800 Subject: [PATCH] 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 #998 --- karma.conf.js | 61 +++++++++++++++++++++++++++ package.json | 6 ++- spec/helpers/test-helper.js | 2 +- spec/observables/from-promise-spec.js | 43 ++++++++++--------- 4 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 karma.conf.js diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..d8ab9440ae --- /dev/null +++ b/karma.conf.js @@ -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 + }); +}; diff --git a/package.json b/package.json index 49d30e67b3..107b432334 100644 --- a/package.json +++ b/package.json @@ -98,9 +98,13 @@ "istanbul": "0.3.22", "jasmine": "2.4.1", "jasmine-core": "2.4.1", + "karma": "0.13.15", + "karma-browserify": "4.4.2", + "karma-chrome-launcher": "0.2.2", + "karma-jasmine": "0.3.6", "lodash": "3.10.1", - "markdown-doctest": "^0.3.0", "madge": "^0.5.3", + "markdown-doctest": "^0.3.0", "mkdirp": "^0.5.1", "platform": "1.3.0", "promise": "7.0.3", diff --git a/spec/helpers/test-helper.js b/spec/helpers/test-helper.js index bf8e90849a..881a713e45 100644 --- a/spec/helpers/test-helper.js +++ b/spec/helpers/test-helper.js @@ -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; var _ = require('lodash'); var root = require('../../dist/cjs/util/root').root; diff --git a/spec/observables/from-promise-spec.js b/spec/observables/from-promise-spec.js index eee5a15a02..c0cb5e4d31 100644 --- a/spec/observables/from-promise-spec.js +++ b/spec/observables/from-promise-spec.js @@ -1,6 +1,9 @@ /* globals describe, it, expect */ var Rx = require('../../dist/cjs/Rx'); var Observable = Rx.Observable; +var isNode = typeof process === 'object' && + process + '' === '[object process]' && + typeof window === 'undefined'; describe('Observable.fromPromise', function () { it('should emit one value from a resolved promise', function (done) { @@ -109,24 +112,26 @@ 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 (isNode) { + it('should globally throw unhandled errors on node', 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); - }); + Observable.fromPromise(Promise.reject('bad')) + .subscribe( + done.fail, + function (e) { + expect(e).toBe('bad'); + throw 'fail'; + }, + done.fail); + }); + } }); \ No newline at end of file