forked from spring-cloud/spring-cloud-dataflow-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spring-cloudgh-648 Provide infrastructure for local E2E/Unit Testing …
…against SauceLabs - Update Readme - Add support for SauceLabs-based E2E testing - Add support for SauceLabs-based Unit testing - Add support for BrowserStack-based E2E testing - Add support for BrowserStack-based Unit testing In order to run the tests, developers must provide SauceLabs credentials, e.g.: $ export SAUCE_USERNAME=your-username $ export SAUCE_ACCESS_KEY=your-access-key and BrowserStack credentials, e.g.: $ export BROWSER_STACK_USERNAME=your-username $ export BROWSER_STACK_ACCESS_KEY=your-access-key Important, for E2E tests, developers should refrain from using `localhost`. Instead, add `dataflow.local` to your local DNS hosts file.
- Loading branch information
Showing
10 changed files
with
329 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
|
||
const customLaunchers = { | ||
'bs_chrome': { | ||
base: 'BrowserStack', | ||
browser: 'firefox', | ||
browser_version: '59', | ||
os: 'Windows', | ||
os_version: '10' | ||
} | ||
}; | ||
|
||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular/cli'], | ||
|
||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-browserstack-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('@angular/cli/plugins/karma') | ||
], | ||
client:{ | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
angularCli: { | ||
environment: 'dev' | ||
}, | ||
browserStack: { | ||
name: 'Data Flow Dashboard Unit Tests' | ||
}, | ||
captureTimeout: 120000, | ||
customLaunchers: customLaunchers, | ||
browsers: Object.keys(customLaunchers), | ||
singleRun: true, | ||
|
||
reporters: ['progress', 'BrowserStack'], | ||
colors: true, | ||
logLevel: config.LOG_DEBUG, | ||
browserNoActivityTimeout: 1000000 | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
|
||
const customLaunchers = { | ||
'SL_Edge': { | ||
base: 'SauceLabs', | ||
browserName: 'MicrosoftEdge', | ||
//version: '48.0', | ||
platform: 'Windows 10', | ||
timeout: 360, | ||
idleTimeout: 5000, | ||
maxDuration: 1800, | ||
commandTimeout: 600 | ||
}, | ||
'SL_Chrome': { | ||
base: 'SauceLabs', | ||
browserName: 'chrome', | ||
version: '64.0', | ||
'chromedriverVersion':'2.35', | ||
timeout: 360, | ||
idleTimeout: 5000, | ||
maxDuration: 1800, | ||
commandTimeout: 600 | ||
} | ||
}; | ||
|
||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular/cli'], | ||
|
||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-sauce-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('@angular/cli/plugins/karma') | ||
], | ||
client:{ | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
angularCli: { | ||
environment: 'dev' | ||
}, | ||
sauceLabs: { | ||
testName: 'Data Flow Dashboard Unit Tests' | ||
}, | ||
captureTimeout: 1000000, | ||
browserDisconnectTimeout: 1000000, | ||
concurrency: 1, | ||
customLaunchers: customLaunchers, | ||
browsers: Object.keys(customLaunchers), | ||
singleRun: true, | ||
reporters: ['progress', 'saucelabs'], | ||
colors: true, | ||
logLevel: config.LOG_DEBUG, | ||
browserNoActivityTimeout: 1000000 | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Protractor configuration file, see link for more information | ||
// https://github.com/angular/protractor/blob/master/lib/config.ts | ||
|
||
const { SpecReporter } = require('jasmine-spec-reporter'); | ||
const browserstack = require('browserstack-local'); | ||
|
||
exports.config = { | ||
jasmineNodeOpts: { | ||
defaultTimeoutInterval: 5000000 | ||
}, | ||
seleniumAddress: 'http://hub-cloud.browserstack.com/wd/hub', | ||
commonCapabilities: { | ||
name: 'Data Flow Dashboard E2E Tests', | ||
'browserstack.user': process.env.BROWSER_STACK_USERNAME, | ||
'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY, | ||
'browserstack.local': true, | ||
'browserstack.debug': true | ||
}, | ||
multiCapabilities: [ | ||
{ | ||
os: 'Windows', | ||
os_version: '10', | ||
browserName: 'Chrome', | ||
browser_version: '62.0', | ||
resolution: '1024x768' | ||
}, | ||
{ | ||
os: 'Windows', | ||
os_version: '10', | ||
browserName: 'Edge', | ||
browser_version: '16.0' | ||
} | ||
], | ||
|
||
allScriptsTimeout: 160000, | ||
specs: [ | ||
'./e2e/**/*.e2e-spec.ts' | ||
], | ||
directConnect: false, | ||
baseUrl: 'http://localhost:4200/', | ||
framework: 'jasmine', | ||
// Code to start browserstack local before start of test | ||
beforeLaunch: function(){ | ||
console.log("Connecting local"); | ||
return new Promise(function(resolve, reject){ | ||
exports.bs_local = new browserstack.Local(); | ||
exports.bs_local.start({'key': exports.config.commonCapabilities['browserstack.key'] }, function(error) { | ||
if (error) return reject(error); | ||
console.log('Connected. Now testing...'); | ||
|
||
resolve(); | ||
}); | ||
}); | ||
}, | ||
|
||
// Code to stop browserstack local after end of test | ||
afterLaunch: function() { | ||
return new Promise(function(resolve, reject){ | ||
exports.bs_local.stop(resolve); | ||
}); | ||
}, | ||
jasmineNodeOpts: { | ||
showColors: true, | ||
defaultTimeoutInterval: 30000, | ||
print: function() {} | ||
}, | ||
onPrepare() { | ||
require('ts-node').register({ | ||
project: 'e2e/tsconfig.e2e.json' | ||
}); | ||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); | ||
} | ||
}; | ||
|
||
// Code to support common capabilities | ||
exports.config.multiCapabilities.forEach(function(caps){ | ||
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Protractor configuration file, see link for more information | ||
// https://github.com/angular/protractor/blob/master/lib/config.ts | ||
|
||
const { SpecReporter } = require('jasmine-spec-reporter'); | ||
|
||
exports.config = { | ||
jasmineNodeOpts: { | ||
defaultTimeoutInterval: 5000000 | ||
}, | ||
sauceUser: process.env.SAUCE_USERNAME, | ||
sauceKey: process.env.SAUCE_ACCESS_KEY, | ||
multiCapabilities: [ | ||
{ | ||
name: 'E2E Safari/Mac', | ||
browserName: 'safari', | ||
platform: 'macOS 10.13', | ||
}, | ||
{ | ||
name: 'E2E Edge/Win10', | ||
browserName: 'MicrosoftEdge', | ||
platform: 'Windows 10', | ||
} | ||
], | ||
|
||
allScriptsTimeout: 160000, | ||
specs: [ | ||
'./e2e/**/*.e2e-spec.ts' | ||
], | ||
directConnect: false, | ||
baseUrl: 'http://localhost:4200/', | ||
framework: 'jasmine', | ||
beforeLaunch: function() { | ||
const q = require('q'); | ||
const deferred = q.defer(); | ||
startSauceConnect(deferred); | ||
return deferred.promise; | ||
}, | ||
jasmineNodeOpts: { | ||
showColors: true, | ||
defaultTimeoutInterval: 30000, | ||
print: function() {} | ||
}, | ||
onPrepare() { | ||
require('ts-node').register({ | ||
project: 'e2e/tsconfig.e2e.json' | ||
}); | ||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); | ||
} | ||
}; | ||
|
||
function startSauceConnect(deferred) { | ||
var sauceConnectLauncher = require('sauce-connect-launcher'); | ||
console.log('Launching Sauce Connect...') | ||
sauceConnectLauncher( | ||
{ | ||
username: process.env.SAUCE_USERNAME, | ||
accessKey: process.env.SAUCE_ACCESS_KEY, | ||
// verbose: true, | ||
// logger: console.log, | ||
// tunnelIdentifier: 'npm-build', | ||
// doctor: false | ||
}, function (err, sauceConnectProcess) { | ||
if (err) { | ||
console.error('Error', err.message); | ||
} | ||
deferred.resolve(); | ||
console.log("Sauce Connect ready"); | ||
// sauceConnectProcess.close(function () { | ||
// console.log("Closed Sauce Connect process"); | ||
// }) | ||
} | ||
); | ||
}; |