{"id":24753873,"url":"https://github.com/codeceptjs/configure","last_synced_at":"2025-10-11T00:30:57.378Z","repository":{"id":39892401,"uuid":"210709533","full_name":"codeceptjs/configure","owner":"codeceptjs","description":"A set of config hooks which simplify configuration of CodeceptJS","archived":false,"fork":false,"pushed_at":"2025-06-26T13:25:29.000Z","size":396,"stargazers_count":7,"open_issues_count":2,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-23T00:30:23.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeceptjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-09-24T22:37:32.000Z","updated_at":"2025-06-26T13:25:33.000Z","dependencies_parsed_at":"2024-01-12T10:24:33.813Z","dependency_job_id":"081d106b-5342-4604-8c6e-73c5433c8546","html_url":"https://github.com/codeceptjs/configure","commit_stats":{"total_commits":69,"total_committers":13,"mean_commits":"5.3076923076923075","dds":0.6811594202898551,"last_synced_commit":"14434a60eeb585ea3ca9b1e041851cd7613561a4"},"previous_names":["codecept-js/configure"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/codeceptjs/configure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fconfigure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fconfigure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fconfigure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fconfigure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeceptjs","download_url":"https://codeload.github.com/codeceptjs/configure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeceptjs%2Fconfigure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005659,"owners_count":26083942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T11:36:38.331Z","updated_at":"2025-10-11T00:30:57.096Z","avatar_url":"https://github.com/codeceptjs.png","language":"JavaScript","readme":"## CodeceptJS Configuration Hooks [![Build Status](https://travis-ci.org/codeceptjs/configure.svg?branch=master)](https://travis-ci.org/codeceptjs/configure)\n\nConfiguration hook helps you update CodeceptJS configuration at ease.\n\nThose hooks are expected to simplify configuration for common use cases.\n\n**Requires CodeceptJS \u003e= 2.3.3**\n\n## Install it\n\n```\nnpm i @codeceptjs/configure --save\n```\n\n## How to use it\n\nBetter to see once.\n\n**Watch [YouTube video](https://www.youtube.com/watch?v=onBnfo_rJa4)**\n\n### setHeadlessWhen\n\nToggle headless mode for Puppeteer, WebDriver, TestCafe and Playwright on condition.\n\nUsage:\n\n```js\n// in codecept.conf.js\nconst { setHeadlessWhen } = require('@codeceptjs/configure');\n\n// enable headless when env var HEADLESS exists\n// Use it like:\n//\n// export HEADLESS=true \u0026\u0026 npx codeceptjs run\nsetHeadlessWhen(process.env.HEADLESS); \n\nexports.config = {\n  helpers: {\n    // standard config goes here\n    WebDriver: {} \n    // or Puppeteer\n    // or TestCafe\n  }\n}\n```\n\n* For Puppeteer, TestCafe, Playwright: it enables `show: true`.\n* For WebDriver with Chrome or Firefox browser: it adds `--headless` option to chrome/firefox options inside `desiredCapabilities`.\n\n### setHeadedWhen\n\nOpposite to [setHeadlessWhen](#setHeadlessWhen). Forces window mode for running tests.\n\n```js\n// in codecept.conf.js\nconst { setHeadlessWhen } = require('@codeceptjs/configure');\n\n// enable window mode when env var DEV exists\n// Use it like:\n//\n// export DEV=true \u0026\u0026 npx codeceptjs run\nsetHeadedWhen(process.env.DEV); \n```\n### setCommonPlugins\n\nEnables CodeceptJS plugins which are recommened for common usage.\nThe 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:\n\n```js\n// in codecept.conf.js\nconst { setCommonPlugins } = require('@codeceptjs/configure');\n\nsetCommonPlugins();\n```\n\nThese plugins will be loaded:\n\n* tryTo (enabled globally)\n* retryFailedStep (enabled globally)\n* retryTo (enabled globally)\n* eachElement (enabled globally)\n* pauseOnFail (disabled, should be turned on when needed)\n* screenshotOnFail (enable globally)\n\n### setSharedCookies\n\nShares cookies between browser and REST/GraphQL helpers.\n\nThis hooks sets `onRequest` function for REST, GraphQL, ApiDataFactory, GraphQLDataFactory.\nThis function obtains cookies from an active session in WebDriver or Puppeteer helpers.\n\n```js\n// in codecept.conf.js\nconst { setSharedCookies } = require('@codeceptjs/configure');\n\n// share cookies between browser helpers and REST/GraphQL\nsetSharedCookies();\n\nexports.config = {\n  helpers: {\n    WebDriver: {\n      // standard config goes here      \n    },\n    // or Puppeteer\n    // or TestCafe,\n    REST: {\n      // standard config goes here      \n      // onRequest: \u003c= will be set by hook\n    },\n    ApiDataFactory: {\n      // standard config goes here\n      // onRequest: \u003c= will be set by hook\n    }\n  }\n}\n\n```\n\n### setBrowser\n\nChanges browser in config for Playwright, Puppeteer, WebDriver \u0026 TestCafe:\n\n```js\nconst { setBrowser } = require('@codeceptjs/configure');\n\nsetBrowser(process.env.BROWSER);\n```\n\n### setWindowSize\n\nUniversal way to set a browser window size. For Puppeteer this launches Chrome browser with a specified width and height dimensions without changing viewport size. \n\nUsage: `setWindowSize(width, height)`.\n\n```js\n// in codecept.conf.js\nconst { setWindowSize } = require('@codeceptjs/configure');\n\nsetWindowSize(1600, 1200);\n\nexports.config = {\n  helpers: {\n    Puppeteer: {}\n  }\n}\n```\n\n### setTestHost\n\nChanges url in config for Playwright, Puppeteer, WebDriver \u0026 TestCafe:\n\n```js\nconst { setTestHost } = require('@codeceptjs/configure');\n\nsetTestHost(process.env.TEST_HOST);\n```\n\n## Contributing\n\nPlease send your config hooks!\n\nIf you feel that `codecept.conf.js` becomes too complicated, and you know how to make it simpler, \nsend a pull request with a config hook to solve your case.\n\nGood ideas for config hooks:\n\n* Setting the same window size for all browser helpers.\n* Configuring `run-multiple`\n* Changing browser in WebDriver or Protractor depending on environment variable.\n\nTo create a custom hook follow this rules.\n\n1. Create a file starting with prefix `use` in `hooks` directory.\n2. Create a js module that exports a function.\n3. Require `config` object from `codeceptjs` package.\n4. Use `config.addHook((config) =\u003e {})` to set a hook for configuration\n5. Add a test to `index.test.js`\n6. Run `npm run test`\n\nSee current hooks as examples.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fconfigure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeceptjs%2Fconfigure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeceptjs%2Fconfigure/lists"}