QuickStart

NodeJS v 8.9 and higher required to start. CodeceptJS is multi-backend testing framework. It can execute tests using different libraries like webdriverio, Puppeteer, Protractor, etc.

Using Puppeteer

1) Install CodeceptJS with Puppeteer

npm install codeceptjs puppeteer --save-dev

(due to this issue in Puppeteer, we install it locally)

2) Initialize CodeceptJS in current directory by running:

./node_modules/.bin/codeceptjs init

(use node node_modules/.bin/codeceptjs on Windows)

3) Answer questions. Agree on defaults, when asked to select helpers choose Puppeteer.

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

4) Create First Test.

./node_modules/.bin/codeceptjs gt

5) Enter a test name. Open a generated file in your favorite JavaScript editor.

Feature('My First Test');

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

});

6) Write a simple scenario

Feature('My First Test');

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

7) Run a test:

./node_modules/.bin/codeceptjs run --steps

The output should be similar to this:

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

Puppeteer starts a browser without showing its window. To see the browser, edit codecept.json config and set show: true for Puppeteer:

{
  "helpers": {
    "Puppeteer": {
      "url": "http://localhost",
      "show": true,
    }
  }
}

Rerun the test to see the browser.


Next: CodeceptJS with Puppeteer >>>

Next: CodeceptJS Basics >>>

Next: Demo Project


Using Selenium WebDriver

1) Install CodeceptJS with webdriverio library

[sudo] npm install -g codeceptjs webdriverio

2) Initialize CodeceptJS in current directory by running:

codeceptjs init

3) Answer questions. Agree on defaults, when asked to select helpers choose WebDriverIO.

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

4) Create First Test.

codeceptjs gt

5) Enter a test name. Open a generated file in your favorite JavaScript editor.

Feature('My First Test');

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

});

6) Write a simple scenario

Feature('My First Test');

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

7) Prepare Selenium Server

To execute tests in Google Chrome browser running Selenium Server with ChromeDriver is required.

Use selenium-standalone from NPM to install and run them:

[sudo] npm install -g selenium-standalone
selenium-standalone install
selenium-standalone start

8) Run a test:

codeceptjs run --steps

If everything is done right, you will see in console:

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

Next: CodeceptJS Basics >>>

Next: Acceptance Testing in CodeceptJS >>>


Using Protractor

Follow corresponding guide >>

Using Appium

Follow corresponding guide >>

Using NightmareJS

Follow corresponding guide >>