mirror of
https://github.com/wassname/talk.git
synced 2026-07-07 17:34:54 +08:00
Integrate browserstack into ci
This commit is contained in:
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const Nightwatch = require('nightwatch');
|
||||
const browserstack = require('browserstack-local');
|
||||
const {onshutdown} = require('../bin/util');
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
const bs_local = new browserstack.Local();
|
||||
process.mainModule.filename = './node_modules/.bin/nightwatch';
|
||||
|
||||
// Code to start browserstack local before start of test
|
||||
console.log('Connecting local');
|
||||
Nightwatch.bs_local = bs_local;
|
||||
|
||||
bs_local.start({
|
||||
'key': process.env.BROWSERSTACK_KEY,
|
||||
'logFile': './test/e2e/bslocal.log'
|
||||
}, function(error) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log('Connected. Now testing...');
|
||||
Nightwatch.cli(function(argv) {
|
||||
Nightwatch.CliRunner(argv)
|
||||
.setup(null, function(){
|
||||
|
||||
// Code to stop browserstack local after end of parallel test
|
||||
bs_local.stop(function(){});
|
||||
})
|
||||
.runTests(function(){
|
||||
|
||||
// Code to stop browserstack local after end of single test
|
||||
bs_local.stop(function(){});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
onshutdown([
|
||||
() => bs_local.stop(function(){}),
|
||||
]);
|
||||
} catch (ex) {
|
||||
console.log('There was an error while starting the test runner:\n\n');
|
||||
process.stderr.write(`${ex.stack}\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
start();
|
||||
Reference in New Issue
Block a user