gulp-up-and-running

Gulp extension to wait until a webserver is up and running.

Usage no npm install needed!

<script type="module">
  import gulpUpAndRunning from 'https://cdn.skypack.dev/gulp-up-and-running';
</script>

README

gulp-up-and-running

npm version

Gulp extension to wait until a webserver is up and running.

var upAndRunning = require('gulp-up-and-running');

API

upAndRunning(options)

Returns an asynchronous promise that is resolved when the specified url returns an HTTP code 200. It is rejected after the retries limit is reached.

options is a JS object containing the following keys:

  • name: The name of the webserver for logging purposes.
  • url: The url that should be queried until an HTTP code 200 is returned or the retries limit is reached.
  • retry: A JS object containing node-retry timeout-options.

Usage

var upAndRunning = require('gulp-up-and-running');

// waits until selenium is up-and-running
gulp.task('selenium-up-and-running', function() {
    return upAndRunning({
      name: 'selenium-server',
      url: 'http://localhost:4444/wd/hub/status',
      retry: {
        retries: 30,
        minTimeout: 1000,     // 1 second
        maxTimeout: 5 * 1000, // 5 seconds
        randomize: true
      }
    });
});

// you can start your end to end tests once selenium is up-and-running
gulp.task('e2e-tests', ['selenium-up-and-running'], function(){ 
  // some code to start your e2e tests here ...
});