mirror of
https://github.com/pnx/neotest-phpunit
synced 2026-06-16 03:54:55 +02:00
Update neotest-pest to work with Pest 2.0
This commit is contained in:
parent
179ada37aa
commit
8b20d2e087
3 changed files with 1265 additions and 559 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pestphp/pest": "^1.22",
|
"pestphp/pest": "^2.3",
|
||||||
"phpstan/phpstan": "^1.9",
|
"phpstan/phpstan": "^1.9",
|
||||||
"laravel/pint": "^1.2"
|
"laravel/pint": "^1.2"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
1810
composer.lock
generated
1810
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -8,9 +8,13 @@ local separator = "::"
|
||||||
---@param namespace neotest.Position[] Any namespaces the position is within
|
---@param namespace neotest.Position[] Any namespaces the position is within
|
||||||
---@return string
|
---@return string
|
||||||
M.make_test_id = function(position)
|
M.make_test_id = function(position)
|
||||||
-- Treesitter starts line numbers from 0 so we add 1
|
-- Treesitter ID needs to look like 'tests/Unit/ColsHelperTest.php::it returns the proper format'
|
||||||
local id = position.path .. separator .. position.name
|
-- which means it should include position.path. However, as of PHPUnit 10, position.path
|
||||||
|
-- includes the root directory of the project, which breaks the ID matching.
|
||||||
|
-- As such, we need to remove the root directory from the path.
|
||||||
|
local path = string.sub(position.path, string.len(vim.loop.cwd()) + 2)
|
||||||
|
|
||||||
|
local id = path .. separator .. position.name
|
||||||
logger.info("Path to test file:", { position.path })
|
logger.info("Path to test file:", { position.path })
|
||||||
logger.info("Treesitter id:", { id })
|
logger.info("Treesitter id:", { id })
|
||||||
|
|
||||||
|
|
@ -65,7 +69,9 @@ local function make_outputs(test, output_file)
|
||||||
local test_attr = test["_attr"] or test[1]["_attr"]
|
local test_attr = test["_attr"] or test[1]["_attr"]
|
||||||
local name = string.gsub(test_attr.name, "it (.*)", "%1")
|
local name = string.gsub(test_attr.name, "it (.*)", "%1")
|
||||||
|
|
||||||
local test_id = test_attr.file .. separator .. name
|
-- Difference to neotest-phpunit as of PHPUnit 10:
|
||||||
|
-- Pest's test IDs are in the format "path/to/test/file::test name"
|
||||||
|
local test_id = string.gsub(test_attr.file, "(.*)::(.*)", "%1") .. separator .. name
|
||||||
logger.info("Pest id:", { test_id })
|
logger.info("Pest id:", { test_id })
|
||||||
|
|
||||||
local test_output = {
|
local test_output = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue