mirror of
https://github.com/enso-org/enso.git
synced 2024-12-21 09:31:35 +03:00
54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
|
# End-to-end tests
|
||
|
|
||
|
## Running tests
|
||
|
|
||
|
Execute all commands from the parent directory.
|
||
|
|
||
|
```sh
|
||
|
# Run tests normally
|
||
|
npm run test:e2e
|
||
|
# Open UI to run tests
|
||
|
npm run test:e2e:debug
|
||
|
# Run tests in a specific file only
|
||
|
npm run test:e2e -- e2e/file-name-here.spec.ts
|
||
|
npm run test:e2e:debug -- e2e/file-name-here.spec.ts
|
||
|
# Compile the entire app before running the tests.
|
||
|
# DOES NOT hot reload the tests.
|
||
|
# Prefer not using this when you are trying to fix a test;
|
||
|
# prefer using this when you just want to know which tests are failing (if any).
|
||
|
PROD=1 npm run test:e2e
|
||
|
PROD=1 npm run test:e2e:debug
|
||
|
PROD=1 npm run test:e2e -- e2e/file-name-here.spec.ts
|
||
|
PROD=1 npm run test:e2e:debug -- e2e/file-name-here.spec.ts
|
||
|
```
|
||
|
|
||
|
## Getting started
|
||
|
|
||
|
```ts
|
||
|
test.test("test name here", ({ page }) =>
|
||
|
actions.mockAllAndLogin({ page }).then(
|
||
|
// ONLY chain methods from `pageActions`.
|
||
|
// Using methods not in `pageActions` is UNDEFINED BEHAVIOR.
|
||
|
// If it is absolutely necessary though, please remember to `await` the method chain.
|
||
|
// Note that the `async`/`await` pair is REQUIRED, as `Actions` subclasses are `PromiseLike`s,
|
||
|
// not `Promise`s, which causes Playwright to output a type error.
|
||
|
async ({ pageActions }) => await pageActions.goToHomePage(),
|
||
|
),
|
||
|
);
|
||
|
```
|
||
|
|
||
|
### Perform arbitrary actions (e.g. actions on the API)
|
||
|
|
||
|
```ts
|
||
|
test.test("test name here", ({ page }) =>
|
||
|
actions.mockAllAndLogin({ page }).then(
|
||
|
async ({ pageActions, api }) =>
|
||
|
await pageActions.do(() => {
|
||
|
api.foo();
|
||
|
api.bar();
|
||
|
test.expect(api.baz()?.quux).toEqual("bar");
|
||
|
}),
|
||
|
),
|
||
|
);
|
||
|
```
|