Skip to content

Commit 4d40c77

Browse files
authored
Rebase 3.x (#5282)
1 parent 0155120 commit 4d40c77

File tree

238 files changed

+18348
-2405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+18348
-2405
lines changed

.github/CONTRIBUTING.md

Lines changed: 63 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22

33
Thanks for getting here. If you have a good will to improve CodeceptJS we are always glad to help. Ask questions, raise issues, ping in Twitter.
44

5-
Go over the steps in [this](https://github.com/firstcontributions/first-contributions) guide as first contributions
6-
75
To start you need:
86

9-
1. Fork and clone the repo.
10-
2. Run `npm i --force` to install all required libraries
11-
3. Do the changes.
12-
4. Add/Update Test (if possible)
13-
5. Update documentation
14-
6. Run `npm run def` to generate types
15-
7. Run `npm run docs` if you change the documentation
16-
8. Commit and Push to your fork
17-
9. Make Pull Request
7+
1. Fork the repo.
8+
2. Run `npm install` to install all required libraries
9+
3. Run `npm run def`to generate types
10+
4. Do the changes.
11+
5. Add/Update Test (if possible)
12+
6. Update documentation
13+
7. Commit and Push to your fork
14+
8. Make Pull Request
1815

1916
To run codeceptjs from this repo use:
2017

@@ -28,28 +25,21 @@ To run examples:
2825
node bin/codecept.js run -c examples
2926
```
3027

31-
Depending on a type of change you should do the following.
32-
33-
## Debugging
3428

35-
To see recorder queue in logs enable NodeJS debug output by passing `DEBUG=codeceptjs:*` env variable:
36-
37-
```
38-
DEBUG=codeceptjs:* npx codeceptjs run
39-
```
29+
Depending on a type of a change you should do the following.
4030

4131
## Helpers
4232

43-
Please keep in mind that CodeceptJS have **unified API** for Playwright, WebDriverIO, Appium, Puppeteer, TestCafe. Tests written using those helpers should be compatible at syntax level. However, some helpers may contain unique methods. That happens. If, for instance, WebDriverIO has method XXX and Playwright doesn't, you can implement XXX inside Playwright using the same method signature.
33+
Please keep in mind that CodeceptJS have **unified API** for WebDriver, Appium, Playwright, and Puppeteer. Tests written using those helpers should be compatible at syntax level. However, some of helpers may contain unique methods. That happens. If, for instance, WebDriver has method XXX and Playwright doesn't, you can implement XXX inside Playwright using the same method signature.
4434

45-
### Updating Playwright | Puppeteer | WebDriver
35+
### Updating a WebDriver | Playwright | Puppeteer
4636

47-
_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! _
37+
*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! *
4838

4939
Working test is highly appreciated. To run the test suite you need:
5040

51-
- selenium server + chromedriver
52-
- PHP installed
41+
* selenium server + chromedriver
42+
* PHP installed
5343

5444
To launch PHP demo application run:
5545

@@ -60,8 +50,9 @@ php -S 127.0.0.1:8000 -t test/data/app
6050
Execute test suite:
6151

6252
```sh
63-
mocha test/helper/WebDriver_test.js
53+
mocha test/helper/WebDriverIO_test.js
6454
mocha test/helper/Puppeteer_test.js
55+
mocha test/helper/Nightmare_test.js
6556
```
6657

6758
Use `--grep` to execute tests only for changed parts.
@@ -80,9 +71,21 @@ Then is should be accessible at:
8071
http://localhost:8000/form/myexample
8172
```
8273

74+
### Updating Protractor
75+
76+
*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! *
77+
78+
Protractor helper is based on [Protractor library](http://www.protractortest.org)
79+
80+
In case you do Protractor-specific change, please add a test:To run the test suite you need:
81+
82+
* selenium server + chromedriver
83+
84+
Demo application is located at: [http://davertmik.github.io/angular-demo-app](http://davertmik.github.io/angular-demo-app)
85+
8386
### Updating REST | ApiDataFactory
8487

85-
_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required!_
88+
*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required!*
8689

8790
Adding a test is highly appreciated.
8891

@@ -96,20 +99,30 @@ Edit a test at `test/rest/REST_test.js` or `test/rest/ApiDataFactory_test.js`
9699

97100
## Appium
98101

99-
_Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! _
102+
*Whenever a new method or new behavior is added it should be documented in a docblock. Valid JS-example is required! Do **not edit** `docs/helpers/`, those files are generated from docblocks in corresponding helpers! *
100103

101104
It is recommended to run mobile tests on CI.
102105
So do the changes, make pull request, see the CI status.
103-
Appium tests are executed at **Saucelabs**.
106+
Appium tests are executed at **Semaphore CI**.
104107

105108
## Core Changes
106109

107110
Before applying any Core changes please raise an issue to discuss that change with core team.
108111
Please try to add corresponding testcase to runner or unit.
109112

113+
## Typings
114+
115+
Typings is generated in `typings/` directory via `jsdoc`
116+
117+
After you updated docblock in JS file, generate typing files with next command:
118+
119+
```
120+
npm run def
121+
```
122+
110123
## Documentation
111124

112-
Documentation is stored in `/docs` directory in Markdown format.
125+
Documentation is stored in `/docs` directory in markdown format.
113126

114127
**Documentation for helpers is a part of a source code**.
115128

@@ -121,52 +134,17 @@ After you updated docblock in JS file, generate markdown files with next command
121134
npm run docs
122135
```
123136

124-
Documentation parts can be shared across helpers. Those parts are located in `docs/webapi/*.mustache`. Inside a docblock those files can be included like this:
125-
126-
```js
127-
/**
128-
* {{> click }}
129-
*/
130-
click() {
131-
// ...
132-
}
133-
```
134-
135-
_Note:_ Due to the (lib)[https://documentation.js.org/] that we are using to generate docs, the fast and cheap way to fix format issue that text after the mustache template is appended without formatting is moving the texts to above the mustache template.
136-
137-
```js
138-
/**
139-
* // Before
140-
* Click action
141-
* {{> click }}
142-
* Click action
143-
*/
144-
click() {
145-
// ...
146-
}
147-
```
137+
Documentation parts can be shared accross helpers. Those parts are located in `docs/webapi/*.mustache`. Inside a docblock those files can be included like this:
148138

149139
```js
150140
/**
151-
* // After
152-
* Click action
153141
* {{> click }}
154142
*/
155143
click() {
156144
// ...
157145
}
158146
```
159147

160-
## Typings
161-
162-
Typings are generated in `typings/` directory via `jsdoc`
163-
164-
After you updated docblock in JS file, generate typing files with next command:
165-
166-
```
167-
npm run def
168-
```
169-
170148
## Testing
171149

172150
Whenever you implemented a feature/bugfix
@@ -188,7 +166,7 @@ mocha test/runner
188166
Instead of manually running php, json_server and selenium for before tests you
189167
can use `docker-compose` to run those automatically.
190168
You can find `docker-compose.yml` file in `test` directory and run all commands
191-
from this directory. Currently, we provide following commands to run tests with
169+
from this directory. Currently we provide following commands to run tests with
192170
respective dependencies:
193171

194172
#### Run unit tests
@@ -203,25 +181,28 @@ docker-compose run --rm test-unit
203181
docker-compose run --rm test-helpers
204182

205183
# or pass path to helper test to run specific helper,
206-
# for example to run only WebDriver tests:
207-
docker-compose run --rm test-helpers test/helper/WebDriver_test.js
184+
# for example to run only WebDriverIO tests:
185+
docker-compose run --rm test-helpers test/helper/WebDriverIO_test.js
208186

209187
# Or to run only rest and ApiDataFactory tests
210188
docker-compose run --rm test-helpers test/rest
211189
```
212190

213191
#### Run acceptance tests
214192

215-
To that we provide three separate services respectively for WebDriver, Nightmare and Puppeteer tests:
193+
To that we provide three separate services respectively for WebDriverIO, Nightmare, Puppeteer and
194+
Protractor tests:
216195

217196
```sh
218197
docker-compose run --rm test-acceptance.webdriverio
198+
docker-compose run --rm test-acceptance.nightmare
219199
docker-compose run --rm test-acceptance.puppeteer
200+
docker-compose run --rm test-acceptance.protractor
220201
```
221202

222203
#### Running against specific Node version
223204

224-
By default, dockerized tests are run against node 12.10.0, you can run it against
205+
By default dockerized tests are run against node 12.10.0, you can run it against
225206
specific version as long as there is Docker container available for such
226207
version. To do that you need to build codecept's Docker image prior to running
227208
tests and pass `NODE_VERSION` as build argument.
@@ -236,17 +217,26 @@ And now every command based on `test-helpers` service will use node 9.4.0. The
236217
same argument can be passed when building unit and acceptance tests services.
237218

238219
### CI flow
239-
240-
We're currently using a bunch of CI services to build and test codecept in
220+
We're currently using bunch of CI services to build and test codecept in
241221
different environments. Here's short summary of what are differences between
242222
separate services
243223

244-
#### CircleCI
224+
#### TravisCI
225+
Travis CI uses runs tests against Node 8 and Node 9. In total it uses 8 jobs to
226+
build each helper against both Node versions. For every job it runs unit tests
227+
first, then `ApiDataFactory` and `REST` tests present in `test/rest` directory.
228+
Finally if those pass we run specific helper tests found in `test/helper`
229+
directory. It doesn't run acceptance tests.
230+
Config is present in `.travis.yml` file.
245231

232+
#### CircleCI
246233
Here we use CodeceptJS docker image to build and execute tests inside it. We
247234
start with building Docker container based on Dockerfile present in main project
248235
directory. Then we run (in this order) unit tests, all helpers present in
249236
`test/helpers`, then we go with `test/rest` directory and finally if everything
250237
passed so far it executes acceptance tests. For easier maintenance and local
251238
debugging CircleCI uses `docker-compose.yml` file from `test` directory.
252239
You can find Circle config in `.circleci` directory.
240+
241+
#### Semaphore
242+
Currently Semaphore runs only Appium helper tests.

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* CodeceptJS version:
2020
* NodeJS Version:
2121
* Operating System:
22-
* puppeteer || webdriverio || testcafe version (if related)
22+
* puppeteer || webdriverio || playwright version (if related)
2323
* Configuration file:
2424

2525
```js

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Applicable helpers:
1010
- [ ] REST
1111
- [ ] FileHelper
1212
- [ ] Appium
13-
- [ ] TestCafe
1413

1514
Applicable plugins:
1615

.github/SHARDING_WORKFLOWS.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Test Sharding Workflows
2+
3+
This document explains the GitHub Actions workflows that demonstrate the new test sharding functionality in CodeceptJS.
4+
5+
## Updated/Created Workflows
6+
7+
### 1. `acceptance-tests.yml` (Updated)
8+
9+
**Purpose**: Demonstrates sharding with acceptance tests across multiple browser configurations.
10+
11+
**Key Features**:
12+
13+
- Runs traditional docker-compose tests (for backward compatibility)
14+
- Adds new sharded acceptance tests using CodeceptJS directly
15+
- Tests across multiple browser configurations (Puppeteer, Playwright)
16+
- Uses 2x2 matrix: 2 configs × 2 shards = 4 parallel jobs
17+
18+
**Example Output**:
19+
20+
```
21+
- Sharded Tests: codecept.Puppeteer.js (Shard 1/2)
22+
- Sharded Tests: codecept.Puppeteer.js (Shard 2/2)
23+
- Sharded Tests: codecept.Playwright.js (Shard 1/2)
24+
- Sharded Tests: codecept.Playwright.js (Shard 2/2)
25+
```
26+
27+
### 2. `sharding-demo.yml` (New)
28+
29+
**Purpose**: Comprehensive demonstration of sharding features with larger test suite.
30+
31+
**Key Features**:
32+
33+
- Uses sandbox tests (2 main test files) for sharding demonstration
34+
- Shows basic sharding with 2-way split (`1/2`, `2/2`)
35+
- Demonstrates combination of `--shuffle` + `--shard` options
36+
- Uses `DONT_FAIL_ON_EMPTY_RUN=true` to handle cases where some shards may be empty
37+
38+
### 3. `test.yml` (Updated)
39+
40+
**Purpose**: Clarifies which tests support sharding.
41+
42+
**Changes**:
43+
44+
- Added comment explaining that runner tests are mocha-based and don't support sharding
45+
- Points to sharding-demo.yml for examples of CodeceptJS-based sharding
46+
47+
## Sharding Commands Used
48+
49+
### Basic Sharding
50+
51+
```bash
52+
npx codeceptjs run --config ./codecept.js --shard 1/2
53+
npx codeceptjs run --config ./codecept.js --shard 2/2
54+
```
55+
56+
### Combined with Other Options
57+
58+
```bash
59+
npx codeceptjs run --config ./codecept.js --shuffle --shard 1/2 --verbose
60+
```
61+
62+
## Test Distribution
63+
64+
The sharding algorithm distributes tests evenly:
65+
66+
- **38 tests across 4 shards**: ~9-10 tests per shard
67+
- **6 acceptance tests across 2 shards**: 3 tests per shard
68+
- **Uneven splits handled gracefully**: Earlier shards get extra tests when needed
69+
70+
## Benefits Demonstrated
71+
72+
1. **Parallel Execution**: Tests run simultaneously across multiple CI workers
73+
2. **No Manual Configuration**: Automatic test distribution without maintaining test lists
74+
3. **Load Balancing**: Even distribution ensures balanced execution times
75+
4. **Flexibility**: Works with any number of shards and test configurations
76+
5. **Integration**: Compatible with existing CodeceptJS features (`--shuffle`, `--verbose`, etc.)
77+
78+
## CI Matrix Integration
79+
80+
The workflows show practical CI matrix usage:
81+
82+
```yaml
83+
strategy:
84+
matrix:
85+
config: ['codecept.Puppeteer.js', 'codecept.Playwright.js']
86+
shard: ['1/2', '2/2']
87+
```
88+
89+
This creates 4 parallel jobs:
90+
91+
- Config A, Shard 1/2
92+
- Config A, Shard 2/2
93+
- Config B, Shard 1/2
94+
- Config B, Shard 2/2
95+
96+
Perfect for scaling test execution across multiple machines and configurations.

.github/workflows/acceptance-tests.yml renamed to .github/workflows/acceptance-tests.yml.disabled

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Acceptance Tests using docker compose
1+
name: Acceptance Tests
22

33
on:
44
push:
@@ -32,9 +32,9 @@ jobs:
3232
sudo apt-get update --allow-releaseinfo-change
3333
sudo apt-get install -y docker-compose
3434

35-
# Run rest tests using docker-compose
36-
- name: Run REST Tests
37-
run: docker-compose run --rm test-rest
35+
# Build Docker images to include latest code changes
36+
- name: Build Docker Images
37+
run: docker-compose build
3838
working-directory: test
3939

4040
# Run WebDriverIO acceptance tests using docker-compose

0 commit comments

Comments
 (0)