How to use nightwatch - 10 common examples

To help you get started, we’ve selected a few nightwatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-router / test / e2e / runner.js View on Github external
.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)
github vuejs / vue-router / test / e2e / runner.js View on Github external
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)
            })
          })
github vuejs / vue-router / test / e2e / runner.js View on Github external
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)
            })
          })
github luniehq / lunie / tests / e2e / browserstack.runner.js View on Github external
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() {})
          })
      })
    }
  )
github luniehq / lunie / tests / e2e / browserstack.runner.js View on Github external
#!/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
github luniehq / lunie / tests / e2e / browserstack.runner.js View on Github external
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() {})
          })
      })
    }
github appnexus / lucid / scripts / local.runner.js View on Github external
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);
						});
					});

				});
github appnexus / lucid / scripts / local.runner.js View on Github external
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);
						});
github browserstack / nightwatch-browserstack / scripts / local.runner.js View on Github external
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) {
github uikit / uikit / nightwatch.runner.js View on Github external
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');

nightwatch

Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.

MIT
Latest version published 18 days ago

Package Health Score

92 / 100
Full package analysis