Merge pull request #4262 from strongloop/fix/ci
test: switch from PhantomJS to HeadlessChrome
This commit is contained in:
commit
af9f776ed0
14
.travis.yml
14
.travis.yml
|
@ -5,18 +5,10 @@ node_js:
|
||||||
- "10"
|
- "10"
|
||||||
- "12"
|
- "12"
|
||||||
|
|
||||||
|
addons:
|
||||||
|
chrome: stable
|
||||||
|
|
||||||
after_success: npm run coverage
|
after_success: npm run coverage
|
||||||
|
|
||||||
# see https://www.npmjs.com/package/phantomjs-prebuilt#continuous-integration
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- travis_phantomjs
|
|
||||||
before_install:
|
before_install:
|
||||||
- npm config set registry http://ci.strongloop.com:4873/
|
- npm config set registry http://ci.strongloop.com:4873/
|
||||||
# Upgrade PhantomJS to v2.1.1.
|
|
||||||
- "export PHANTOMJS_VERSION=2.1.1"
|
|
||||||
- "export PATH=$PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin:$PATH"
|
|
||||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; fi"
|
|
||||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then wget https://github.com/Medium/phantomjs/releases/download/v$PHANTOMJS_VERSION/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2; fi"
|
|
||||||
- "if [ $(phantomjs --version) != $PHANTOMJS_VERSION ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
|
|
||||||
- "phantomjs --version"
|
|
||||||
|
|
12
Gruntfile.js
12
Gruntfile.js
|
@ -31,11 +31,6 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
run: {
|
|
||||||
optionalInstall: {
|
|
||||||
exec: 'npm install --no-save --silent karma-phantomjs-launcher phantomjs-prebuilt',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
eslint: {
|
eslint: {
|
||||||
gruntfile: {
|
gruntfile: {
|
||||||
src: 'Gruntfile.js',
|
src: 'Gruntfile.js',
|
||||||
|
@ -109,7 +104,7 @@ module.exports = function(grunt) {
|
||||||
karma: {
|
karma: {
|
||||||
'unit-once': {
|
'unit-once': {
|
||||||
configFile: 'test/karma.conf.js',
|
configFile: 'test/karma.conf.js',
|
||||||
browsers: ['PhantomJS'],
|
browsers: ['ChromeDocker'],
|
||||||
singleRun: true,
|
singleRun: true,
|
||||||
reporters: ['dots', 'junit'],
|
reporters: ['dots', 'junit'],
|
||||||
|
|
||||||
|
@ -216,7 +211,6 @@ module.exports = function(grunt) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// These plugins provide necessary tasks.
|
// These plugins provide necessary tasks.
|
||||||
grunt.loadNpmTasks('grunt-run');
|
|
||||||
grunt.loadNpmTasks('grunt-browserify');
|
grunt.loadNpmTasks('grunt-browserify');
|
||||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
grunt.loadNpmTasks('grunt-eslint');
|
grunt.loadNpmTasks('grunt-eslint');
|
||||||
|
@ -242,14 +236,12 @@ module.exports = function(grunt) {
|
||||||
// Default task.
|
// Default task.
|
||||||
grunt.registerTask('default', ['browserify']);
|
grunt.registerTask('default', ['browserify']);
|
||||||
|
|
||||||
grunt.registerTask('phantomTests', ['run', 'karma:unit-once']);
|
|
||||||
|
|
||||||
grunt.registerTask('test', [
|
grunt.registerTask('test', [
|
||||||
'eslint',
|
'eslint',
|
||||||
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
|
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
|
||||||
process.env.JENKINS_HOME && (/^win/.test(process.platform) ||
|
process.env.JENKINS_HOME && (/^win/.test(process.platform) ||
|
||||||
/^s390x/.test(process.arch) || /^ppc64/.test(process.arch)) ?
|
/^s390x/.test(process.arch) || /^ppc64/.test(process.arch)) ?
|
||||||
'skip-karma' : 'phantomTests',
|
'skip-karma' : 'karma:unit-once',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// alias for sl-ci-run and `npm test`
|
// alias for sl-ci-run and `npm test`
|
||||||
|
|
|
@ -63,9 +63,7 @@
|
||||||
"underscore.string": "^3.3.5"
|
"underscore.string": "^3.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-preset-es2015": "^6.22.0",
|
"browserify": "^16.5.0",
|
||||||
"babelify": "^7.3.0",
|
|
||||||
"browserify": "^13.1.0",
|
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"cookie-parser": "^1.3.4",
|
"cookie-parser": "^1.3.4",
|
||||||
"coveralls": "^3.0.2",
|
"coveralls": "^3.0.2",
|
||||||
|
@ -82,7 +80,7 @@
|
||||||
"grunt-eslint": "^21.0.0",
|
"grunt-eslint": "^21.0.0",
|
||||||
"grunt-karma": "^3.0.2",
|
"grunt-karma": "^3.0.2",
|
||||||
"grunt-mocha-test": "^0.13.3",
|
"grunt-mocha-test": "^0.13.3",
|
||||||
"grunt-run": "^0.8.1",
|
"is-docker": "^2.0.0",
|
||||||
"karma": "^4.1.0",
|
"karma": "^4.1.0",
|
||||||
"karma-browserify": "^6.0.0",
|
"karma-browserify": "^6.0.0",
|
||||||
"karma-chrome-launcher": "^2.2.0",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
|
@ -100,7 +98,8 @@
|
||||||
"sinon-chai": "^3.2.0",
|
"sinon-chai": "^3.2.0",
|
||||||
"strong-error-handler": "^3.0.0",
|
"strong-error-handler": "^3.0.0",
|
||||||
"strong-task-emitter": "^0.0.8",
|
"strong-task-emitter": "^0.0.8",
|
||||||
"supertest": "^3.0.0"
|
"supertest": "^3.0.0",
|
||||||
|
"which": "^1.3.1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -3,12 +3,37 @@
|
||||||
// This file is licensed under the MIT License.
|
// This file is licensed under the MIT License.
|
||||||
// License text available at https://opensource.org/licenses/MIT
|
// License text available at https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const isDocker = require('is-docker');
|
||||||
|
const which = require('which');
|
||||||
|
|
||||||
// Karma configuration
|
// Karma configuration
|
||||||
// http://karma-runner.github.io/0.12/config/configuration-file.html
|
// http://karma-runner.github.io/0.12/config/configuration-file.html
|
||||||
|
|
||||||
'use strict';
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
|
// see https://github.com/docker/for-linux/issues/496
|
||||||
|
const disableChromeSandbox = isDocker() && !process.env.TRAVIS;
|
||||||
|
if (disableChromeSandbox) {
|
||||||
|
console.log('!! Disabling Chrome sandbox to support un-privileged Docker !!');
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasChromium =
|
||||||
|
which.sync('chromium-browser', {nothrow: true}) ||
|
||||||
|
which.sync('chromium', {nothrow: true});
|
||||||
|
|
||||||
config.set({
|
config.set({
|
||||||
|
customLaunchers: {
|
||||||
|
ChromeDocker: {
|
||||||
|
// cis-jenkins build server does not provide Chrome, only Chromium
|
||||||
|
base: hasChromium ? 'ChromiumHeadless' : 'ChromeHeadless',
|
||||||
|
// We must disable the Chrome sandbox when running Chrome inside Docker
|
||||||
|
// (Chrome's sandbox needs more permissions than Docker allows by default)
|
||||||
|
// See https://github.com/docker/for-linux/issues/496
|
||||||
|
flags: disableChromeSandbox ? ['--no-sandbox'] : [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
// enable / disable watching file and executing tests whenever any file changes
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
autoWatch: true,
|
autoWatch: true,
|
||||||
|
|
||||||
|
@ -64,7 +89,6 @@ module.exports = function(config) {
|
||||||
'karma-browserify',
|
'karma-browserify',
|
||||||
'karma-es6-shim',
|
'karma-es6-shim',
|
||||||
'karma-mocha',
|
'karma-mocha',
|
||||||
'karma-phantomjs-launcher',
|
|
||||||
'karma-chrome-launcher',
|
'karma-chrome-launcher',
|
||||||
'karma-junit-reporter',
|
'karma-junit-reporter',
|
||||||
],
|
],
|
||||||
|
@ -104,27 +128,18 @@ module.exports = function(config) {
|
||||||
'superagent',
|
'superagent',
|
||||||
'supertest',
|
'supertest',
|
||||||
],
|
],
|
||||||
transform: [
|
packageFilter: function(pkg, dir) {
|
||||||
['babelify', {
|
// async@3 (used e.g. by loopback-connector) is specifying custom
|
||||||
presets: [
|
// browserify config, in particular it wants to apply transformation
|
||||||
['es2015', {
|
// `babelify`. We don't have `babelify` installed because we are
|
||||||
// Disable transform-es2015-modules-commonjs which adds
|
// testing using latest Chrome and thus don't need any transpilation.
|
||||||
// "use strict" to all files, even those that don't work
|
// Let's remove the browserify config from the package and force
|
||||||
// in strict mode
|
// browserify to use our config instead.
|
||||||
// (e.g. chai, loopback-datasource-juggler, etc.)
|
if (pkg.name === 'async') {
|
||||||
modules: false,
|
delete pkg.browserify;
|
||||||
}],
|
}
|
||||||
],
|
return pkg;
|
||||||
// By default, browserify does not transform node_modules
|
},
|
||||||
// As a result, our dependencies like strong-remoting and juggler
|
|
||||||
// are kept in original ES6 form that does not work in PhantomJS
|
|
||||||
global: true,
|
|
||||||
// Prevent SyntaxError in strong-task-emitter:
|
|
||||||
// strong-task-emitter/lib/task.js (83:4):
|
|
||||||
// arguments is a reserved word in strict mode
|
|
||||||
ignore: /node_modules\/(strong-task-emitter)\//,
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
debug: true,
|
debug: true,
|
||||||
// noParse: ['jquery'],
|
// noParse: ['jquery'],
|
||||||
watch: true,
|
watch: true,
|
||||||
|
|
Loading…
Reference in New Issue