Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
refactor e2e test configurations
Browse files Browse the repository at this point in the history
add failsafe test for ie9
  • Loading branch information
hmdhk committed Jul 8, 2016
1 parent 3982570 commit 542de47
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
var utils = require('../../e2e/utils')
describe('angular.ui router app', function () {
beforeEach(utils.verifyNoBrowserErrors)

describe('minified_module_app.failsafe', function () {
it('should run application without error', function (done) {
browser.url('/angular/index.e2e.html')
browser
.url('/angular/index.e2e.html')
.executeAsync(function (cb) {
window.runFixture('./minified_module_app/minified_module_app.js', ['../dist/dev/opbeat-angular.e2e.min.js', 'angular-ui-router'], {
window.runFixture('./minified_module_app/minified_module_app.js', ['../dist/dev/opbeat-angular.min.js', 'angular-ui-router'], {
beforeInit: function (app, deps) {
var errors = []
window.onerror = function (error, url, line) {
errors.push(error)
console.log(error)
}
app.init({
debug: true,
debug: false,
orgId: '7f9fa667d0a349dd8377bc740bcfc33e',
appId: '0a8757798e',
performance: {
enable: true,
enableStackFrames: true
}
})
cb('trs')
setTimeout(function () {
cb(errors)
}, 1000)
},
useNgApp: false,
uiRouter: true
})
})
.then(function (trs) {
var errors = trs.value
expect(errors.length).toBe(0)
console.log('errors: ', errors)
done()
}, function (error) {
console.log(error)
})
})

afterEach(utils.verifyNoBrowserErrors)
})
25 changes: 16 additions & 9 deletions e2e_test/e2e/browser_utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
function setup () {
if (!window.console) {
window.console = {}
}
if (!console.log) {
console.log = function () {}
}

function logError (e) {
console.log(e)
}
Expand Down Expand Up @@ -81,15 +88,15 @@ function setup () {
// // return originalSend.apply(xhr, arguments)
// // }

// xhr.addEventListener('load', function () {
// window.__httpInterceptor.requests.push({
// requestedMethod: lastMethod.toUpperCase(),
// requestedURL: lastURL,
// xhr: this
// })
// })
// return xhr
// }
// xhr.addEventListener('load', function () {
// window.__httpInterceptor.requests.push({
// requestedMethod: lastMethod.toUpperCase(),
// requestedURL: lastURL,
// xhr: this
// })
// })
// return xhr
// }
}

setup()
6 changes: 4 additions & 2 deletions e2e_test/e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ module.exports = {
if (logLevels[logEntry.level].value > logLevels.WARNING.value) {
filteredLog.push(logEntry)
} else if (logLevels[logEntry.level].value >= logLevels.INFO.value) {
console.log('>> ' + logEntry.message)
// console.log('>> ' + logEntry.message)
}
}
console.log(filteredLog)
if (filteredLog.length > 0) {
console.log('Erros: ', filteredLog)
}
expect(filteredLog.length).toEqual(0, 'Expected no errors in the browserLog but got ' + filteredLog.length + ' error(s)') // .because()
if (typeof done === 'function') {
done()
Expand Down
60 changes: 40 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gulp.task('server', function () {
})
})

function createBuildStream(mainFilePath) {
function createBuildStream (mainFilePath) {
return browserify({
entries: [mainFilePath],
standalone: '',
Expand All @@ -49,15 +49,14 @@ function createBuildStream(mainFilePath) {
.pipe(derequire())
}

function writeToDestinations(stream, dests) {
function writeToDestinations (stream, dests) {
var tasks = dests.map(function (destPath) {
return stream.pipe(gulp.dest(versionPath))
})
return es.merge.apply(null, tasks)
}


function getMajorVersion() {
function getMajorVersion () {
var version = require('./package').version
var majorVersion = version.match(/^(\d).(\d).(\d)/)[1]
return majorVersion
Expand Down Expand Up @@ -100,7 +99,6 @@ gulp.task('build:release', function () {
}))
.pipe(gulp.dest(prodPath + integration.name))


return es.merge.apply(null, [mainStream, packagejson, gulp.src(['./README.md', 'LICENSE']).pipe(gulp.dest(prodPath + integration.name))])
})

Expand Down Expand Up @@ -159,7 +157,6 @@ gulp.task('deploy', ['build:release'], function () {
'Cache-Control': 'max-age=1800, public'
}


var version = require('./package').version
var majorVersion = version.match(/^(\d).(\d).(\d)/)[1]

Expand All @@ -176,7 +173,7 @@ gulp.task('deploy', ['build:release'], function () {
.pipe(awspublish.reporter())
})

function runKarma(configFile, done) {
function runKarma (configFile, done) {
var exec = require('child_process').exec

var cmd = process.platform === 'win32' ? 'node_modules\\.bin\\karma run ' :
Expand All @@ -202,7 +199,6 @@ gulp.task('test', function (done) {
}, done).start()
})


// Run end-to-end tests on the local machine using webdriver configuration
gulp.task('test:e2e', function (done) {
gulp.src('wdio.conf.js')
Expand All @@ -215,23 +211,47 @@ gulp.task('test:e2e', function (done) {
})
})

gulp.task('test:e2e:sauceconnect:failsafe', function () {
failSafeConfig = {
user: 'opbeat',
key: 'de42e589-1450-41a2-8a44-90aa00c15168',
host: 'ondemand.saucelabs.com',
port: 80,
baseUrl: 'http://localhost:8000',
}

var failSafeStream = gulp.src('wdio.failsafe.conf.js')
.pipe(webdriver(failSafeConfig))
.on('error', function () {
console.log('Exiting process with status 1')
process.exit(1)
})
.on('end', function () {
console.log('Tests complete')
})
return failSafeStream
})

// Run end-to-end tests remotely in saucelabs using webdriver configuration
gulp.task('test:e2e:sauceconnect', function () {
return gulp.src('wdio.conf.js')
.pipe(webdriver({
user: 'opbeat',
key: 'de42e589-1450-41a2-8a44-90aa00c15168',
host: 'ondemand.saucelabs.com',
port: 80,
baseUrl: 'http://localhost:8000'
}))
gulp.task('test:e2e:sauceconnect', ['test:e2e:sauceconnect:failsafe'], function () {
var e2eConfig = {
user: 'opbeat',
key: 'de42e589-1450-41a2-8a44-90aa00c15168',
host: 'ondemand.saucelabs.com',
port: 80,
baseUrl: 'http://localhost:8000'
}

var e2eStream = gulp.src('wdio.sauce.conf.js')
.pipe(webdriver(e2eConfig))
.on('error', function () {
console.log('Exiting process with status 1')
process.exit(1)
})
.on('end', function () {
console.log('Tests complete')
})
return e2eStream
})

// Launch sauce connect and connect
Expand Down Expand Up @@ -280,22 +300,22 @@ gulp.task('test:e2e:selenium', function (done) {
gulp.task('test:e2e:start-local', function (done) {
runSequence('build', 'build:release', 'test:e2e:serve', 'test:e2e:selenium', function () {
console.log('All tasks completed.')
});
})
})

// Run all required tasks to perform remote end-to-end testing
gulp.task('test:e2e:start-sauce', function (done) {
runSequence('build', 'test:e2e:launchsauceconnect', function () {
console.log('All tasks completed.')
});
})
})

gulp.task('test:e2e:start-travis', function (done) {
runSequence('build', 'test:e2e:serve', 'test:e2e:sauceconnect', function () {
console.log('All tasks completed.')
done()
process.exit(0)
});
})
})

gulp.task('watch:e2e', ['e2e-serve', 'selenium-start'], function (done) {
Expand Down
23 changes: 2 additions & 21 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@ exports.config = {
browser.timeoutsAsyncScript(30000)
}
}
// {
// maxInstances: 1,
// browserName: 'internet explorer'
// },
// {
// browserName: 'internet explorer',
// maxInstances: 1,
// 'platform': 'Windows 7',
// 'version': '9.0',
// specs: [
// '/e2e_test/**/*.ie9.spec.js'
// ],
// baseUrl: 'http://localhost:8000',
// initialBrowserUrl: 'about:blank',
// before: function () {
// browser.timeoutsAsyncScript(15000)
// }
// }
],
//
// ===================
Expand All @@ -83,7 +65,7 @@ exports.config = {
baseUrl: 'http://localhost:8000',
//
// Default timeout for all waitForXXX commands.
waitforTimeout: 10000,
waitforTimeout: 30000,
//
// Initialize the browser instance with a WebdriverIO plugin. The object should have the
// plugin name as key and the desired plugin options as property. Make sure you have
Expand Down Expand Up @@ -174,8 +156,7 @@ exports.config = {
}

browser.expectedAngularVersion = version
}
else {
} else {
// otherwise we manually set the version to the latest major/minor combination
browser.expectedAngularVersion = { major: 1, minor: 5, patch: 0, full: '1.5.0' }
}
Expand Down
15 changes: 15 additions & 0 deletions wdio.failsafe.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var config = require('./wdio.conf.js').config
config.capabilities = [
{
browserName: 'internet explorer',
maxInstances: 1,
'platform': 'Windows 7',
'version': '9.0'
}
]

config.specs = [
'./e2e_test/**/*.failsafe.js'
]

exports.config = config
18 changes: 18 additions & 0 deletions wdio.sauce.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var config = require('./wdio.conf.js').config
config.capabilities = [
{
maxInstances: 1,
browserName: 'chrome',
'version': '45',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
before: function () {
browser.timeoutsAsyncScript(30000)
}
}
]

config.specs = [
'./e2e_test/**/*.spec.js'
]

exports.config = config

0 comments on commit 542de47

Please sign in to comment.