Quickstart

CodeceptJS supports various engines for running browser tests. By default we recommend using Playwright which is cross-browser and performant solution.

Use CodeceptJS all-in-one installer (opens new window) to get CodeceptJS, a demo project, and Playwright.

npx create-codeceptjs .

Installation

To install codeceptjs into a different folder, like tests use npx create-codeceptjs tests

After CodeceptJS is installed, try running demo tests using this commands:

  • npm run codeceptjs:demo - executes demo tests in window mode
  • npm run codeceptjs:demo:headless - executes demo tests in headless mode
  • npm run codeceptjs:demo:ui - open CodeceptJS UI to list and run demo tests.

CodeceptJS UI application:

To start a new project initialize CodeceptJS to create main config file: codecept.conf.js.

npx codeceptjs init

Answer questions, agree on defaults, when asked to select helpers choose Playwright.

? What helpers do you want to use?
❯◉ Playwright
 ◯ WebDriver
 ◯ Protractor
 ◯ Puppeteer
 ◯ Appium
 ◯ Nightmare
 ◯ FileSystem

Create first feature and test when asked. Open a newly created file in your favorite JavaScript editor. The file should look like this:

Feature('My First Test');

Scenario('test something', ({ I }) => {

});

Write a simple test scenario:

Feature('My First Test');

Scenario('test something', ({ I }) => {
  I.amOnPage('https://github.com');
  I.see('GitHub');
});

Run a test:

npm run codeceptjs

The output should be similar to this:

My First Test --
  test something
     I am on page "https://github.com"
     I see "GitHub"
 ✓ OK

To quickly execute tests use following npm scripts:

After CodeceptJS is installed, try running demo tests using this commands:

  • npm run codeceptjs - executes tests in window mode
  • npm run codeceptjs:headless - executes tests in headless mode
  • npm run codeceptjs:ui - open CodeceptJS UI to list and run tests.

More commands available in CodeceptJS CLI runner (opens new window).

▶ Next: CodeceptJS Basics

▶ Next: CodeceptJS with Playwright

© 2015 DavertMik <[email protected]> (http://codegyre.com)
Licensed under the MIT License.
https://codecept.io/quickstart/