codeceptjs
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -127,2 +127,3 @@ #!/usr/bin/env node | ||
.option('--debug', 'output additional information') | ||
.option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated') | ||
.option('-o, --override [value]', 'override current config options') | ||
@@ -129,0 +130,0 @@ .option('-O, --reporter-options <k=v,k2=v2,...>', 'reporter-specific options') |
@@ -0,1 +1,8 @@ | ||
## 1.4.1 | ||
* Added `plugins` option to `run-multiple` | ||
* Minor output fixes | ||
* Added Type Definition for Helper class by @Akxe | ||
* Fixed extracing devault extension in generators by @Akxe | ||
## 1.4.0 | ||
@@ -2,0 +9,0 @@ |
@@ -246,2 +246,4 @@ # Acceptance Testing | ||
If it's hard to define what to wait, it is recommended to use [retries](https://codecept.io/basics/#retries) to rerun flaky steps. | ||
## IFrames | ||
@@ -248,0 +250,0 @@ |
@@ -52,4 +52,6 @@ # Basics | ||
## Pause | ||
## Debug | ||
### Pause | ||
Test execution can be paused in any place of a test with `pause()` call. | ||
@@ -78,2 +80,13 @@ This also launches interactive console where you can call actions of `I` object. | ||
### Screenshot on failure | ||
By default CodeceptJS saves a screenshot of a failed test. | ||
This can be configured in [screenshotOnFail Plugin](https://codecept.io/plugins/#screenshotonfail) | ||
### Step By Step Report | ||
To see how the test was executed, use [stepByStepReport Plugin](https://codecept.io/plugins/#stepbystepreport). It saves a screenshot of each passed step and shows them in a nice slideshow. | ||
## Before | ||
@@ -186,48 +199,3 @@ | ||
## Reporters | ||
CodeceptJS supports [Mocha Reporters](https://mochajs.org/#reporters). | ||
They can be used with `--reporter` options. | ||
By default a custom console reporter is enabled. | ||
We are currently working on improving reporters support. | ||
## Translation | ||
Because CodeceptJS tests use high level DSL it is possible to write tests using different languages. | ||
Tests can be written in Portuguese, Russian, Italian, Polish & Chinese languages using predefined [translations](http://codecept.io/translation/). | ||
## Test Options | ||
Features and Scenarios have their options that can be set by passing a hash after their names: | ||
```js | ||
Feature('My feature', {key: val}); | ||
Scenario('My scenario', {key: val}, (I) => {}); | ||
``` | ||
### Timeout | ||
By default there is no timeout for tests, however you can change this value for a specific suite: | ||
```js | ||
Feature('Stop me').timeout(5000); // set timeout to 5s | ||
``` | ||
or for the test: | ||
```js | ||
// set timeout to 1s | ||
Scenario("Stop me faster", (I) => { | ||
// test goes here | ||
}).timeout(1000); | ||
// alternative | ||
Scenario("Stop me faster", {timeout: 1000}, (I) => {}); | ||
// disable timeout for this scenario | ||
Scenario("Don't stop me", {timeout: 0}, (I) => {}); | ||
``` | ||
## Retries | ||
@@ -299,4 +267,39 @@ | ||
## Test Options | ||
Features and Scenarios have their options that can be set by passing a hash after their names: | ||
```js | ||
Feature('My feature', {key: val}); | ||
Scenario('My scenario', {key: val}, (I) => {}); | ||
``` | ||
### Timeout | ||
By default there is no timeout for tests, however you can change this value for a specific suite: | ||
```js | ||
Feature('Stop me').timeout(5000); // set timeout to 5s | ||
``` | ||
or for the test: | ||
```js | ||
// set timeout to 1s | ||
Scenario("Stop me faster", (I) => { | ||
// test goes here | ||
}).timeout(1000); | ||
// alternative | ||
Scenario("Stop me faster", {timeout: 1000}, (I) => {}); | ||
// disable timeout for this scenario | ||
Scenario("Don't stop me", {timeout: 0}, (I) => {}); | ||
``` | ||
--- | ||
### done() |
@@ -25,3 +25,3 @@ # allure | ||
codeceptjs run --plugin allure | ||
codeceptjs run --plugins allure | ||
@@ -55,2 +55,6 @@ By default, allure reports are saved to `output` directory. | ||
Run tests with plugin enabled: | ||
codeceptjs run --plugins retryFailedStep | ||
## Configuration: | ||
@@ -102,3 +106,3 @@ | ||
![](https://user-images.githubusercontent.com/220264/45696671-c58cc800-bb6c-11e8-9bd9-28396805de2b.png) | ||
![](https://codecept.io/images/codeceptjs-slideshow.gif) | ||
@@ -109,2 +113,6 @@ Generates step by step report for a test. | ||
Run tests with plugin enabled: | ||
codeceptjs run --plugins stepByStepReport | ||
## Configuration | ||
@@ -111,0 +119,0 @@ |
# QuickStart | ||
**NodeJS v 8.9** and higher required to start. | ||
CodeceptJS is multi-backend testing framework. In this guide we will use webdriverio as backend but the same rules applies to other backends like Protractor or Nightmare. | ||
CodeceptJS is multi-backend testing framework. It can execute tests using different libraries like webdriverio, Puppeteer, Protractor, etc. | ||
### Install Globally: | ||
* In this guide we will use [Google Chrome **Puppeteer**](https://github.com/GoogleChrome/puppeteer) as a driver for browsers. This allows us to start in a minutes with no extra tools installed. | ||
* If you are familiar with Selenium, you can choose classical [**Selenium WebDriver** setup](#using-selenium-webdriver). | ||
* Also, look at [complete installation reference](https://codecept.io/installation/). | ||
```sh | ||
[sudo] npm install -g codeceptjs | ||
``` | ||
Execute codeceptjs as: | ||
``` | ||
codeceptjs | ||
``` | ||
## Using Puppeteer | ||
### Install Locally | ||
```sh | ||
npm install codeceptjs --save-dev | ||
``` | ||
<video onclick="this.paused ? this.play() : this.pause();" src="/images/codeceptjs-install.mp4" style="width: 100%" controls></video> | ||
Execute codeceptjs as: | ||
1) Install CodeceptJS with Puppeteer | ||
``` | ||
./node_modules/.bin/codeceptjs | ||
npm install codeceptjs puppeteer --save-dev | ||
``` | ||
## Setup | ||
(due to [this issue in Puppeteer](https://github.com/GoogleChrome/puppeteer/issues/375), we install it locally) | ||
Initialize CodeceptJS running: | ||
2) Initialize CodeceptJS in current directory by running: | ||
```sh | ||
codeceptjs init | ||
./node_modules/.bin/codeceptjs init | ||
``` | ||
It will create `codecept.json` config in current directory (or provide path in the first argument). | ||
(use `node node_modules/.bin/codeceptjs` on Windows) | ||
You will be asked for tests location (they will be searched in current dir by default). | ||
3) Answer questions. Agree on defaults, when asked to select helpers choose **Puppeteer**. | ||
On next step you are asked to select **Helpers**. Helpers include actions which can be used in tests. | ||
We recommend to start with **WebDriverIO** helper in order to write acceptance tests using webdriverio library and Selenium Server as test runner. | ||
If you want to test AngularJS application, use Protractor helper, or if you are more familiar with official Selenium Webdriver JS library, choose it. | ||
No matter what helper you've chosen they will be similar in use. | ||
```sh | ||
? What helpers do you want to use? | ||
❯◉ WebDriverIO | ||
◯ WebDriverIO | ||
◯ Protractor | ||
◯ Puppeteer | ||
❯◉ Puppeteer | ||
◯ Appium | ||
@@ -57,46 +46,95 @@ ◯ Nightmare | ||
Then you will be asked for an output directory. Logs, reports, and failure screenshots will be placed there. | ||
4) Create First Test. | ||
```sh | ||
? Where should logs, screenshots, and reports to be stored? ./output | ||
```bash | ||
./node_modules/.bin/codeceptjs gt | ||
``` | ||
If you are going to extend test suite by writing custom steps you should probably agree to create `steps_file.js` | ||
5) Enter a test name. Open a generated file in your favorite JavaScript editor. | ||
```sh | ||
? Would you like to extend I object with custom steps? Yes | ||
? Where would you like to place custom steps? ./steps_file.js | ||
``` | ||
```js | ||
Feature('My First Test'); | ||
WebDriverIO helper will ask for additional configuration as well: | ||
Scenario('test something', (I) => { | ||
```sh | ||
? [WebDriverIO] Base url of site to be tested http://localhost | ||
? [WebDriverIO] Browser in which testing will be performed (chrome) | ||
}); | ||
``` | ||
If you agree with defaults, finish the installation. | ||
6) Write a simple scenario | ||
## Installing Backends | ||
```js | ||
Feature('My First Test'); | ||
To run CodeceptJS you will need to install a corresponding backend for the helepr you've choosen. `WebDriverIO` helper requires `webdriverio` package to be installed. The init command will notify you what libraries are missing so you could install it: | ||
Scenario('test something', (I) => { | ||
I.amOnPage('https://github.com'); | ||
I.see('GitHub'); | ||
}); | ||
``` | ||
* Global installation | ||
7) Run a test: | ||
``` | ||
Please install dependent packages globally: npm -g install webdriverio@^4.0.0 | ||
./node_modules/.bin/codeceptjs run --steps | ||
``` | ||
* Local installation | ||
The output should be similar to this: | ||
```bash | ||
My First Test -- | ||
test something | ||
• I am on page "https://github.com" | ||
• I see "GitHub" | ||
✓ OK | ||
``` | ||
Please install dependent packages locally: npm install --save-dev webdriverio@^4.0.0 | ||
Puppeteer starts a browser without showing its window. To see the browser, edit `codecept.json` config and set `show: true` for Puppeteer: | ||
```js | ||
{ | ||
"helpers": { | ||
"Puppeteer": { | ||
"url": "http://localhost", | ||
"show": true, | ||
} | ||
} | ||
} | ||
``` | ||
Please follow this steps and install required package. | ||
Rerun the test to see the browser. | ||
## Creating First Test | ||
--- | ||
Tests can be easily created by running | ||
### Next: [CodeceptJS with Puppeteer >>>](https://codecept.io/puppeteer/) | ||
### Next: [CodeceptJS Basics >>>](https://codecept.io/basics/) | ||
--- | ||
## Using Selenium WebDriver | ||
1) Install CodeceptJS with webdriverio library | ||
``` | ||
[sudo] npm install -g codeceptjs webdriverio | ||
``` | ||
2) Initialize CodeceptJS in current directory by running: | ||
```sh | ||
codeceptjs init | ||
``` | ||
3) Answer questions. Agree on defaults, when asked to select helpers choose **Puppeteer**. | ||
```sh | ||
? What helpers do you want to use? | ||
❯◉ WebDriverIO | ||
◯ Protractor | ||
◯ Puppeteer | ||
◯ Appium | ||
◯ Nightmare | ||
◯ FileSystem | ||
``` | ||
4) Create First Test. | ||
```bash | ||
@@ -106,6 +144,4 @@ codeceptjs gt | ||
*(or `generate test`)* | ||
5) Enter a test name. Open a generated file in your favorite JavaScript editor. | ||
Provide a test name and open generated file in your favorite JavaScript editor (with ES6 support). | ||
```js | ||
@@ -119,3 +155,3 @@ Feature('My First Test'); | ||
Inside the scenario block you can write your first test scenario by using [actions from WebDriverIO helper](http://codecept.io/helpers/WebDriverIO/). Let's assume we have a web server on `localhost` is running and there is a **Welcome** text on the first page. The simplest test will look like this: | ||
6) Write a simple scenario | ||
@@ -126,8 +162,8 @@ ```js | ||
Scenario('test something', (I) => { | ||
I.amOnPage('/'); | ||
I.see('Welcome'); | ||
I.amOnPage('https://github.com'); | ||
I.see('GitHub'); | ||
}); | ||
``` | ||
## Prepare Selenium Server | ||
7) Prepare Selenium Server | ||
@@ -144,14 +180,9 @@ To execute tests in Google Chrome browser running Selenium Server with ChromeDriver is required. | ||
Alternatively [Selenium Server](http://codecept.io/helpers/WebDriverIO/#selenium-installation) with [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/getting-started) can be installed and started manually. | ||
## Run | ||
8) Run a test: | ||
Execute tests: | ||
```bash | ||
``` | ||
codeceptjs run --steps | ||
``` | ||
( *steps option will display test execution process in console.* ) | ||
If everything is done right, you will see in console: | ||
@@ -162,9 +193,24 @@ | ||
test something | ||
• I am on page "/" | ||
• I see "Welcome" | ||
• I am on page "https://github.com" | ||
• I see "GitHub" | ||
✓ OK | ||
``` | ||
## Congrats! Your first test is running | ||
--- | ||
Wasn't so hard, right? | ||
### Next: [CodeceptJS Basics >>>](https://codecept.io/basics/) | ||
### Next: [Acceptance Testing in CodeceptJS >>>](https://codecept.io/puppeteer/) | ||
--- | ||
## Using Protractor | ||
[**Follow corresponding guide >>**](https://codecept.io/angular/) | ||
## Using Appium | ||
[**Follow corresponding guide >>**](https://codecept.io/mobile/) | ||
## Using NightmareJS | ||
[**Follow corresponding guide >>**](https://codecept.io/nightmare/) |
@@ -118,3 +118,3 @@ # Reporters | ||
``` | ||
codeceptjs run --plugin allure | ||
codeceptjs run --plugins allure | ||
``` | ||
@@ -121,0 +121,0 @@ |
@@ -58,2 +58,3 @@ const fsPath = require('path'); | ||
global.locate = locator => require('./locator').build(locator); | ||
global.codeceptjs = require('./index'); // load all objects | ||
@@ -60,0 +61,0 @@ // BDD |
@@ -41,2 +41,42 @@ const getConfig = require('./utils').getConfig; | ||
declare class Helper { | ||
/** Abstract method to provide required config options */ | ||
static _config(): any; | ||
/** Abstract method to validate config */ | ||
_validateConfig<T>(config: T): T; | ||
/** Sets config for current test */ | ||
_setConfig(opts: any): void; | ||
/** Hook executed before all tests */ | ||
_init(): void | ||
/** Hook executed before each test. */ | ||
_before(): void | ||
/** Hook executed after each test */ | ||
_after(): void | ||
/** | ||
* Hook provides a test details | ||
* Executed in the very beginning of a test | ||
*/ | ||
_test(test): void | ||
/** Hook executed after each passed test */ | ||
_passed(test: () => void): void | ||
/** Hook executed after each failed test */ | ||
_failed(test: () => void): void | ||
/** Hook executed before each step */ | ||
_beforeStep(step: () => void): void | ||
/** Hook executed after each step */ | ||
_afterStep(step: () => void): void | ||
/** Hook executed before each suite */ | ||
_beforeSuite(suite: () => void): void | ||
/** Hook executed after each suite */ | ||
_afterSuite(suite: () => void): void | ||
/** Hook executed after all tests are executed */ | ||
_finishTest(suite: () => void): void | ||
/**Access another configured helper: this.helpers['AnotherHelper'] */ | ||
get helpers(): any | ||
/** Print debug message to console (outputs only in debug mode) */ | ||
debug(msg: string): void | ||
debugSection(section: string, msg: string): void | ||
} | ||
declare class Locator implements ILocator { | ||
@@ -68,4 +108,8 @@ xpath?: string; | ||
declare function Feature(title: string, opts?: {}): FeatureConfig; | ||
declare function Scenario(title: string, callback: ICodeceptCallback): ScenarioConfig; | ||
declare function Scenario(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig; | ||
declare const Scenario: { | ||
(title: string, callback: ICodeceptCallback): ScenarioConfig; | ||
(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig; | ||
only(title: string, callback: ICodeceptCallback): ScenarioConfig; | ||
only(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig; | ||
} | ||
declare function xScenario(title: string, callback: ICodeceptCallback): ScenarioConfig; | ||
@@ -90,3 +134,3 @@ declare function xScenario(title: string, opts: {}, callback: ICodeceptCallback): ScenarioConfig; | ||
declare const codecept_helper: any; | ||
declare const codeceptjs: any; | ||
@@ -93,0 +137,0 @@ declare namespace CodeceptJS { |
@@ -29,3 +29,3 @@ const output = require('../output'); | ||
const defaultExt = config.tests.match(/\*(.*?)$/[1])[0] || '_test.js'; | ||
const defaultExt = config.tests.match(/([^\*/]*?)$/[1])[0] || '_test.js'; | ||
@@ -32,0 +32,0 @@ inquirer.prompt([ |
@@ -17,3 +17,3 @@ const { | ||
const childOpts = {}; | ||
const copyOptions = ['override', 'steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'debug']; | ||
const copyOptions = ['override', 'steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'debug', 'plugins']; | ||
@@ -20,0 +20,0 @@ // codeceptjs run:multiple smoke:chrome regression:firefox - will launch smoke run in chrome and regression in firefox |
@@ -168,3 +168,3 @@ const colors = require('chalk'); | ||
} | ||
const width = (process.stdout.columns || 200) - gap - 1; | ||
const width = (process.stdout.columns || 200) - gap - 4; | ||
if (msg.length > width) { | ||
@@ -171,0 +171,0 @@ msg = msg.substr(0, width - 1) + figures.ellipsis; |
@@ -34,3 +34,3 @@ const event = require('../event'); | ||
* ``` | ||
* codeceptjs run --plugin allure | ||
* codeceptjs run --plugins allure | ||
* ``` | ||
@@ -37,0 +37,0 @@ * |
@@ -21,2 +21,9 @@ const event = require('../event'); | ||
* | ||
* | ||
* Run tests with plugin enabled: | ||
* | ||
* ``` | ||
* codeceptjs run --plugins retryFailedStep | ||
* ``` | ||
* | ||
* ## Configuration: | ||
@@ -23,0 +30,0 @@ * |
@@ -30,3 +30,3 @@ const Container = require('../container'); | ||
/** | ||
* ![](https://user-images.githubusercontent.com/220264/45696671-c58cc800-bb6c-11e8-9bd9-28396805de2b.png) | ||
* ![](https://codecept.io/images/codeceptjs-slideshow.gif) | ||
* | ||
@@ -37,2 +37,9 @@ * Generates step by step report for a test. | ||
* | ||
* | ||
* Run tests with plugin enabled: | ||
* | ||
* ``` | ||
* codeceptjs run --plugins stepByStepReport | ||
* ``` | ||
* | ||
* ## Configuration | ||
@@ -39,0 +46,0 @@ * |
@@ -30,7 +30,6 @@ const Base = require('mocha/lib/reporters/base'); | ||
if (showSteps) { | ||
if (level >= 2) { | ||
const Containter = require('../container'); | ||
output.print(); | ||
output.print(output.styles.debug(`Enabled Helpers: ${Object.keys(Containter.helpers()).join(', ')}`)); | ||
output.print(output.styles.debug(`Enabled Plugins: ${Object.keys(Containter.plugins()).join(', ')}`)); | ||
output.print(output.styles.debug(`Helpers: ${Object.keys(Containter.helpers()).join(', ')}`)); | ||
output.print(output.styles.debug(`Plugins: ${Object.keys(Containter.plugins()).join(', ')}`)); | ||
} | ||
@@ -37,0 +36,0 @@ |
{ | ||
"name": "codeceptjs", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Modern Era Acceptance Testing Framework for NodeJS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1187231
24585