@robby-rabbitman/nx-plus-web-test-runner
Version:
Web Test Runner integration for Nx workspaces.
80 lines (59 loc) • 3 kB
Markdown
[](https://www.npmjs.com/package/@robby-rabbitman/nx-plus-web-test-runner)
[](https://www.npmjs.com/package/@robby-rabbitman/nx-plus-web-test-runner)
[](https://nx.dev)
[](https://modern-web.dev/docs/test-runner/overview)
# nx-plus-web-test-runner
[Nx](https://nx.dev) plugin to infer [Web Test Runner](https://modern-web.dev/docs/test-runner/overview) in a workspace.
**Note** that `@web/test-runner` has not released a `1.0.0` yet.
## 🚀 Getting started
```sh
npm i -D @robby-rabbitman/nx-plus-web-test-runner
```
```sh
nx g @robby-rabbitman/nx-plus-web-test-runner:init
```
Projects with a Web Test Runner now have a _test_ target.
```sh
nx run {{project}}:test
```
## 📖 Documentation
### `@robby-rabbitman/nx-plus-web-test-runner:init`
Adds [`@robby-rabbitman/nx-plus-web-test-runner/plugins/web-test-runner`](#robby-rabbitmannx-plus-web-test-runnerpluginsweb-test-runner) to the `plugins` in the `nx.json`.
#### Usage
```sh
nx g @robby-rabbitman/nx-plus-web-test-runner:init
```
#### Options
| Option | Type | Default | Description |
| ---------------- | ------- | ------- | --------------------------------------------- |
| test-target-name | string | 'test' | The name of the Web Test Runner target. |
| skip-format | boolean | false | Whether to skip formatting the updated files. |
| skip-add-plugin | boolean | false | Whether to skip adding the plugin. |
### `@robby-rabbitman/nx-plus-web-test-runner/plugins/web-test-runner`
Adds a _test_ target for projects that have a [Web Test Runner config](https://modern-web.dev/docs/test-runner/cli-and-configuration/#configuration-file) file in their root, the plugin infers a Web Test Runner with one of the following names.
- `web-test-runner.config.js`
- `web-test-runner.config.cjs`
- `web-test-runner.config.mjs`
- `wtr.config.js`
- `wtr.config.cjs`
- `wtr.config.mjs`
#### Options
```json5
// nx.json
"plugins": [
{
"plugin": "@robby-rabbitman/nx-plus-web-test-runner/plugins/web-test-runner",
"options": {
// the name of the web test runner target => nx run {{project}}:test
"testTargetName": "test",
// the default configuration of the web test runner targets inferred by this plugin
"testTargetConfig": {
"options":{
"watch": true,
"node-resolve": true
}
}
}
},
]
```