A simple perform command which allows access to the Nightwatch API in a callback. Can be useful if you want to read variables set by other commands.

The callback signature can have up to two parameters.

  • no parameters: callback runs and perform completes immediately at the end of the execution of the callback.
  • one parameter: allows for asynchronous execution within the callback providing a done callback function for completion as the first argument.
  • two parameters: allows for asynchronous execution with the Nightwatch api object passed in as the first argument, followed by the done callback.

In the case of asynchronous execution, the timeout can be controlled by setting the asyncHookTimeout global. See Using test globals for more info.



Or run locally with:
git clone https://github.com/nightwatchjs/nightwatch-examples.git
cd nightwatch-examples
npm install
npx nightwatch tests/api/perform.js


Name Type description
callback function

The function to run as part of the queue.