Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Bielik20 committed Mar 6, 2023
1 parent eb038b6 commit de8b22d
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions packages/nx-playwright/README.md
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_
```

0 comments on commit de8b22d

Please sign in to comment.