Skip to content

Commit e2ab01c

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

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
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

lua/neotest-playwright/build-command.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ local logger = require("neotest.logging")
1515
--- A function that takes in CommandOptions and returns a string.
1616
____exports.buildCommand = function(options, extraArgs)
1717
local o = options
18-
local reporters = o.reporters or ({"list", "json"})
19-
local reportersArg = buildReporters(reporters)
18+
local ____o_reporters_0
19+
if o.reporters then
20+
____o_reporters_0 = buildReporters(o.reporters)
21+
else
22+
____o_reporters_0 = nil
23+
end
24+
local reporters = ____o_reporters_0
2025
local command = {}
2126
command[#command + 1] = o.bin
2227
command[#command + 1] = "test"
23-
if reportersArg ~= nil then
24-
command[#command + 1] = reportersArg
28+
if reporters ~= nil then
29+
command[#command + 1] = reporters
2530
end
2631
if o.debug == true then
2732
command[#command + 1] = "--debug"

lua/neotest-playwright/playwright.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ ____exports.get_projects = function()
1515
{
1616
bin = options.get_playwright_command(path),
1717
config = options.get_playwright_config(path),
18-
reporters = {"json"},
1918
testFilter = "./does-not-exist"
2019
},
2120
{"--list"}

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)