npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-service-client

v1.2.6

Published

Client for cypress-service

Downloads

17

Readme

cypress-service-client

Helper to simplify deploying Cypress tests to cypress-service. See https://github.com/Qarj/cypress-service

Also can trigger the tests to run in serial or parallel.

Check https://github.com/Qarj/cypress-frontend-app for a repo that uses this package.

Install

npm install cypress-service-client

deployCypressFolder(serviceBaseUrl, environmentName, options)

Example 1

The name and version will be read from your package.json.

Assuming your app name is my-react-app then in this example your cypress folder will be zipped up and posted to http://localhost:4567/test/dev/my-react-app along with the associated version.

const csc = require('cypress-service-client');

deployCypressTests();

async function deployCypressTests() {
    const serviceBaseUrl = 'http://localhost:4567';
    const result = await csc.deployCypressFolder(serviceBaseUrl, 'dev');
    console.log(result);
}

Since we are posting to dev, cypress-service will expect to find the cypress config file cypress-dev.json at cypress/cypress-dev.json from project root.

Example 2

Here the cypress path, app name and version are overridden by passing options.

const csc = require('cypress-service-client');

deployCypressTests();

async function deployCypressTests() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'prod';
    const app = 'react-app';
    const version = 'v1.2.4';

    options = {
        app: app,
        cypressPath: './test/release/cypress',
        version: version,
    };
    const result = await csc.deployCypressFolder(serviceBaseUrl, environmentName, options);
    console.log(result);
}

startSequential(serviceBaseUrl, environmentName, options)

Starts running all tests for the app and environment to run one by one sequentially without waiting for the result.

Example 1

The name and version will be read from your package.json.

const csc = require('cypress-service-client');

testStartSequential();

async function testStartSequential() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';

    const result = await csc.startSequential(serviceBaseUrl, environmentName);
    console.log(result);
}

Assuming your app is called my-react-app, a GET will be done to http://localhost:4567/test/dev/my-react-app?group=22.01.35.215&noWait=1

The group name is derived from the current time.

Example 2

Supply options to override defaults.

const csc = require('cypress-service-client');

testStartSequential();

async function testStartSequential() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';
    const app = 'my-react-app';

    options = {
        app: app,
        groupName: 'MyGroup_' + Math.floor(Math.random() * 1000),
        noVideo: true,
        tag: '_deploy',
    };
    const result = await csc.startSequential(serviceBaseUrl, environmentName, options);

    console.log(result);
}

A GET will be done to http://localhost:4567/test/dev/my-react-app?group=MyGroup_215&noVideo=1&noWait=1

The no video option tells cypress-service not to produce video files.

The group name you supply is a string but must be unique - cypress-service will not allow you to reuse the group name on any given day - for an app and environment combination.

The tag is appended to the groupName - useful when using the default automatically generated group names (based on the current time.)

runSequential(serviceBaseUrl, environmentName, options)

runSequential is exactly the same as startSequential except for one thing - instead of kicking off the tests and returning immediately, runSequential waits until the tests have finished running and returns the test result from cypress-service.

startParallel(serviceBaseUrl, environmentName, options)

Kicks off each Cypress suite of tests (a suite being defined as each folder directly under cypress/integration).

Each suite is kicked off without waiting for the test result. The cypress-service response for each kickoff is returned in an array.

By default there will be a startInterval of 10000 milliseconds between each suite kickoff - this is because Cypress tends to choke a bit when starting a suite until it gets underway.

Example 1

Using all defaults.

const csc = require('cypress-service-client');

testStartParallel();

async function testStartParallel() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';

    const result = await csc.startParallel(serviceBaseUrl, environmentName);
    console.log(result);
}

Example 2

In this example all the defaults are overriden.

const csc = require('cypress-service-client');

testStartParallel();

async function testStartParallel() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';
    const app = 'my-react-app';

    options = {
        app: app,
        cypressPath: './test/release/cypress',
        groupName: 'MyGroup_' + Math.floor(Math.random() * 1000),
        noVideo: true,
        startInterval: 5000,
        tag: '_deploy',
    };
    const result = await csc.startParallel(serviceBaseUrl, environmentName, options);
    console.log(result);
    console.log('All done.');
}

runParallel(serviceBaseUrl, environmentName, options)

Kicks off all tests to run in parallel but with a startInterval of 10000 milliseconds between each kickoff (Cypress chokes during test startup.)

By default runParallel will wait up to 10 minutes for some kind of definitive result before returning. A definitive result is either that all tests have passed, or at least one test has failed or crashed.

Example 1

const csc = require('cypress-service-client');

testRunParallel();

async function testRunParallel() {
    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';

    const result = await csc.runParallel(serviceBaseUrl, environmentName, options);
    console.log(result);
}

Example 2

We can override the default options as shown here.

resultWaitLoops is the number of loops while waiting for a result, resultWaitPause is the sleep in milliseconds between each loop.

const csc = require('cypress-service-client');

testRunParallel();

async function testRunParallel() {
    const csc = require('../index.js');

    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';
    const app = 'my-react-app';

    options = {
        app: app,
        cypressPath: './test/release/cypress',
        groupName: 'MyGroup_' + Math.floor(Math.random() * 1000),
        noVideo: true,
        resultWaitLoops: 60,
        resultWaitPause: 10000,
        startInterval: 5000,
        tag: '_deploy',
    };
    const result = await csc.runParallel(serviceBaseUrl, environmentName, options);
    console.log(result);
}

isRunning(serviceBaseUrl, environmentName, options)

const csc = require('cypress-service-client');

isRunning();

async function isRunning() {
    const csc = require('../index.js');

    const serviceBaseUrl = 'http://localhost:4567';
    const environmentName = 'dev';
    const app = 'my-react-app';

    const result = await csc.isRunning(serviceBaseUrl, environmentName);
    console.log(result);
}

Can override app name with

options = {
    app: 'my-react-app',
};