Closed catgoose closed 5 months ago
Similar to https://github.com/thenbe/neotest-playwright/issues/21 but I can never get them to pass. I am not modifying the test file.
I wonder if this due to the latest version. Can you reproduce this issue on an older version of playwright (like 1.41.2
)?
I've tried 1.41, 1.40, 1.39 and same issue. It doesn't seem to be updating workspace diagnostics at all. If I add something to a test like:
expect(false).toBeTruthy();
I can view the output of the test, but it does not show diagnostics for that line:
As a comparison here is vitest:
I'm having difficulty reproducing this.
Btw, you should update your config. it_test_file
should be more strict to avoid slurping up unrelated files (e.g. .png
from a snapshot test). In your example, it should be something like:
local is_test_file = function(file_path)
local result = file_path:find('e2e/tests/.*%.test%.[jt]s$') ~= nil
return result
end
See 985ec2649831 for more examples.
Thanks, I added that to my config.
Does neotest-playwright
get back the results of a test with the json
reporter? Does this have anything to do with the reporter setup in the playwright config? It seems like it's using the list
reporter for the output floats in my screenshots.
Here is my full playwright config:
import { defineConfig, devices } from '@playwright/test';
import { config } from 'dotenv';
config();
const baseURL = process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:7373';
const msalEnabled = process.env.MSAL_AUTH_ENABLED === 'true';
const dependencies = msalEnabled ? ['setup'] : [];
const ci = process.env.CI === 'true';
export default defineConfig({
testDir: './e2e/tests',
fullyParallel: true,
timeout: 30 * 1000,
expect: {
timeout: 5000,
},
forbidOnly: ci,
retries: ci ? 2 : 0,
workers: ci ? 1 : undefined,
reporter: ci
? [['list', { printSteps: true }]]
: [
['list', { printSteps: true }],
['html', { outputFolder: 'e2e/report', open: 'never' }],
['json', { outputFile: 'e2e/test-results.json' }],
],
use: {
actionTimeout: 0,
baseURL,
trace: 'on-first-retry',
headless: true,
},
outputDir: 'e2e/test-results',
projects: [
{
name: 'setup',
testMatch: msalEnabled ? /.*\.setup\.ts/ : undefined,
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: 'e2e/.auth/user.json',
},
dependencies,
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
storageState: 'e2e/.auth/user.json',
},
dependencies,
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
storageState: 'e2e/.auth/user.json',
},
dependencies,
},
],
webServer: {
command: 'npm run dev-ci',
url: baseURL,
reuseExistingServer: true,
},
});
That might be the cause actually. Apparently I started working on a solution in this PR but never got around to finishing it up.
See this line in particular: https://github.com/thenbe/neotest-playwright/blob/e2ab01cc4fe40f2d71b0860480b65116c1170096/README.md?plain=1#L72
If you un-declare the outputFile
of the json reporter, is the issue fixed?
- ['json', { outputFile: 'e2e/test-results.json' }],
+ ['json'],
What about if you remove the json reporter entirely?
The problem has to do with the dependencies on each project:
{
name: 'setup',
testMatch: msalEnabled ? /.*\.setup\.ts/ : undefined,
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: 'e2e/.auth/user.json',
},
dependencies: 'setup',
},
The auth step logs in the user, so I think when that step is completed neotest-playright
thinks that the test was successful. If I disable the dependency, I can pass the test:
Do you know if neotest-playwright
can handle dependency projects or should I disable my dependencies temporarily?
Honestly, I never got around to using dependency projects so I can't say for sure. But given the issue you're facing, some changes might be required in neotest-playwright
in order to report the correct results when dependency projects are used.
I've decided to enable the setup dependency only in CI environment. If I need get auth cookies, I just run the setup project manually to save auth state to user.json
.
Using Neovim 0.10 and playwright 1.44.1
I select 'chromium' using
NeotestPlaywrightProject
then try to run playwright tests:My lazy.nvim config:
My
playwright.config.ts