@@ -71,6 +71,7 @@ function adapter.build_position(file_path, source, captured_nodes)
7171 local name = vim .treesitter .get_node_text (node , source )
7272 local definition = captured_nodes [match_type .. " .definition" ]
7373 local type = node :type ()
74+ local nonStringNode = false
7475
7576 if type == " string" then
7677 -- If the node is a string then strip the quotes from the name by getting
@@ -94,6 +95,8 @@ function adapter.build_position(file_path, source, captured_nodes)
9495 end
9596
9697 name = table.concat (new_name , " " )
98+ else
99+ nonStringNode = true
97100 end
98101
99102 return {
@@ -103,7 +106,7 @@ function adapter.build_position(file_path, source, captured_nodes)
103106 range = { definition :range () },
104107 -- Record the position of the line where the string name occurs
105108 test_name_range = match_type == " test" and { node :range () } or nil ,
106- is_parameterized = captured_nodes [" each_property" ] and true or false ,
109+ is_parameterized = ( captured_nodes [" each_property" ] or nonStringNode ) and true or false ,
107110 }
108111end
109112
@@ -335,10 +338,10 @@ end
335338
336339local function cleanAnsi (s )
337340 return s :gsub (" \x1b %[%d+;%d+;%d+;%d+;%d+m" , " " )
338- :gsub (" \x1b %[%d+;%d+;%d+;%d+m" , " " )
339- :gsub (" \x1b %[%d+;%d+;%d+m" , " " )
340- :gsub (" \x1b %[%d+;%d+m" , " " )
341- :gsub (" \x1b %[%d+m" , " " )
341+ :gsub (" \x1b %[%d+;%d+;%d+;%d+m" , " " )
342+ :gsub (" \x1b %[%d+;%d+;%d+m" , " " )
343+ :gsub (" \x1b %[%d+;%d+m" , " " )
344+ :gsub (" \x1b %[%d+m" , " " )
342345end
343346
344347local function findErrorPosition (file , errStr )
@@ -418,8 +421,16 @@ function adapter.build_spec(args)
418421 local testNamePattern = " .*"
419422
420423 if pos .type == types .PositionType .test or pos .type == types .PositionType .namespace then
421- -- pos.id in form "path/to/file::Describe text::test text"
422- local testName = pos .id :sub (pos .id :find (" ::" ) + 2 )
424+ local temp = parameterized_tests .getParametricTestToSourceLevelTest (pos .path , pos .id )
425+ local testName
426+
427+ if temp then
428+ testName = temp :sub (pos .id :find (" ::" ) + 2 )
429+ else
430+ -- pos.id in form "path/to/file::Describe text::test text"
431+ testName = pos .id :sub (pos .id :find (" ::" ) + 2 )
432+ end
433+
423434 testName , _ = testName :gsub (" ::" , " " )
424435 testNamePattern = util .escapeTestPattern (testName )
425436
@@ -452,7 +463,7 @@ function adapter.build_spec(args)
452463 }
453464
454465 local options =
455- getJestArguments (jest_util .getJestDefaultArguments (jestArgsContext ), jestArgsContext )
466+ getJestArguments (jest_util .getJestDefaultArguments (jestArgsContext ), jestArgsContext )
456467
457468 if compat .tbl_islist (options ) then
458469 vim .list_extend (command , options )
@@ -540,7 +551,7 @@ function adapter.results(spec, result, tree)
540551
541552 -- FIX: Generate results for source-level parametrized namespaces
542553 if
543- adapter .jest_test_discovery == true and parameterized_tests .isPositionParameterized (tree , pos )
554+ adapter .jest_test_discovery == true and parameterized_tests .isPositionParameterized (tree , pos )
544555 then
545556 local status
546557
0 commit comments