Skip to content

Commit 8ea670a

Browse files
authored
preparing for 1.1.0 release: changelog, docs updates, deps removal (#831)
1 parent e836a7e commit 8ea670a

File tree

14 files changed

+521
-730
lines changed

14 files changed

+521
-730
lines changed

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
## 1.1.0
2+
3+
Major update to CodeceptJS. **NodeJS v 8.9.1** is now minimal Node version required.
4+
This brings native async-await support to CodeceptJS. It is recommended to start using await for tests instead of generators:
5+
6+
```js
7+
async () => {
8+
I.amOnPage('/page');
9+
const url = await I.grabTextFrom('.nextPage');
10+
I.amOnPage(url);
11+
}
12+
```
13+
14+
Thanks to [@Apshenkin](https://github.com/apshenkin) for implementation. Also, most helpers were refactored to use async-await. This made our code simpler. We hope that this encourages more users to send pull requests!
15+
16+
We also introduced strict ESLint policies for our codebase. Thanks to **[@Galkin](https://github.com/galkin)** for that.
17+
18+
* **[Puppeteer] Helper introduced**. [Learn how to run tests headlessly with Google Chrome's Puppeteer](http://codecept.io/puppeteer/).
19+
* **[SeleniumWebdriver] Helper is deprecated**, it is recommended to use Protractor with config option `angular: false` instead.
20+
* [WebDriverIO] nested iframe support in the within block by @reubenmiller. Example:
21+
22+
```js
23+
within({frame: ['#wrapperId', '[name=content]']}, () => {
24+
I.click('Sign in!');
25+
I.see('Email Address');
26+
});
27+
I.see('Nested Iframe test');
28+
I.dontSee('Email Address');
29+
});
30+
```
31+
* [WebDriverIO] Support for `~` locator to find elements by `aria-label`. This behavior is similar as it is in Appium and helps testing cross-platform React apps. Example:
32+
33+
```html
34+
<Text accessibilityLabel="foobar">
35+
CodeceptJS is awesome
36+
</Text>
37+
```
38+
↑ This element can be located with `~foobar` in WebDriverIO and Appium helpers. Thanks to @flyskywhy
39+
40+
* Allow providing arbitrary objects in config includes by @rlewan
41+
* [REST] Prevent from mutating default headers by @alexashley. See [#789](https://github.com/Codeception/CodeceptJS/pull/789)
42+
* [REST] Fixed sending empty helpers with `haveRequestHeaders` in `sendPostRequest`. By @petrisorionel
43+
* Fixed displaying undefined args in output by @APshenkin
44+
* Fixed NaN instead of seconds in output by @APshenkin
45+
* Add browser name to report file for `multiple-run` by @trollr
46+
* Mocha updated to 4.x
47+
48+
49+
150
## 1.0.3
251

352
* [WebDriverIO][Protractor][Nightmare] method `waitUntilExists` implemented by @sabau

docs/acceptance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ within({frame: [".content", "#editor"]}, () => {
256256
I.see('Page');
257257
});
258258
```
259-
260259
---
261260

262261
### done()
263262

264263
CodeceptJS through helpers provides user friendly API to interact with a webpage. In this section we described using WebDriverIO helper which allows to control browser through Selenium WebDriver.
264+

docs/angular.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# AngularJS E2E Testing with CodeceptJS
1+
# Protractor Testing with CodeceptJS
22

33
## Introduction
44

55
CodeceptJS is an acceptance testing framework. In diversified world of JavaScript testing libraries it aims to create a unified high level API for end-to-end testing, powered by different backends.
6-
CodeceptJS allows you to write a test and switch in config execution drivers: will it be *wedriverio*, *selenium-webdriver*, or *protractor* depends on you.
6+
CodeceptJS allows you to write a test and switch in config execution drivers: will it be *wedriverio*, *puppeteer*, or *protractor* depends on you.
77
This way you aren't be bound to implementation, and your acceptance tests will work no matter of framework running them.
88

99
As you know, [Protractor](http://www.protractortest.org/#/) is an official tool for testing AngularJS applications.
@@ -96,7 +96,7 @@ For TodoMVC application you will have following config created in `codecept.json
9696
"Protractor": {
9797
"url": "http://todomvc.com/examples/angularjs/",
9898
"driver": "hosted",
99-
"browser": "firefox",
99+
"browser": "chrome",
100100
"rootElement": "body"
101101
}
102102
},
@@ -264,6 +264,21 @@ Scenario('create todo item', (I) => {
264264

265265
To learn more about refactoring options in CodeceptJS read [PageObjects guide](http://codecept.io/pageobjects/).
266266

267+
### Testing non-Angular Applications
268+
269+
Sure, Protractor can be used to test applications built without AngularJS. In this case you need to disable angular synchronization feature in config:
270+
271+
```js
272+
"helpers": {
273+
"Protractor": {
274+
"url": "http://todomvc.com/examples/angularjs/",
275+
"driver": "hosted",
276+
"browser": "firefox",
277+
"angular": false
278+
}
279+
}
280+
```
281+
267282
### Extending
268283

269284
What if CodeceptJS doesn't provide some of Protractor functionality you actually need? Sure its API is to general,

docs/basics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ I object is an **actor**, an abstraction for a testing user. I is a proxy object
1919
"helpers": {
2020
"WebDriverIO": {
2121
"url": "http://localhost",
22-
"browser": "firefox"
22+
"browser": "chrome"
2323
}
2424
}
2525
```
@@ -36,15 +36,15 @@ However, behind the scene **all actions are wrapped in promises** inside the `I`
3636
If you want to get information from a running test you can use `yield` inside a **generator function** and special methods of helpers started with `grab` prefix.
3737

3838
```js
39-
Scenario('try grabbers', function* (I) {
40-
var title = yield I.grabTitle();
39+
Scenario('try grabbers', async (I) => {
40+
var title = await I.grabTitle();
4141
});
4242
```
4343

4444
then you can use those variables in assertions:
4545

4646
```js
47-
var title = yield I.grabTitle();
47+
var title = await I.grabTitle();
4848
var assert = require('assert');
4949
assert.equal(title, 'CodeceptJS');
5050
```

docs/helpers.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,22 @@ class MyHelper extends Helper {
8383
/**
8484
* checks that authentication cookie is set
8585
*/
86-
seeAuthentication() {
86+
async seeAuthentication() {
8787
// access current client of WebDriverIO helper
8888
let client = this.helpers['WebDriverIO'].browser;
8989

9090
// get all cookies according to http://webdriver.io/api/protocol/cookie.html
9191
// any helper method should return a value in order to be added to promise chain
92-
return client.cookie(function(err, res) {
93-
// get values
94-
let cookies = res.value;
95-
for (let k in cookies) {
96-
// check for a cookie
97-
if (cookies[k].name != 'logged_in') continue;
98-
assert.equal(cookies[k].value, 'yes');
99-
return;
100-
}
101-
assert.fail(cookies, 'logged_in', "Auth cookie not set");
102-
});
92+
const res = await client.cookie();
93+
// get values
94+
let cookies = res.value;
95+
for (let k in cookies) {
96+
// check for a cookie
97+
if (cookies[k].name != 'logged_in') continue;
98+
assert.equal(cookies[k].value, 'yes');
99+
return;
100+
}
101+
assert.fail(cookies, 'logged_in', "Auth cookie not set");
103102
}
104103
}
105104

docs/installation.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,8 @@
11
# Installation
22

3-
## Global
4-
5-
CodeceptJS can be installed via NPM globally
6-
7-
```sh
8-
[sudo] npm install -g codeceptjs
9-
```
10-
11-
then it can be started as
12-
13-
```sh
14-
codeceptjs
15-
```
16-
17-
To use it with WebDriverIO install webdriverio package globally:
18-
19-
```sh
20-
[sudo] npm install -g webdriverio
21-
```
22-
23-
To use it with Protractor install protractor package globally:
24-
25-
```sh
26-
[sudo] npm install -g protractor
27-
```
28-
29-
To use it with Nightmare install nightmare and nightmare-upload packages globally:
30-
31-
```sh
32-
[sudo] npm install -g nightmare nightmare-upload
33-
```
34-
353
### Local
364

37-
CodeceptJS can also be installed locally
5+
Use NPM install CodeceptJS:
386

397
```sh
408
npm install --save-dev codeceptjs
@@ -64,14 +32,34 @@ To use it with Nightmare install nightmare and nightmare-upload packages:
6432
npm install nightmare nightmare-upload --save-dev
6533
```
6634

35+
To use it with Puppeteer install puppeteer package:
36+
37+
```sh
38+
npm install puppeteer --save-dev
39+
```
40+
41+
6742
## Meta Packages
6843

6944
By default it doesn't install any backends like Webdriverio, Protractor, or Nightmare, so you need to install corresponding packages manually, or install one of the provided meta-packages:
7045

7146
* [codeceptjs-webdriverio](https://www.npmjs.com/package/codeceptjs-webdriverio) - installs CodeceptJS + WebDriverIO
7247
* [codeceptjs-protractor](https://www.npmjs.com/package/codeceptjs-protractor) - installs CodeceptJS + Protractor
48+
* [codeceptjs-puppeteer](https://www.npmjs.com/package/codeceptjs-puppeteer) - installs CodeceptJS + Puppeteer
7349
* [codeceptjs-nightmare](https://www.npmjs.com/package/codeceptjs-nightmare) - installs CodeceptJS + Nightmare
7450

51+
Install them using NPM:
52+
53+
```sh
54+
[sudo] npm install codeceptjs-webdriverio
55+
# or
56+
[sudo] npm install codeceptjs-protractor
57+
# or
58+
[sudo] npm install codeceptjs-puppeteer
59+
# or
60+
[sudo] npm install codeceptjs-nightmare
61+
```
62+
7563
They can be installed either globally or locally
7664

7765
## WebDriver
@@ -89,4 +77,24 @@ Launch Selenium with Chrome browser inside a Docker container:
8977

9078
```sh
9179
docker run --net=host selenium/standalone-chrome
92-
```
80+
```
81+
82+
## Global
83+
84+
CodeceptJS can be installed via NPM globally, in this case it is recommended to use meta-packages for installation:
85+
86+
```sh
87+
[sudo] npm install -g codeceptjs-webdriverio
88+
# or
89+
[sudo] npm install -g codeceptjs-protractor
90+
# or
91+
[sudo] npm install -g codeceptjs-puppeteer
92+
# or
93+
[sudo] npm install -g codeceptjs-nightmare
94+
```
95+
96+
then it can be started as
97+
98+
```sh
99+
codeceptjs
100+
```

docs/nightmare.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,23 @@ so you can access them in next calls to `evaluate`:
187187

188188
```js
189189
// inside a custom helper class
190-
seeAttributeContains(locator, attribute, expectedValue) {
190+
async seeAttributeContains(locator, attribute, expectedValue) {
191191
// let's use chai assertion library
192-
let assert = require('chai').assert;
192+
const assert = require('chai').assert;
193193
// get nightmare instance
194-
let browser = this.helpers['Nightmare'].browser;
194+
const browser = this.helpers['Nightmare'].browser;
195195
// find an element by CSS or XPath:
196-
return this.helpers['Nightmare']._locate(locator).then(function(els) {
196+
const els = await this.helpers['Nightmare']._locate(locator);
197197
// we received an array with IDs of matched elements
198198
// now let's execute client-side script to get attribute for the first element
199-
return browser.evaluate(function(el, attribute) {
199+
const attributeValue = await browser.evaluate(function(el, attribute) {
200200
// this is executed inside a web page!
201201
return codeceptjs.fetchElement(el).getAttribute(attribute);
202-
}, els[0], attribute); // function + its params
203-
}).then(function(attributeValue) {
202+
}, els[0], attribute); // function + its params
203+
204204
// get attribute value and back to server side
205205
// execute an assertion
206-
assert.include(attributeValue, expectedValue);
207-
});
206+
assert.include(attributeValue, expectedValue);
208207
}
209208
```
210209

docs/pageobjects.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ module.exports = {
130130
},
131131

132132
// introducing methods
133-
openMainArticle: function* () {
133+
openMainArticle: async () => {
134134
I.waitForVisible(this.container)
135135
let _this = this
136136
let title;
137-
yield within(this.container, function*(){
138-
title = yield I.grabTextFrom(_this.mainItem.number);
139-
let subtitle = yield I.grabTextFrom(_this.mainItem.title);
137+
await within(this.container, async () => {
138+
title = await I.grabTextFrom(_this.mainItem.number);
139+
let subtitle = await I.grabTextFrom(_this.mainItem.title);
140140
title = title + " " + subtitle.charAt(0).toLowerCase() + subtitle.slice(1);
141-
yield I.click(_this.mainItem.title)
141+
await I.click(_this.mainItem.title)
142142
})
143143
return title;
144144
}
@@ -148,8 +148,8 @@ module.exports = {
148148
and use them in your tests:
149149

150150
```js
151-
Scenario('login2', function* (I, loginPage, basePage) {
152-
let title = yield* mainPage.openMainArticle()
151+
Scenario('login2', async (I, loginPage, basePage) => {
152+
let title = await mainPage.openMainArticle()
153153
basePage.pageShouldBeOpened(title)
154154
});
155155
```

docs/quickstart.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# QuickStart
22

3-
**NodeJS v 6.11.1** and higher required to start.
3+
**NodeJS v 8.9** and higher required to start.
44
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.
55

66
Install **CodeceptJS** with WebDriverIO using `codeceptjs-webdriverio` meta package from NPM.
@@ -17,8 +17,9 @@ or locally
1717
npm install codeceptjs-webdriverio --save-dev
1818
```
1919

20-
* To test with Nightmare install `codeceptjs-nightmare` package
20+
* To test with Puppeteer install `codeceptjs-puppeteer` package
2121
* To test with Protractor install `codeceptjs-protractor` package
22+
* To test with Nightmare install `codeceptjs-nightmare` package
2223
* For additional options see [Installation guide](http://codecept.io/installation/).
2324

2425
## Setup
@@ -42,7 +43,7 @@ No matter what helper you've chosen they will be similar in use.
4243
? What helpers do you want to use?
4344
❯◉ WebDriverIO
4445
◯ Protractor
45-
SeleniumWebdriver
46+
Puppeteer
4647
◯ Nightmare
4748
◯ FileSystem
4849
```

lib/command/run-multiple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function runSuite(suite, suiteConf, browser) {
110110
// tweaking default output directories and for mochawesome
111111
overriddenConfig = replaceValue(overriddenConfig, 'output', path.join(config.output, outputDir));
112112
overriddenConfig = replaceValue(overriddenConfig, 'reportDir', path.join(config.output, outputDir));
113-
overriddenConfig = replaceValue(overriddenConfig, 'mochaFile', path.join(config.output, outputDir, browser + '_report.xml'));
113+
overriddenConfig = replaceValue(overriddenConfig, 'mochaFile', path.join(config.output, outputDir, `${browser}_report.xml`));
114114

115115
// override grep param and collect all params
116116
const params = ['run',

0 commit comments

Comments
 (0)