Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.catch(() => {
server && server.close()
// fail execution
process.exit(1)
})
})
} catch (err) {
console.error(err)
bsLocal.stop(() => {
process.exit(1)
})
}
})
} else {
// create the Nightwatch CLI runner
Nightwatch.cli(argv => {
adaptArgv(argv)
const runner = Nightwatch.CliRunner(argv)
// setup and run tests
runner
.setup()
.startWebDriver()
.then(() => runner.runTests())
.then(() => {
runner.stopWebDriver()
server && server.close()
process.exit(0)
})
.catch(err => {
server && server.close()
console.error(err)
if (isLocal) {
if (isLocal && (!process.env.BS_USER || !process.env.BS_KEY)) {
console.log(
'Hey!\n',
'You are missing credentials for Browserstack.\n',
'If you are a contributor, this is normal, credentials are private. These tests must be run by a maintainer of vue-router',
'If you are a maintainer, make sure to create your `.env` file with both `BS_USER` and `BS_KEY` variables!'
)
// fail if testing locally
process.exit(process.env.CI ? 0 : 1)
}
let bsLocal
const browserstack = require('browserstack-local')
Nightwatch.bs_local = bsLocal = new browserstack.Local()
bsLocal.start({ key: process.env.BS_KEY }, error => {
if (error) throw error
console.log('Connected. Now testing...')
try {
Nightwatch.cli(argv => {
adaptArgv(argv)
Nightwatch.CliRunner(argv)
.setup(null, () => {
// NOTE: I don't know when this is running or if it does
// Code to stop browserstack local after end of parallel test
bsLocal.stop(() => {
server && server.close()
process.exit(0)
})
})
Nightwatch.cli(argv => {
adaptArgv(argv)
Nightwatch.CliRunner(argv)
.setup(null, () => {
// NOTE: I don't know when this is running or if it does
// Code to stop browserstack local after end of parallel test
bsLocal.stop(() => {
server && server.close()
process.exit(0)
})
})
.runTests()
.then(() => {
// Code to stop browserstack local after end of single test
bsLocal.stop(() => {
server && server.close()
process.exit(0)
})
})
function(error) {
if (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() {})
})
})
}
)
#!/usr/bin/env node
var Nightwatch = require("nightwatch")
var browserstack = require("browserstack-local")
var bs_local
try {
process.mainModule.filename = "./node_modules/nightwatch/bin/nightwatch"
// Code to start browserstack local before start of test
console.log("Connecting local")
Nightwatch.bs_local = bs_local = new browserstack.Local()
bs_local.start(
{
key: process.env.BROWSERSTACK_ACCESS_KEY
},
function(error) {
if (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
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() {})
})
})
}
Nightwatch.cli(argv => {
console.log('run tests');
Nightwatch.CliRunner(argv)
// Code to stop browserstack local after end of parallel test
.setup(null, () => {
local.stop(() => {
server.close()
process.exit(0);
});
})
.runTests(() => {
// Code to stop browserstack local after end of single test
local.stop(() => {
server.close()
process.exit(0);
});
});
});
local.start(browserStackConfig, err => {
if (err) {
console.log('browserstack-local error');
console.error(err);
local.stop(() => {
server.close();
process.exit(1);
});
}
console.log('start test setup');
Nightwatch.cli(argv => {
console.log('run tests');
Nightwatch.CliRunner(argv)
// Code to stop browserstack local after end of parallel test
.setup(null, () => {
local.stop(() => {
server.close()
process.exit(0);
});
})
.runTests(() => {
// Code to stop browserstack local after end of single test
local.stop(() => {
server.close()
process.exit(0);
});
bs_local.start({'key': process.env.BROWSERSTACK_ACCESS_KEY }, function(error) {
if (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(){});
});
});
});
} catch (ex) {
const globals = require('./nightwatch.globals');
const cp = require('child_process');
const httpServer = require('http-server');
const browserstack = require('browserstack-local');
const nightwatch = require('nightwatch');
const chromedriver = require('chromedriver');
const server = httpServer.createServer(); // {root:'./'}
const configs = Object.keys(conf.test_settings);
let bsLocal = null;
if (~process.argv.indexOf('--bs') || process.env.NIGHTWATCH_BROWSERSTACK) {
bsLocal = nightwatch.bs_local = new browserstack.Local;
}
beforeTests().then(doTests).then(afterTest).then(process.exit);
function beforeTests() {
server.listen(globals.port, globals.host);
return new Promise(res => {
if (bsLocal) {
bsLocal.start({}, err => {
if (err) {
if (err.message.indexOf('another browserstack local')) {
console.log('re-using running bs-local instance');