Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
215 lines (142 sloc) 4.21 KB
id title
quickstart
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)

  1. Initialize CodeceptJS in current directory by running:
./node_modules/.bin/codeceptjs init

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

  1. Answer questions. Agree on defaults, when asked to select helpers choose Puppeteer.
? What helpers do you want to use?
 ◯ WebDriver
 ◯ Protractor
❯◉ Puppeteer
 ◯ Appium
 ◯ Nightmare
 ◯ FileSystem
  1. Create First Test.
./node_modules/.bin/codeceptjs gt
  1. Enter a test name. Open a generated file in your favorite JavaScript editor.
Feature('My First Test');

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

});
  1. Write a simple scenario
Feature('My First Test');

Scenario('test something', (I) => {
  I.amOnPage('https://github.com');
  I.see('GitHub');
});
  1. 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
  1. Initialize CodeceptJS in current directory by running:
codeceptjs init
  1. Answer questions. Agree on defaults, when asked to select helpers choose WebDriver.
? What helpers do you want to use?
❯◉ WebDriver
 ◯ Protractor
 ◯ Puppeteer
 ◯ Appium
 ◯ Nightmare
 ◯ FileSystem
  1. Create First Test.
codeceptjs gt
  1. Enter a test name. Open a generated file in your favorite JavaScript editor.
Feature('My First Test');

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

});
  1. Write a simple scenario
Feature('My First Test');

Scenario('test something', (I) => {
  I.amOnPage('https://github.com');
  I.see('GitHub');
});
  1. 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
  1. 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 >>