-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,53 @@ | ||
# nx-playwright | ||
# NX Playwright | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
A plugin to run playwright e2e tests in nx monorepo. | ||
|
||
## Building | ||
## Install | ||
|
||
Run `nx build nx-playwright` to build the library. | ||
``` | ||
npm i -D @ns3/nx-playwright | ||
``` | ||
|
||
## Running unit tests | ||
## Generate | ||
|
||
Run `nx test nx-playwright` to execute the unit tests via [Jest](https://jestjs.io). | ||
``` | ||
nx generate @ns3/nx-playwright:project my-desktop-e2e --project my-destkop | ||
``` | ||
|
||
Providing `project` flag will generate a config that targets this frontend application. | ||
|
||
## Run project | ||
|
||
``` | ||
npx nx run my-desktop-e2e:e2e | ||
``` | ||
|
||
It works similarly to cypress runner in a sense that you can pass dev server options: | ||
|
||
```ts | ||
export interface StartDevServerOptions { | ||
devServerTarget?: string; | ||
skipServe?: boolean; | ||
baseUrl?: string; | ||
watch?: boolean; // Only affects DevServer, Playwright doesn't support it :( | ||
} | ||
``` | ||
|
||
With an exception that `watch` is not supported at the moment as `Playwright` doesn't have a concept of [watch/open](https://github.com/microsoft/playwright/issues/7035) like Cypress does. | ||
|
||
`baseUrl` is passed as `BASE_URL` env variable. | ||
|
||
Apart from that, there is a `command` option which is generated with `playwright test`. | ||
It is done like that to allow you to replace it with different command or different runner altogether like [playwright-watch](https://www.npmjs.com/package/@deploysentinel/playwright-watch), or `playwright show-trace` etc. | ||
|
||
```bash | ||
npx nx run my-desktop-e2e:e2e --command "playwright show-trace" | ||
``` | ||
|
||
This executor passes every [arg to playwright runner](https://playwright.dev/docs/test-cli#reference) including nameless ones | ||
In case there is a name conflict between Playwright and Nx/Executor params simply suffix them with `_`: | ||
|
||
```bash | ||
npx nx run my-desktop-e2e:e2e app.spec.ts --debug # all args passed to Playwright | ||
npx nx run my-desktop-e2e:e2e --help_ # help conflicts with Nx help so we pass it as help_ | ||
``` |