Skip to content

Commit 263f99a

Browse files
committed
ci: replace grunt-saucelabs with karma
1 parent ecbcb1c commit 263f99a

File tree

3 files changed

+94
-6
lines changed

3 files changed

+94
-6
lines changed

karma.conf.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Karma configuration
2+
// Generated on Fri Apr 13 2018 13:53:08 GMT+0800 (CST)
3+
4+
module.exports = config => {
5+
const customLaunchers = {
6+
sl_chrome: {
7+
base: 'SauceLabs',
8+
browserName: 'chrome',
9+
version: '45',
10+
},
11+
sl_ios_safari: {
12+
base: 'SauceLabs',
13+
browserName: 'iPhone',
14+
version: '9.3',
15+
},
16+
};
17+
18+
config.set({
19+
// base path that will be used to resolve all patterns (eg. files, exclude)
20+
basePath: '',
21+
22+
// frameworks to use
23+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
24+
frameworks: ['mocha'],
25+
26+
client: {
27+
mocha: {
28+
ui: 'bdd',
29+
timeout: 30000,
30+
},
31+
},
32+
33+
// list of files / patterns to load in the browser
34+
files: ['test/browser/index.js'],
35+
36+
// list of files / patterns to exclude
37+
exclude: [],
38+
39+
// preprocess matching files before serving them to the browser
40+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
41+
preprocessors: {},
42+
43+
// test results reporter to use
44+
// possible values: 'dots', 'progress'
45+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
46+
reporters: ['progress', 'saucelabs'],
47+
48+
// web server port
49+
port: 9876,
50+
51+
// enable / disable colors in the output (reporters and logs)
52+
colors: true,
53+
54+
// level of logging
55+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
56+
logLevel: config.LOG_INFO,
57+
58+
// enable / disable watching file and executing tests whenever any file changes
59+
autoWatch: false,
60+
61+
sauceLabs: {
62+
testName: `LeanCloud Realtime SDK Test #${(
63+
process.env.TRAVIS_COMMIT || ''
64+
).slice(0, 7)}`,
65+
recordVideo: true,
66+
connectOptions: {
67+
noSslBumpDomains: 'all',
68+
logfile: 'sauce_connect.log',
69+
},
70+
},
71+
customLaunchers,
72+
captureTimeout: 480000,
73+
browserNoActivityTimeout: 120000,
74+
75+
// start these browsers
76+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
77+
browsers: Object.keys(customLaunchers),
78+
79+
// Continuous Integration mode
80+
// if true, Karma captures browsers, runs the tests and exits
81+
singleRun: true,
82+
83+
// Concurrency level
84+
// how many browser should be started simultaneous
85+
concurrency: 1,
86+
});
87+
};

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"npm run lint && npm run build && npm run docs && npm run test:node && npm run test:browser",
1717
"test:node":
1818
"NODE_ENV=test nyc mocha --timeout 30000 test/index.js plugins/**/test/index.js --exit",
19-
"test:browser": "npm run build:test && grunt test-browser --stack",
19+
"test:browser": "npm run build:test && karma start",
2020
"docs":
2121
"jsdoc src README.md package.json -d docs -c .jsdocrc.json && jsdoc plugins/typed-messages/src plugins/typed-messages/package.json src/messages/message.js src/messages/typed-message.js -d plugins/typed-messages/docs -c .jsdocrc.json && jsdoc plugins/webrtc/src plugins/webrtc/package.json -d plugins/webrtc/docs -c .jsdocrc.json && jsdoc plugins/groupchat-receipts/src plugins/groupchat-receipts/package.json -d plugins/groupchat-receipts/docs -c .jsdocrc.json",
2222
"build":
@@ -65,6 +65,10 @@
6565
"inherit": "^2.2.3",
6666
"jsdoc": "leeyeh/jsdoc#v3.4.0",
6767
"jsdoc-ignore-future": "^1.1.0",
68+
"karma": "^2.0.0",
69+
"karma-chrome-launcher": "^2.2.0",
70+
"karma-mocha": "^1.3.0",
71+
"karma-sauce-launcher": "^1.2.0",
6872
"leancloud-storage": "^3.0.0",
6973
"load-grunt-tasks": "^3.4.1",
7074
"mocha": "^5.0.0",
@@ -97,7 +101,6 @@
97101
},
98102
"browser": {
99103
"ws": "./src/polyfills/ws-browser.js",
100-
"sinon": false,
101104
"./dist/realtime.js": "./dist/realtime.browser.js",
102105
"./dist/realtime-core.js": "./dist/realtime-core.browser.js"
103106
},

test/test-utils.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export { default as sinon } from 'sinon';
2+
13
export const listen = (target, resolveEvent, rejectEvent) =>
24
new Promise((resolve, reject) => {
35
if (resolveEvent) target.once(resolveEvent, (...args) => resolve(args));
@@ -8,10 +10,6 @@ export const wait = time => new Promise(resolve => setTimeout(resolve, time));
810

911
export const hold = time => result => wait(time).then(() => result);
1012

11-
/* global window */
12-
export const sinon =
13-
(typeof window !== 'undefined' && window.sinon) || require('sinon');
14-
1513
export const series = promiseGens =>
1614
promiseGens.reduce(
1715
(m, p) => m.then(v => Promise.all([...v, p()])),

0 commit comments

Comments
 (0)