mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
- e2e tests should work with production now also by exporting STF_URL, STF_USERNAME and STF_PASSWORD.
- Added BrowerLogs, a Protractor helper which redirects browser logs to the console, with an additional expectNoLogs option. - Refactored Login model names to work seamlessly.
This commit is contained in:
parent
a08d9e26f0
commit
e87dc45fb9
8 changed files with 104 additions and 30 deletions
36
res/test/e2e/helpers/browser-logs.js
Normal file
36
res/test/e2e/helpers/browser-logs.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
var chalk = require('chalk')
|
||||
|
||||
// http://stackoverflow.com/questions/7157999/output-jasmine-test-results-to-the-console
|
||||
// https://github.com/pivotal/jasmine/blob/master/src/console/ConsoleReporter.js
|
||||
|
||||
module.exports = function BrowserLogs(options) {
|
||||
options = options || {}
|
||||
|
||||
if (typeof options.expectNoLogs === 'undefined') {
|
||||
options.expectNoLogs = false
|
||||
}
|
||||
if (typeof options.outputLogs === 'undefined') {
|
||||
options.outputLogs = true
|
||||
}
|
||||
|
||||
browser.getCapabilities().then(function (cap) {
|
||||
var browserName = ' ' + cap.caps_.browserName + ' log '
|
||||
var browserStyled = chalk.bgBlue.white.bold(browserName) + ' '
|
||||
|
||||
browser.manage().logs().get('browser').then(function (browserLogs) {
|
||||
if (options.expectNoLogs) {
|
||||
expect(browserLogs.length).toEqual(0)
|
||||
}
|
||||
|
||||
if (options.outputLogs && browserLogs.length) {
|
||||
browserLogs.forEach(function (log) {
|
||||
if (log.level.value > 900) {
|
||||
console.error(browserStyled + chalk.white.bold(log.message))
|
||||
} else {
|
||||
console.log(browserStyled + chalk.white.bold(log.message))
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue