Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cypress] ESM docu update #43702

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"versioning": "node build/build.js --versioning",
"browserlist:update": "npx browserslist@latest --update-db",
"cypress:install": "cypress install",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
"cypress:open": "cypress open --config-file cypress.config.mjs",
"cypress:run": "cypress run --config-file cypress.config.mjs"
},
"browserslist": [
"last 2 major version",
Expand Down Expand Up @@ -111,4 +111,4 @@
"stylelint-order": "^5.0.0",
"stylelint-scss": "^4.7.0"
}
}
}
34 changes: 17 additions & 17 deletions tests/System/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It is simplified to offer an initial understanding. Detailed explanations follow

![System Tests Architecture](images/system-tests.svg)

On the left, **Cypress** is running as a [Node.js](https://nodejs.org/) application. The file **`cypress.config.js`** is used to configure settings and preferences for running the System Tests in your environment.
On the left, **Cypress** is running as a [Node.js](https://nodejs.org/) application. The file **`cypress.config.mjs`** is used to configure settings and preferences for running the System Tests in your environment.

In the middle, the **Cypress Test Runner** controls a **Browser** with the **Joomla** application running HTML, CSS, and JavaScript. Also running in the browser context are the **Database Commands**, the **API commands** and the npm packages **[joomala-cypress](https://github.com/joomla-projects/joomla-cypress/)** and
**[smtp-tester](https://www.npmjs.com/package/smtp-tester)**.
Expand Down Expand Up @@ -52,29 +52,29 @@ npm ci
```
3. Create the Cypress configuration file from the distribution template.
```
cp cypress.config.dist.js cypress.config.js
cp cypress.config.dist.mjs cypress.config.mjs
```
4. Adjust the parameter `baseUrl` in the `cypress.config.js` file, it should point to the Joomla base URL.
5. Adapt the env variables in the file `cypress.config.js`, they should point to the site, user data and database environment. Ensure that the `smtp_port` is not in use on your system.
4. Adjust the parameter `baseUrl` in the `cypress.config.mjs` file, it should point to the Joomla base URL.
5. Adapt the env variables in the file `cypress.config.mjs`, they should point to the site, user data and database environment. Ensure that the `smtp_port` is not in use on your system.


## Running System Tests

After installation, you can start the Joomla System Tests with headless Cypress. The test suite starts with Joomla Web-Installer as the first test step.
```
npx cypress run
npm run cypress:run
```
:point_right: In case of errors, see [Troubleshooting](#Troubleshooting) at the end.

You can execute single test specs, e.g. to run the installation step only.
```
npx cypress run --spec tests/System/integration/install/Installation.cy.js
npm run cypress:run --spec tests/System/integration/install/Installation.cy.js
```

You can run multiple test specs separated by commas and use patterns. For example, to execute all the tests from the
administrator, site, api and plugins specs without the installation step:
```
npx cypress run --spec 'tests/System/integration/{administrator,site,api,plugins}/**/*.cy.js'
npm run cypress:run --spec 'tests/System/integration/{administrator,site,api,plugins}/**/*.cy.js'
```

> [!NOTE]
Expand All @@ -83,13 +83,13 @@ npx cypress run --spec 'tests/System/integration/{administrator,site,api,plugins
> The Cypress GUI also displays the Cypress log output, providing real-time feedback on the test execution process.
> To open the Cypress GUI, run the following command.
> ```
> npx cypress open
> npm run cypress:open
> ```

If you are running System Tests, you will see `console.log()` outputs from Cypress Tasks in the Node.js environment. If you would like to see `console.log()` output from the browser in headless mode as well, you can use the Electron web browser and set the following environment variable:
```
export ELECTRON_ENABLE_LOGGING=1
npx cypress run --browser electron
npm run cypress:run --browser electron
```


Expand All @@ -107,7 +107,7 @@ which are numbered and described below.
interacting with the file system.
5. Joomla on the Web Server interacts with the **Database** as it normally would, without running any tests.
6. System Tests has Cypress custom **Database Commands** (described later) to interact with the database.
7. The file `cypress.config.js` is read by **Cypress** and used to configure settings and preferences for running the System Tests in your environment.
7. The file `cypress.config.mjs` is read by **Cypress** and used to configure settings and preferences for running the System Tests in your environment.
8. The Joomla installation is initiated by the test spec [Installation.cy.js](integration/install/Installation.cy.js),
which is the first test executed in the overall test suite.
This test spec deletes the Joomla configuration file, and since the `configuration.php` file no longer exists,
Expand All @@ -127,7 +127,7 @@ The used npm package "Helpers for using Cypress with Joomla for testing" **[joom
> see [tests/System/support/commands.js](/tests/System/support/commands.js).

The **[smtp-tester](https://www.npmjs.com/package/smtp-tester)** npm package creates an SMTP server that listens
on the `smtp_port` specified in `cypress.config.js` during test runtime.
on the `smtp_port` specified in `cypress.config.mjs` during test runtime.
This server accepts connections, receives emails, and provides the capability to check the received emails during the test.

> [!IMPORTANT]
Expand Down Expand Up @@ -288,27 +288,27 @@ If the Web Server and Cypress are run by different users, this can lead to file
:point_right: You have to give the user running Cypress the permission to write `configuration.php`
e.g. with the command `sudo` on macOS, Linux or Windows WSL 2:
```
sudo npx cypress run
sudo npm run cypress:run
```

If the `root` user does not have a Cypress installation, you can use the Cypress installation cache of the current user:
```
sudo CYPRESS_CACHE_FOLDER=$HOME/.cache/Cypress npx cypress run
sudo CYPRESS_CACHE_FOLDER=$HOME/.cache/Cypress npm run cypress:run
```


### Error 'EADDRINUSE: address already in use'

If the used SMTP server port is already in use you will see an error like:
```
Your configFile threw an error from: cypress.config.js
Your configFile threw an error from: cypress.config.mjs

We stopped running your tests because your config file crashed.

Error: listen EADDRINUSE: address already in use :::1025
```

:point_right: Configure a different, unused port in the `cypress.config.js` file as `smtp_port`.
:point_right: Configure a different, unused port in the `cypress.config.mjs` file as `smtp_port`.


### Timeout Error on Slow Machines
Expand All @@ -319,10 +319,10 @@ If you encounter the following error while running the System Tests on slow mach
AssertionError: Timed out retrying after 4000ms: Expected to find element
```

:point_right: You can increase the default 4 second waiting time in the cypress.config.js file:
:point_right: You can increase the default 4 second waiting time in the cypress.config.mjs file:

```JavaScript
module.exports = {
export default defineConfig({
defaultCommandTimeout: 20000, // sets the waiting time to 20 seconds
...
}
Expand Down
Binary file modified tests/System/images/system-tests-interactions.odg
Binary file not shown.
Binary file modified tests/System/images/system-tests-interactions.pdf
Binary file not shown.
Loading