Set of CodeceptJS config hooks to simplify configuration

Usage no npm install needed!

<script type="module">
  import codeceptjsConfigure from 'https://cdn.skypack.dev/@codeceptjs/configure';


CodeceptJS Configuration Hooks Build Status

Configuration hook helps you update CodeceptJS configuration at ease.

Those hooks are expected to simplify configuration for common use cases.

Requires CodeceptJS >= 2.3.3

Install it

npm i @codeceptjs/configure --save

How to use it

Better to see once.

Watch YouTube video


Toggle headless mode for Puppeteer, WebDriver, TestCafe, Nightmare and Playwright on condition.


// in codecept.conf.js
const { setHeadlessWhen } = require('@codeceptjs/configure');

// enable headless when env var HEADLESS exists
// Use it like:
// export HEADLESS=true && npx codeceptjs run

exports.config = {
  helpers: {
    // standard config goes here
    WebDriver: {} 
    // or Puppeteer
    // or TestCafe
  • For Puppeteer, TestCafe, Nigthmare, Playwright: it enables show: true.
  • For WebDriver with Chrome or Firefox browser: it adds --headless option to chrome/firefox options inside desiredCapabilities.


Opposite to setHeadlessWhen. Forces window mode for running tests.

// in codecept.conf.js
const { setHeadlessWhen } = require('@codeceptjs/configure');

// enable window mode when env var DEV exists
// Use it like:
// export DEV=true && npx codeceptjs run


Enables CodeceptJS plugins which are recommened for common usage. The list of plugins can be updated from version to version so this hook ensures that all of them are loaded and you won't need to update them in a config:

// in codecept.conf.js
const { setCommonPlugins } = require('@codeceptjs/configure');


These plugins will be loaded:

  • tryTo (enabled globally)
  • retryFailedStep (enabled globally)
  • retryTo (enabled globally)
  • eachElement (enabled globally)
  • pauseOnFail (disabled, should be turned on when needed)
  • screenshotOnFail (enable globally)


Shares cookies between browser and REST/GraphQL helpers.

This hooks sets onRequest function for REST, GraphQL, ApiDataFactory, GraphQLDataFactory. This function obtains cookies from an active session in WebDriver or Puppeteer helpers.

// in codecept.conf.js
const { setSharedCookies } = require('@codeceptjs/configure');

// share cookies between browser helpers and REST/GraphQL

exports.config = {
  helpers: {
    WebDriver: {
      // standard config goes here      
    // or Puppeteer
    // or TestCafe,
    REST: {
      // standard config goes here      
      // onRequest: <= will be set by hook
    ApiDataFactory: {
      // standard config goes here
      // onRequest: <= will be set by hook


Changes browser in config for Playwright, Puppeteer, WebDriver, Protractor & TestCafe:

const { setBrowser } = require('@codeceptjs/configure');



Universal way to set a browser window size. For Puppeteer this launches Chrome browser with a specified width and height dimensions without changing viewport size.

Usage: setWindowSize(width, height).

// in codecept.conf.js
const { setWindowSize } = require('@codeceptjs/configure');

setWindowSize(1600, 1200);

exports.config = {
  helpers: {
    Puppeteer: {}


Changes url in config for Playwright, Puppeteer, WebDriver, Protractor & TestCafe:

const { setTestHost } = require('@codeceptjs/configure');



Please send your config hooks!

If you feel that codecept.conf.js becomes too complicated and you know how to make it simpler, send a pull request with a config hook to solve your case.

Good ideas for config hooks:

  • Setting the same window size for all browser helpers.
  • Configuring run-multiple
  • Changing browser in WebDriver or Protractor depending on environment variable.

To create a custom hook follow this rules.

  1. Create a file starting with prefix use in hooks directory.
  2. Create a js module that exports a function.
  3. Require config object from codeceptjs package.
  4. Use config.addHook((config) => {}) to set a hook for configuration
  5. Add a test to index_test.js
  6. Run mocha index_test.js

See current hooks as examples.