Skip to content

Commit

Permalink
Merge branch '3.x' of github.com:codeceptjs/CodeceptJS into 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Nov 23, 2021
2 parents f554472 + 02dd104 commit 7c66aed
Show file tree
Hide file tree
Showing 24 changed files with 195 additions and 89 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/appium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: 'npm run test:appium-quick'
env: # Or as an environment variable
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
Expand All @@ -46,6 +49,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: 'npm run test:appium-other'
env: # Or as an environment variable
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dtslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: npm run def
- run: npm run dtslint
2 changes: 2 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- name: npm install
run: |
npm install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run chromium tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/puppeteer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
- name: npm install
run: |
npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- run: npm test
3 changes: 3 additions & 0 deletions .github/workflows/testcafe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: npm install
run: |
npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run unit tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/webdriver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: npm install
run: |
npm install
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run unit tests
Expand Down
27 changes: 26 additions & 1 deletion docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Refer to following guides to more information on:
* [▶ Playwright](/playwright)
* [▶ WebDriver](/webdriver)
* [▶ Puppeteer](/puppeteer)
* [▶ Protractor](/angular)
* [▶ Nightmare](/nightmare)
* [▶ TestCafe](/testcafe)

Expand Down Expand Up @@ -317,6 +316,32 @@ var assert = require('assert');
assert.equal(title, 'CodeceptJS');
```

It is important to understand the usage of **async** functions in CodeceptJS. While non-returning actions can be called without await, if an async function uses `grab*` action it must be called with `await`:

```js
// a helper function
async function getAllUsers(I) {
const users = await I.grabTextFrom('.users');
return users.filter(u => u.includes('active'))
}

// a test
Scenario('try helper functions', async ({ I }) => {
// we call function with await because it includes `grab`
const users = await getAllUsers(I);
});
```

If you miss `await` you get commands unsynchrhonized. And this will result to an error like this:

```
(node:446390) UnhandledPromiseRejectionWarning: ...
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:446390) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
```

If you face that error please make sure that all async functions are called with `await`.

## Running Tests

To launch tests use the `run` command, and to execute tests in [multiple browsers](/advanced/#multiple-browsers-execution) or [multiple threads](/advanced/#parallel-execution) use the `run-multiple` command.
Expand Down
4 changes: 2 additions & 2 deletions docs/bdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Behavior Driven Development

# Behavior Driven Development

Behavior Driven Development (BDD) is a popular software development methodology. BDD is considered an extension of TDD, and is greatly inspired by [Agile](http://agilemanifesto.org/) practices. The primary reason to choose BDD as your development process is to break down communication barriers between business and technical teams. BDD encourages the use of automated testing to verify all documented features of a project from the very beginning. This is why it is common to talk about BDD in the context of test frameworks (like CodeceptJS). The BDD approach, however, is about much more than testing - it is a common language for all team members to use during the development process.
Behavior Driven Development (BDD) is a popular software development methodology. BDD is considered an extension of TDD, and is greatly inspired by [Agile](https://agilemanifesto.org/) practices. The primary reason to choose BDD as your development process is to break down communication barriers between business and technical teams. BDD encourages the use of automated testing to verify all documented features of a project from the very beginning. This is why it is common to talk about BDD in the context of test frameworks (like CodeceptJS). The BDD approach, however, is about much more than testing - it is a common language for all team members to use during the development process.

## What is Behavior Driven Development

Expand Down Expand Up @@ -55,7 +55,7 @@ I should see that total number of products I want to buy is 2
And my order amount is $1600
```

As we can see this simple story highlights core concepts that are called *contracts*. We should fulfill those contracts to model software correctly. But how we can verify that those contracts are being satisfied? [Cucumber](http://cucumber.io) introduced a special language for such stories called **Gherkin**. Same story transformed to Gherkin will look like this:
As we can see this simple story highlights core concepts that are called *contracts*. We should fulfill those contracts to model software correctly. But how we can verify that those contracts are being satisfied? [Cucumber](https://cucumber.io) introduced a special language for such stories called **Gherkin**. Same story transformed to Gherkin will look like this:

```gherkin
Feature: checkout process
Expand Down

0 comments on commit 7c66aed

Please sign in to comment.