添加travis和saucelabs测试
This commit is contained in:
parent
1c55deb97c
commit
669a6aeab4
12
.travis.yml
Normal file
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
script:
|
||||
- npm run test:cov
|
||||
- npm run test:sauce
|
||||
after_script:
|
||||
- npm install coveralls && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
@ -43,7 +43,7 @@ sourceFileMap.filter(function (uri) {
|
||||
});
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
return {
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '',
|
||||
@ -122,5 +122,5 @@ module.exports = function(config) {
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
// 脚本调用请设为 true
|
||||
singleRun: true
|
||||
});
|
||||
};
|
||||
};
|
106
karma.conf.sauce.js
Normal file
106
karma.conf.sauce.js
Normal file
@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @file karma配置
|
||||
* @author fe.xiaowu@gmail.com
|
||||
*/
|
||||
|
||||
var base = require('./karma.conf.base.js');
|
||||
|
||||
var customLaunchers = {
|
||||
// Safari
|
||||
sl_ios_safari: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'Safari'
|
||||
},
|
||||
|
||||
// 安卓浏览器
|
||||
sl_android_4_4: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'android',
|
||||
version: '4.4'
|
||||
},
|
||||
sl_android_5: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'android',
|
||||
version: '5'
|
||||
},
|
||||
sl_android_6: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'android',
|
||||
version: '6'
|
||||
},
|
||||
|
||||
// chrome
|
||||
sl_ios_chrome: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'chrome'
|
||||
},
|
||||
|
||||
sl_ie_8: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 7',
|
||||
version: '8'
|
||||
},
|
||||
sl_ie_9: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 7',
|
||||
version: '9'
|
||||
},
|
||||
sl_ie_10: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 8',
|
||||
version: '10'
|
||||
},
|
||||
sl_ie_11: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 8.1',
|
||||
version: '11'
|
||||
},
|
||||
|
||||
sl_firefox: {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'firefox',
|
||||
platform: 'Windows 7'
|
||||
}
|
||||
};
|
||||
|
||||
// 不支持本地运行
|
||||
if (!process.env.TRAVIS) {
|
||||
console.error('不支持本地运行, 请使用 npm run test!');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 变量检查
|
||||
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
|
||||
console.error('---------------');
|
||||
console.error('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
|
||||
console.error('---------------');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
module.exports = function (config) {
|
||||
var options = Object.assign(base(config), {
|
||||
reporters: ['mocha', 'saucelabs'],
|
||||
sauceLabs: {
|
||||
'testName': 'layui test case',
|
||||
'recordVideo': false,
|
||||
'recordScreenshots': false,
|
||||
'startConnect': false,
|
||||
'connectOptions': {
|
||||
'no-ssl-bump-domains': 'all'
|
||||
},
|
||||
'public': 'public',
|
||||
'build': process.env.CIRCLE_BUILD_NUM || process.env.SAUCE_BUILD_ID || 'build-' + Date.now(),
|
||||
'tunnelIdentifier': process.env.TRAVIS_JOB_NUMBER
|
||||
},
|
||||
customLaunchers: customLaunchers,
|
||||
browsers: Object.keys(customLaunchers),
|
||||
captureTimeout: 1000 * 60 * 5,
|
||||
browserNoActivityTimeout: 1000 * 60 * 5
|
||||
});
|
||||
|
||||
config.set(options);
|
||||
};
|
14
karma.conf.unit.js
Normal file
14
karma.conf.unit.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file karma配置
|
||||
* @author fe.xiaowu@gmail.com
|
||||
*/
|
||||
|
||||
const base = require('./karma.conf.base.js');
|
||||
|
||||
module.exports = function(config) {
|
||||
const options = Object.assign(base(config), {
|
||||
|
||||
});
|
||||
|
||||
config.set(options);
|
||||
};
|
@ -5,8 +5,9 @@
|
||||
"main": "layui.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "karma start karma.conf.js",
|
||||
"test": "karma start karma.conf.unit.js",
|
||||
"test:cov": "npm test -- --reporters mocha,coverage",
|
||||
"test:sauce": "karma start karma.conf.sauce.js",
|
||||
"test:watch": "npm test -- --auto-watch --no-single-run"
|
||||
},
|
||||
"repository": {
|
||||
@ -32,6 +33,7 @@
|
||||
"karma-chai-sinon": "^0.1.5",
|
||||
"karma-coverage": "^1.1.1",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sauce-launcher": "^1.1.0",
|
||||
"karma-mocha-reporter": "^2.2.3",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"mocha": "^3.2.0",
|
||||
|
Loading…
Reference in New Issue
Block a user