Quickstart
Install CodeceptJS into your project:
npm install codeceptjs playwright --save-devThen install the browser binaries:
npx playwright install --with-depsThe --with-deps flag also installs required system dependencies for the browsers.
Prefer WebDriver or Appium? See installation options for all supported helpers.
Initialize CodeceptJS to set up the config file and test directory:
npx codeceptjs initThis command walks you through a short setup wizard and creates codecept.conf.js, a sample test file, and any required browser binaries.
Answer the questions, accepting defaults to get started quickly:
| Question | Default Answer | Alternative |
|---|---|---|
| Do you plan to write tests in TypeScript? | n (No) | or learn how to use TypeScript |
| Where are your tests located? | **./*_test.js | or any glob pattern like **.spec.js |
| What helpers do you want to use? | Playwright | See options for web testing, mobile testing, API testing |
| Where should logs, screenshots, and reports be stored? | ./output | path to store artifacts and temporary files |
For Playwright, you’ll also be asked about the site and browser:
| Question | Default Answer | Alternative |
|---|---|---|
| Base url of site to be tested | http://localhost | URL of the site you plan to test |
| Show browser window | y Yes | or run in headless mode |
| Browser | chromium | or firefox, webkit (open-source Safari), or electron |
Sample output:
? Do you plan to write tests in TypeScript? No? Where are your tests located? **./*_test.js? What helpers do you want to use? Playwright? Where should logs, screenshots, and reports be stored? ./output? [Playwright] Base url of site to be tested http://localhost? [Playwright] Show browser window Yes? [Playwright] Browser in which testing will be performed chromiumWhen asked, create your first feature and test file.
Write Your First Test
Section titled “Write Your First Test”Open the generated test file. It will look like this:
Feature('My First Test');
Scenario('test something', ({ I }) => {
});Add a simple scenario:
Feature('My First Test');
Scenario('test something', ({ I }) => { I.amOnPage('https://github.com'); I.see('GitHub');});Run Tests
Section titled “Run Tests”npx codeceptjs runExpected output:
My First Test -- test something I am on page "https://github.com" I see "GitHub" ✓ OKRun in headless mode:
npx codeceptjs run --headlessSee all available commands in the CLI reference.