Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request prebid#159 from CRAFT/feature/PLMP-261-test-saucelabs
Browse files Browse the repository at this point in the history
Feature/PLMP-261 running unit test on saucelabs
  • Loading branch information
vzhukovsky authored and GitHub Enterprise committed Jun 20, 2018
2 parents 3f79534 + 0755686 commit c3c42ad
Show file tree
Hide file tree
Showing 6 changed files with 690 additions and 38 deletions.
21 changes: 1 addition & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,7 @@ dist: trusty
language: node_js
node_js:
- '7.0'
env:
- BROWSERSTACK_USERNAME=info184
addons:
chrome: stable,
browserstack:
username: info184
access_key:
secure: Ru286R4pMcEIRKwb2AoaaJY6lEKIzeZraxY7CtbOP4ykNk7uqsnyitk4QwxpCCh0n35b71m30okW6ZmZnl0lJXhOMdYoSOYBAnUw2Vn7Y93oMSKIC5dc2/qmtF1t2b1qX65/Ont2iJUj+UY8VQw5Hk2vIT4/5wifYPBnV5ILK4AI7SVk/ma7OzK4rkp3WThlouddctAd7tx4O3YIyJKDi9lkfcMA0pnH4OZSOlDClRLIy50Q1NE+iyqHtWFZK1TwJ+IhQbSsCLbuyQJBRnyJJEftNmtrs5MCZt/9pwFDj7c8+o11F6HCsTBYFkehFRfbKnmhCc1G+bsNXY8OxIWwEHeuVmSGK7TDPYcPPQBc03mcQ1fY/IPNQOdsVJ/n8RsG2u0IU2CF2hhkuNFzeov7dOHljanc45NKOrLdjwzP1aZCAUvLquOTzvmdF23nJhMs8UO+Du4kTK5VfmKyz1MC91E40a0Q15+O4qmS39rNOlwhxPJSfuxxL1jKVPJ7PsFbTkGM8M/XPJ6dyGLufy225HjdLdJTAOa5BZ4st+nXH/AzqHzy6a2I5vTmAz1j4gHLgVU+iNxAkX8znb25s3Rs1ZuFVj+aBSBmNoQA1FA5f/uXWeruTdDig7ksp+XdjsjLm9Md8cWwYaEn04FYj1ztJrylrEMfnc0Kcs6zQ3fll1g=
before_install:
- npm install -g gulp
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
script: |-
if [[ ${TRAVIS_PULL_REQUEST} == "false" ]]; then
gulp test --browserstack
else
gulp run-tests
fi
notifications:
slack:
on_success: never
on_failure: always
on_pull_requests: false
secure: C4O77VtABLE5DiPDeKGqUcsBdTBMNjQRLc8iBfSp231e95K1rA/JXJJEQN/lVhhiFJyPhxueE0i6cR0zD8uAMC8HRShGGfPjEZ7f6glawPzap2wFwjAyVkknYV+BMKcX0jvn7CiSKBj+zTbHQfn/Uj3nMSbDZQIdbNDiFGh4NuDr3/Yd/efhsw/miExlSPSWqGVCKV3WPpTrU3BRpLNDq4sZMXP9ORZxGK7ER3tsMiD2z05YpvC+mibESJxaY0qsuQu1y1Gu65QLPe5ocw405btJwqYn+b4YFpUd2GbLNhjtLzsc+OKrD0DWuEI0bxePQUYDga5wR6g4cdZaXU3ixDjee7sJbDeVJAuykGlfZ4A1k+fQIgPs3s9XMHaeG9AfDhFiZ/UoNdonzos1iSa/Y1TzHIXp1wnbHKT5HUWWPFNb5PzJxHEtHbm3jwOH4iK8VAq94ec16M2aqUAj7muiqcrTlYa5rs6jRlXo/TRymFnbQRdBT7eLmLNDQD35yR1Y+4mxHqKi+3189yG9RE+uwIlB+9HZFgNbioOApB+jarKC6M0qEgn0bHxkpJBP8JmNCA84U0ZUzyPvuMGsRbisAmKoUsU8C6cq59QDfBTcCTvKXK6r+6f23iRGieoGSbTxYQj46QkykpbWU0WstQDQsZL3L316uZecOVZmWKBRxPs=
gulp test-unit-cloud
6 changes: 6 additions & 0 deletions browsers.saucelabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sl_chrome": {
"base": "SauceLabs",
"browserName": "chrome"
}
}
45 changes: 29 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var sourcemaps = require('gulp-sourcemaps');
var through = require('through2');
var fs = require('fs');
var jsEscape = require('gulp-js-escape');
const karmaConfigProvider = require('./karmaConfigProvider');

var prebid = require('./package.json');
var banner = '/* <%= prebid.name %> v<%= prebid.version %>*/\n';
Expand Down Expand Up @@ -177,22 +178,6 @@ gulp.task('webpack', ['clean'], function () {
.pipe(connect.reload());
});

gulp.task('build-aol-bundle', ['build-bundle-dev'], () => {
return gulp.src('build/dev/prebid.js')
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER BEGIN \w+\*\/)/g, '$1window=window;'))
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER END \w+\*\/)/g, '$1window=window;'))
.pipe(uglify({
output: {
comments: /^!/
}
}))
.pipe(optimizejs())
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER BEGIN \w+\*\/)\s*window=window(;|,)?/g, '$1'))
.pipe(replace(/(,)?(\/\*!(ANALYTICS\s)?ADAPTER END \w+\*\/)\s*window=window(;|,)?/g, ';$2'))
.pipe(header(banner, { prebid: prebid }))
.pipe(gulp.dest('build/dist'));
});

// Run the unit tests.
//
// By default, this runs in headless chrome.
Expand Down Expand Up @@ -338,4 +323,32 @@ gulp.task('escape-postbid-config', function() {
.pipe(gulp.dest('build/postbid/'));
});

gulp.task('build-aol-bundle', ['build-bundle-dev'], () => {
return gulp.src('build/dev/prebid.js')
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER BEGIN \w+\*\/)/g, '$1window=window;'))
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER END \w+\*\/)/g, '$1window=window;'))
.pipe(uglify({
output: {
comments: /^!/
}
}))
.pipe(optimizejs())
.pipe(replace(/(\/\*!(ANALYTICS\s)?ADAPTER BEGIN \w+\*\/)\s*window=window(;|,)?/g, '$1'))
.pipe(replace(/(,)?(\/\*!(ANALYTICS\s)?ADAPTER END \w+\*\/)\s*window=window(;|,)?/g, ';$2'))
.pipe(header(banner, { prebid: prebid }))
.pipe(gulp.dest('build/dist'));
});

gulp.task('test-unit', ['clean'], function (done) {
new KarmaServer(karmaConfigProvider.generateDefaultConfig(), newKarmaCallback(done)).start();
});

gulp.task('test-unit-cloud', ['clean'], function (done) {
if (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) {
done('Make sure the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are set.');
} else {
new KarmaServer(karmaConfigProvider.generateSaucelabsConfig(), newKarmaCallback(done)).start();
}
});

module.exports = nodeBundle;
72 changes: 72 additions & 0 deletions karmaConfigProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const webpackConfig = require('./webpack.conf');
const browsers = require('./browsers.saucelabs');

const BROWSER_TIMEOUTS = {
DISCONNECT: 10000,
NO_ACTIVITY: 240000
};

const BROWSER_DISCONNECT_TOLERANCE = 1;

module.exports = {
generateDefaultConfig () {
return {
basePath: './',

webpack: Object.assign(webpackConfig, {
plugins: []
}),
webpackMiddleware: {
noInfo: true
},

files: ['test/test_index.js'],
frameworks: ['es5-shim', 'mocha', 'chai', 'sinon'],
preprocessors: {
'test/test_index.js': ['webpack', 'sourcemap']
},

singleRun: true,
reporters: ['mocha'],
browsers: ['ChromeHeadless'],

plugins: [
'karma-chrome-launcher',
'karma-coverage-istanbul-reporter',
'karma-es5-shim',
'karma-mocha',
'karma-chai',
'karma-requirejs',
'karma-sinon',
'karma-sourcemap-loader',
'karma-spec-reporter',
'karma-junit-reporter',
'karma-webpack',
'karma-mocha-reporter'
],

browserDisconnectTimeout:BROWSER_TIMEOUTS.DISCONNECT,
browserNoActivityTimeout: BROWSER_TIMEOUTS.NO_ACTIVITY,
captureTimeout: BROWSER_TIMEOUTS.NO_ACTIVITY,

browserDisconnectTolerance: BROWSER_DISCONNECT_TOLERANCE
}
},

generateSaucelabsConfig() {
let baseConfig = this.generateDefaultConfig();

return Object.assign(baseConfig, {
sauceLabs: {
testName: 'Prebid unit tests'
},

customLaunchers: browsers,
browsers: Object.keys(browsers),

reporters: baseConfig.reporters.concat(['saucelabs']),

plugins: baseConfig.plugins.concat(['karma-sauce-launcher'])
});
}
};
Loading

0 comments on commit c3c42ad

Please sign in to comment.