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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cypress-configuration-builder

v1.2.4

Published

A Cypress plugin that enables multi-level configuration.

Downloads

16

Readme

Overview

This Cypress plugin can help you in the following cases.

1 Your test configuration depends on multiple factors.

For example, apiBaseUrl differs per environment (dev, staging etc).

2 You need to be able to combine multiple configuration files together, allowing for overrides among configurations.

3 You need to store sensitive information (e.g., login credentials) in configuration files that should not be versioned (e.g., ignored by Git).

Setup

1 Install through Yarn:

yarn add --dev cypress-configuration-builder

or NPM:

npm install --dev cypress-configuration-builder

2 Open your Cypress plugins file (usually, /cypress/plugins/index.js) and add:

const ccb = require('cypress-configuration-builder');

/**
 * @type {Cypress.PluginConfig}
 */
module.exports = (on, config) => ccb.buildConfiguration(config);

Example

yarn start --env configKeys=a.b

This will load the following files:

  1. cypress.json (loaded by default - see Cypress Configuration)
  2. cypress.a.json
  3. cypress.a-secrets.json
  4. cypress.b.json
  5. cypress.b-secrets.json

Explanation

1 Except for cypress.json, the rest of the file names follow these patterns:

  1. either: cypress.<configKey>.json
  2. or: cypress.<configKey>-secrets.json

2 The configuration files we want to combine are defined in the configKeys environment variable.

2.1 The file keys are separated by a dot (U+002E) character.

2.2 The separator can change through the configKeysSeparator parameter.

2.3 2.1 and 2.2 imply that we cannot have the configKeysSeparator string in a file name's configKey part.

For example, if configKeysSeparator is the dot character, we cannot have a configuration file named cypress.a.2.json because passing it to configKeys:

yarn run cypress run --env configKeys=a.2

would result in loading cypress.a.json and cypress.2.json, instead of cypress.a.2.json.

3 The order the files are defined in the call (--configKeys) matters.

Later files override earlier ones. For example, assuming we have the following two files:

// File: cypress.json

{
    "baseUrl": "http://default.com"
}
// File: cypress.a.json

{
    "baseUrl": "http://a.com"
}

baseUrl will end up equal to: http://a.com.

3.1 The files are combined with deep merging.

For example, assuming the following files:

// File: cypress.json

{
    "a": {
        "b": {
            "c": 1
        },
        "d": 2
    }
}
// File: cypress.a.json

{
    "a": {
        "b": {
            "c": 9
        }
    }
}

we will end up with this configuration:

{
    "a": {
        "b": {
            "c": 9
        },
        "d": 2
    }
}

4 Except for cypress.json, if any of the other files does not exist, it is simply ignored.

Best practices

1 Use the cypress.json file for parameters that should be shared by all tests.

2 Use environment (e.g., cypress.dev.json) specific files for parameters specific to an environment.

3 Use the -secrets files for configuration you want available only on your local machine. For example, login credentials.

Note Remember to ignore the -secrets files from Git in order to avoid leaking sensitive information.

For example, add this entry to your .gitignore file:

cypress.*-secrets.json

4 You are not restricted to per environment configuration files.

Feel free to mix and match in order to create a configuration that suits your needs.

For example, let's say we have the following file:

// File: cypress.a.json

{
    "a": 2,
    "b": 1
}

And we want to run a test that will have:

  1. a equal to 1 just for this test
  2. keep the rest of the configuration in this file (in this case, just b)

We can simply create a new configuration file, let's call it cypress.a-2.json, where we will define a equal to 1:

// File: cypress.a-2.json

{
    "a": 1
}

Then, we can use it like this:

yarn start --env configKeys=a.a-2

This will give us the expected configuration:

{
    "a": 1,
    "b": 1
}

5 Consider using the Cypress configuration file JSON schema in your configuration files for autocompletion.

Configuration

configKeys Indicates the configuration files to be loaded, in addition to the one Cypress loads by default (e.g., cypress.json).

For example:

yarn run cypress run --env configKeys=a.b

will merge: cypress.json, cypress.a.json, cypress.a-secrets.json, cypress.b.json and cypress.b-secrets.json.

configKeysSeparator Specifies the string that will be used as a separator for the values of configKeys.

For example:

yarn run cypress run --env configKeys=a#b,configKeysSeparator=#

Notice, that we now use the number sign character (#) as a separator in configKeys.

Invalid separators:

Tests

In order to execute the test suite run:

yarn test