Skip to content

Commit 40cb896

Browse files
committed
do not include json reporter by default
1 parent 5f61514 commit 40cb896

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use({
4747
-- end,
4848

4949
-- env = {
50+
-- PW_NVIM = "1",
5051
-- HELLO = "world",
5152
-- },
5253

@@ -66,6 +67,36 @@ use({
6667
})
6768
```
6869

70+
## Configuration
71+
72+
The only reporter required by `neotest-playwright` is the `json` reporter, which you need to set either in your `playwright.config.ts` or by using `extra_args`. Make sure _not_ to declare the json reporter's `outputFile` property in your config as this will be set by `neotest-playwright`.
73+
74+
One way you can do this is by using environment variables.
75+
76+
```lua
77+
-- init.lua
78+
79+
require("neotest-playwright").adapter({
80+
options = {
81+
env = {
82+
PW_NVIM = "1",
83+
},
84+
},
85+
})
86+
```
87+
88+
```typescript
89+
// playwright.config.ts
90+
91+
const config: PlaywrightTestConfig = {
92+
reporter: process.env.PW_NVIM
93+
? [['json'], ['list'], ['html', { open: 'never' }]] // only json is required. The rest are optional.
94+
: [['list'], ['html', { open: 'never' }]], // Your default reporters.
95+
};
96+
```
97+
98+
> Until `playwright` provides us a way to pass the `--reporters` flag without overwriting the `reporters` set in the user's config, we have to rely on the user handling this.
99+
69100
---
70101

71102
## Projects

src/build-command.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ export type CommandOptionsPreset = Omit<CommandOptions, 'bin'>;
1919
/** A function that takes in CommandOptions and returns a string. */
2020
export const buildCommand = (options: CommandOptions, extraArgs: string[]) => {
2121
const o = options;
22-
const reporters = o.reporters ?? ['list', 'json'];
23-
const reportersArg = buildReporters(reporters);
22+
const reporters = o.reporters ? buildReporters(o.reporters) : null;
2423

2524
const command: string[] = [];
2625

2726
command.push(o.bin);
2827
command.push('test');
29-
if (reportersArg !== null) command.push(reportersArg);
28+
if (reporters !== null) command.push(reporters);
3029
if (o.debug === true) command.push('--debug');
3130
if (o.headed === true) command.push('--headed');
3231
if (o.retries !== undefined) command.push(`--retries=${o.retries}`);

src/playwright.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const get_projects = () => {
1717
{
1818
bin: options.get_playwright_command(path),
1919
config: options.get_playwright_config(path),
20-
reporters: ['json'],
2120
testFilter: './does-not-exist',
2221
},
2322
['--list'],

0 commit comments

Comments
 (0)