mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.3 KiB
101 lines
2.3 KiB
2 years ago
|
# Playwright E2E tests
|
||
|
|
||
|
## Setup
|
||
|
|
||
|
Make sure to install the dependencies(in the playwright folder):
|
||
|
|
||
|
```bash
|
||
|
npm install
|
||
|
npx playwright install chromium --with-deps
|
||
|
```
|
||
|
|
||
|
## Run Test Server
|
||
|
|
||
|
Start the backend test server (in `packages/nocodb` folder):
|
||
|
|
||
|
```bash
|
||
2 years ago
|
npm run watch:run:playwright
|
||
2 years ago
|
```
|
||
|
|
||
|
Start the frontend test server (in `packages/nc-gui` folder):
|
||
|
|
||
|
```bash
|
||
|
NUXT_PAGE_TRANSITION_DISABLE=true npm run dev
|
||
|
```
|
||
|
|
||
|
## Running Tests
|
||
|
|
||
|
### Running all tests
|
||
|
|
||
|
For selecting db type, rename `.env.example` to `.env` and set `E2E_DEV_DB_TYPE` to `sqlite`(default), `mysql` or `pg`.
|
||
|
|
||
2 years ago
|
headless mode(without opening browser):
|
||
|
|
||
2 years ago
|
```bash
|
||
|
npm run test
|
||
|
```
|
||
|
|
||
2 years ago
|
with browser:
|
||
|
|
||
|
```bash
|
||
|
npm run test:debug
|
||
|
```
|
||
|
|
||
|
</br>
|
||
|
</br>
|
||
|
|
||
|
For setting up mysql:
|
||
|
|
||
|
```bash
|
||
|
docker-compose -f ./packages/nc-gui/tests/playwright/scripts/docker-compose-mysql-playwright.yml up -d
|
||
|
```
|
||
|
|
||
|
For setting up postgres:
|
||
|
|
||
|
```bash
|
||
|
docker-compose -f ./packages/nc-gui/tests/playwright/scripts/docker-compose-playwright-pg.yml
|
||
|
```
|
||
|
|
||
2 years ago
|
### Running individual tests
|
||
|
|
||
|
Add `.only` to the test you want to run:
|
||
|
|
||
|
```js
|
||
|
test.only('should login', async ({ page }) => {
|
||
|
// ...
|
||
|
})
|
||
|
```
|
||
|
|
||
|
```bash
|
||
|
npm run test
|
||
|
```
|
||
|
|
||
|
## Developing tests
|
||
|
|
||
|
### WebStorm
|
||
|
|
||
|
In Webstorm, you can use the `test-debug` run action to run the tests.
|
||
|
|
||
|
Add `.only` to the test you want to run. This will open the test in a chromium session and you can also add break points.
|
||
|
|
||
|
### VSCode
|
||
|
|
||
2 years ago
|
In VSCode, use this [extension](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright).
|
||
2 years ago
|
|
||
|
It will have run button beside each test in the file.
|
||
|
|
||
2 years ago
|
## Page Objects
|
||
2 years ago
|
|
||
2 years ago
|
- Page object is a class which has methods to interact with a page/component. Methods should be thin and should not do a whole lot. They should also be reusable.
|
||
2 years ago
|
|
||
2 years ago
|
- All the action methods i.e click of a page object is also responsible for waiting till the action is completed. This can be done by waiting on an API call or some ui change.
|
||
2 years ago
|
|
||
2 years ago
|
- Do not add any logic to the tests. Instead, create a page object for the page you are testing.
|
||
2 years ago
|
All the selection, UI actions and assertions should be in the page object.
|
||
|
|
||
|
Page objects should be in `packages/nc-gui/tests/playwright/pages` folder.
|
||
|
|
||
2 years ago
|
## Verify if tests are not flaky
|
||
2 years ago
|
|
||
2 years ago
|
Add `.only` to the added tests and run `npm run test:repeat`. This will run the test multiple times and should show if the test is flaky.
|