With just one command, set up everything to run Nightwatch tests in under 60 seconds. Our new onboarding client aims to provide a powerful onboarding experience to the developers setting up Nightwatch for the first time or in their existing project. Learn how to quickly set up the config, and automatically install the webdrivers and the required packages.
It all starts with the command
npm init nightwatch
> npm init nightwatch Need to install the following packages: create-nightwatch Ok to proceed? (y)
This is an npm alias for using
npx create-nightwatch . The
npx is a command for executing package binaries without downloading to the local dependency. npm then installs the package in a cache and runs the binary. If you are starting a new project, you can also run
npm init nightwatch <directory> .
The Flow of Choices
The setup is based on a list of questions to accommodate a variety of use cases.
Nightwatch also supports other test runners. You can also pick Mocha or Cucumber as a test runner apart from Nightwatch.
Local / Remote
You can setup the config and downloads based on if you're going to be running the test locally or on a remote machine or both.
Where do you want to run your e2e tests? (Use arrow keys) ❯ On my local machine On a remote machine (cloud) Both
You can pick the browsers you'll be testing on, and the config will be created for them. We provide a multi-selection option so you can pick as many browsers you want to test on. You can also use the selenium-server when testing on the local machine.
(Local) Where you'll be testing on? (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed) ❯◉ Firefox ◯ Chrome ◯ Edge ◯ Safari ◯ IE (requires selenium-server) ◯ Local selenium-server
If you are running from a Mac, safaridriver is present by default but must be enabled.
? Enable safaridriver (requires sudo password)? (Use arrow keys) Yes ❯ No, I'll do that later.
For remote testing, you should provide the host address and port of the remote machine.
? (Remote) What is the host address of your remote machine? (localhost) ? (Remote) What is the port on which your test backend is running on your remote machine? (80)
Apart from the fundamental differences in the ways you test, we also keep adding other extra configs you can add to the questionnaire. As of May '22, the list is as follows.
- Directory location for the end-to-end tests
base_urlof your project
- Using the
--generate-configto create only the config and not download any dependencies
--generate-config is not provided, the script installs the necessary packages.
Installing the following packages: - nightwatch - @nightwatch/selenium-server - @cucumber/cucumber
For local tests, the script also installs the wedrivers based on your browser selection.
Installing/Updating the following webdrivers: - geckodriver - chromedriver - iedriver - safaridriver
By default, the configuration file
nightwatch.conf.js is generated and examples at
tests/nightwatch-examples . If the
nightwatch.conf.js is already present then you can choose to overwrite the existing config file or to create a new one.
? Do you want to overwrite the existing config file? No, create a new one! ? What should your new config file be called? ie-windows-test.conf.js
Then you can run the examples with this command.
npx nightwatch ./tests/nightwatch-examples
npm init nightwatch