@test2doc/playwright 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,6 +106,74 @@ The `TEST2DOC=true` is required to activate the test2doc metadata to pass to the
|
|
|
106
106
|
## Verify installation
|
|
107
107
|
To verify your setup works, run `npm run docs:generate` and check that markdown files appear in your `./doc/docs` directory, or wherever you specified the output directory in the `playwright-test2doc.config.ts` file.
|
|
108
108
|
|
|
109
|
+
## Filtering Tests
|
|
110
|
+
It is possible you may wish to opt-in some tests or opt-out other tests from doc generation. This is possible with playwright tags.
|
|
111
|
+
|
|
112
|
+
### Tag tests
|
|
113
|
+
Adding tags to playwright tests is easy. See the [official docs](https://playwright.dev/docs/test-annotations#tag-tests) for more details.
|
|
114
|
+
|
|
115
|
+
There are a few different approaches to tagging, but for this README we're going with passing in a tag array to help support multiple tags. But if you prefer one of the other options playwright supports, feel free to use it.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
// Add tag to describe block level
|
|
119
|
+
test.describe('Describe Block', {
|
|
120
|
+
tag: ['@test2doc']
|
|
121
|
+
}, () => {
|
|
122
|
+
test('this test inherits from the describe block', () => {
|
|
123
|
+
...
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
// Add tag to tests
|
|
128
|
+
// This example has multiple tags
|
|
129
|
+
test('test title', {
|
|
130
|
+
tag: ['@test2doc', '@other-tag'],
|
|
131
|
+
}, async ({ page }) => {
|
|
132
|
+
...
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Add tag to skip doc generation
|
|
136
|
+
test('test will skip doc generation', {
|
|
137
|
+
tag: ['@skip-docs'],
|
|
138
|
+
}, async ({ page }) => {
|
|
139
|
+
...
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Opt-in Approach
|
|
144
|
+
**Best for:** Legacy codebases or when you want explicit control over which tests generate documentation.
|
|
145
|
+
|
|
146
|
+
Run only tests with the `@test2doc` tag.
|
|
147
|
+
|
|
148
|
+
#### Update package.json
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
...
|
|
152
|
+
"scripts": {
|
|
153
|
+
...
|
|
154
|
+
"docs:generate": "TEST2DOC=true playwright test --config=playwright-test2doc.config.ts --grep @test2doc"
|
|
155
|
+
}
|
|
156
|
+
...
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Opt-out Approach
|
|
161
|
+
**Best for:** Tests that don't need documentation generated, like flaky tests or internal API tests.
|
|
162
|
+
|
|
163
|
+
Skip tests with the `@skip-docs` tag.
|
|
164
|
+
|
|
165
|
+
#### Update package.json
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
...
|
|
169
|
+
"scripts": {
|
|
170
|
+
...
|
|
171
|
+
"docs:generate": "TEST2DOC=true playwright test --config=playwright-test2doc.config.ts --grep-invert @skip-docs"
|
|
172
|
+
}
|
|
173
|
+
...
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
109
177
|
## How it works
|
|
110
178
|
|
|
111
179
|
After this setup, every time you run your Playwright tests, the `@test2doc/playwright` reporter will automatically generate a new markdown file in your specified Docusaurus docs directory for each test file and/or top-level describe block found in your Playwright test files.
|