Open KoderFPV opened 1 week ago
Hi,
Can you try the debug
preset? It should launch the test in trace mode, just like in the video demo.
@thenbe Debug preset for me opens playwright inspector, I meant trace viewer I guess.
In VSC playwright starts tests in trace viewer every time, so it seems like it collects attachments in real-time. In the video below, I had to run a test first to create an attachment and then open this attachment in Trace Viewer.
https://github.com/user-attachments/assets/16084d4f-0895-462a-8147-9735dea086d1
Is it possible to start tests in the tracer viewer every time?
Ahh I see what you mean by trace viewer now (as opposed to the inspector).
I'm not quite sure what's a good way to approach this as I haven't used playwright heavily since the the trace viewer was introduced.
Is it possible to start tests in the tracer viewer every time?
I couldn't find one, but is there a way to do this purely through the playwright cli? If so, then we should be able to do it in neotest-playwright too.
I can see that the --ui
flag can be passed to launch the trace viewer, but once you do pass the --ui
flag (i.e. pnpm playwright test --ui
) it seems no tests are ran until you manually click the play button in the trace viewer gui.
FWIW, I feel like this behavior is not what I would expect as a user, so perhaps this is something that will be changed in a future version of playwright? When passing the --ui
flag, I expect the tests to run. This is also how vitest's --ui
flag works (unlike playwright, vitest runs the tests as the gui launches).
I'm on playwright v1.48.2
.
As for the mappings, these are what I currently have mapped. Although they've changed a fair bit from the time the video was created.
{
'nvim-neotest/neotest',
cond = not vim.g.started_by_foreign,
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
'nvim-neotest/nvim-nio',
{
'thenbe/neotest-playwright',
dependencies = 'nvim-neotest/neotest', -- this is needed to avoid an error when neotest is lazy-loaded as a result of a key defined in neotest-playwright's config
dev = false,
keys = {
{ '<leader>t.', '<cmd>NeotestPlaywrightRefresh<cr>', desc = '[test] [playwright] Refresh' },
{ '<leader>tp', '<cmd>NeotestPlaywrightProject<cr>', desc = '[test] [playwright] Set projects' },
{ '<leader>te', '<cmd>NeotestPlaywrightPreset<cr>', desc = '[test] [playwright] Set preset' },
-- stylua: ignore
{ '<leader>Ta', function() require('neotest').playwright.attachment() end, desc = '[test] [playwright] Launch attachment' },
},
},
},
keys = {
-- stylua: ignore start
{ '<leader>tr', function() require('neotest').run.run() end, desc = '[test] Run test' },
{ '<leader>tR', function() require('neotest').run.run(vim.fn.expand('%')) end, desc = '[test] Run tests in file' },
{ '<leader>ts', function() require('neotest').run.stop() end, desc = '[test] Stop test' },
{ '<leader>tO', function() require('neotest').output.open({ enter = true }) end, desc = '[test] Open output' },
{ '<leader>Tt', function() require('neotest.consumers.summary').toggle() end, desc = '[test] Toggle test tree' },
{ '<leader>To', function() require('neotest.consumers.output_panel').toggle() end, desc = '[test] Toggle output panel' },
-- stylua: ignore end
},
config = function()
require('neotest').setup({
-- log_level = vim.log.levels.DEBUG,
adapters = {
require('neotest-playwright').adapter({
options = {
preset = 'none', -- "none" | "headed" | "debug"
persist_project_selection = true,
enable_dynamic_test_discovery = true,
-- filter_dir = function(name, rel_path, root) return name ~= 'node_modules' end,
---@param file_path string
is_test_file = function(file_path)
local result = file_path:find('%.test%.[tj]sx?$') ~= nil -- enforce extension
-- local result = file_path:find('tests/.*%.test%.[jt]sx?$') ~= nil -- enforce directory and extension
-- P({ 'is_test_file', result, file_path })
return result
end,
experimental = {
telescope = {
enabled = true,
-- opts = {},
},
},
},
}),
},
consumers = {
playwright = require('neotest-playwright.consumers').consumers,
},
})
end,
},
Hi,
Mighty contributors of this amazing project, could you share mappings from the demo video with us?
Is it possible to start the test already in trace mode, to easily revert the history of the test?
Thanks and good job, excellent plugin :)