Timeout

By default, asynchronous hooks and steps time out after 5000 milliseconds. This can be modified globally:

JavaScript
var {setDefaultTimeout} = require('cucumber');

setDefaultTimeout(60 * 1000);

A specific hook or step timeout can be set by

JavaScript
var {Before, Given} = require('cucumber');

Before({timeout: 60 * 1000}, function() {
// Perform some slower browser/file system/network operations
});

Given(/^a slow step$/, {timeout: 60 * 1000}, function() {
// Perform some slower browser/file system/network operations
});

Disable timeout

Do not use this feature unless absolutely necessary

Disable the timeout by setting it to -1. If you use this, you need to implement your own timeout protection. Otherwise the test suite may end prematurely or hang indefinitely.

JavaScript
var {Before, Given} = require('cucumber');
var Promise = require('bluebird');

Given('the operation completes within {n} minutes', {timeout: -1}, function(minutes) {
  const milliseconds = (minutes + 1) * 60 * 1000
  const message = `operation did not complete within ${minutes} minutes`
  return Promise(this.verifyOperationComplete()).timeout(milliseconds, message);
});

Chinese version click here.

results matching ""

    No results matching ""