-
-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathneotest.txt
1654 lines (1279 loc) · 54 KB
/
neotest.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*neotest.txt* A framework to interact with tests within NeoVim
==============================================================================
neotest *neotest*
Setup......................................................|neotest.setup()|
Configuration Options.......................................|neotest.config|
Consumers................................................|neotest.consumers|
Output Consumer.............................................|neotest.output|
Output Panel Consumer.................................|neotest.output_panel|
Run Consumer...................................................|neotest.run|
Watch Consumer...............................................|neotest.watch|
Status Consumer.............................................|neotest.status|
Diagnostic Consumer.....................................|neotest.diagnostic|
Summary Consumer...........................................|neotest.summary|
Jump Consumer.................................................|neotest.jump|
Quickfix Consumer.........................................|neotest.quickfix|
State Consumer...............................................|neotest.state|
Neotest Client..............................................|neotest.Client|
Library........................................................|neotest.lib|
Library: Files...........................................|neotest.lib.files|
Library: Function Utilities..........................|neotest.lib.func_util|
Library: Positions...................................|neotest.lib.positions|
Library: Treesitter.................................|neotest.lib.treesitter|
Library: Processes.....................................|neotest.lib.process|
Library: XML...............................................|neotest.lib.xml|
There are three main components to this plugin's architecture.
- Adapters: Generally language specific objects to parse tests, build commands
and parse results
- Client: Runs tests and stores state of tests and results, emitting events
during operation
- Consumers: Use the client to provide some utility to interact with tests and
results
In order to use neotest, you must use an adapter for your language of choice.
You can supply them in the setup function.
Once you have setup an adapter, you can use neotest consumers to run and
interact with tests.
For most users, the bulk of relevant features will be in the consumers.
Each consumer can be accessed as a property of the neotest module
See the table of contents for the consumers
>vim
lua require("neotest").summary.toggle()
<
*neotest.setup()*
`setup`({user_config})
Neotest strategies and consumers
See also ~
|neotest.Config|
Parameters~
{user_config} `(neotest.Config)`
Default values:
>lua
{
adapters = {},
benchmark = {
enabled = true
},
consumers = {},
default_strategy = "integrated",
diagnostic = {
enabled = true,
severity = 1
},
discovery = {
concurrent = 0,
enabled = true
},
floating = {
border = "rounded",
max_height = 0.6,
max_width = 0.6,
options = {}
},
highlights = {
adapter_name = "NeotestAdapterName",
border = "NeotestBorder",
dir = "NeotestDir",
expand_marker = "NeotestExpandMarker",
failed = "NeotestFailed",
file = "NeotestFile",
focused = "NeotestFocused",
indent = "NeotestIndent",
marked = "NeotestMarked",
namespace = "NeotestNamespace",
passed = "NeotestPassed",
running = "NeotestRunning",
select_win = "NeotestWinSelect",
skipped = "NeotestSkipped",
target = "NeotestTarget",
test = "NeotestTest",
unknown = "NeotestUnknown",
watching = "NeotestWatching"
},
icons = {
child_indent = "│",
child_prefix = "├",
collapsed = "─",
expanded = "╮",
failed = "",
final_child_indent = " ",
final_child_prefix = "╰",
non_collapsible = "─",
notify = "",
passed = "",
running = "",
running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
skipped = "",
unknown = "",
watching = ""
},
jump = {
enabled = true
},
log_level = 3,
output = {
enabled = true,
open_on_run = "short"
},
output_panel = {
enabled = true,
open = "botright split | resize 15"
},
projects = {},
quickfix = {
enabled = true,
open = false
},
run = {
enabled = true
},
running = {
concurrent = true
},
state = {
enabled = true
},
status = {
enabled = true,
signs = true,
virtual_text = false
},
strategies = {
integrated = {
height = 40,
width = 120
}
},
summary = {
animated = true,
count = true,
enabled = true,
expand_errors = true,
follow = true,
mappings = {
attach = "a",
clear_marked = "M",
clear_target = "T",
debug = "d",
debug_marked = "D",
expand = { "<CR>", "<2-LeftMouse>" },
expand_all = "e",
help = "?",
jumpto = "i",
mark = "m",
next_failed = "J",
output = "o",
prev_failed = "K",
run = "r",
run_marked = "R",
short = "O",
stop = "u",
target = "t",
watch = "w"
},
open = "botright vsplit | vertical resize 50"
},
watch = {
enabled = true,
symbol_queries = {
elixir = <function 1>,
go = " ;query\n ;Captures imported types\n (qualified_type name: (type_identifier) @symbol)\n ;Captures package-local and built-in types\n (type_identifier)@symbol\n ;Captures imported function calls and variables/constants\n (selector_expression field: (field_identifier) @symbol)\n ;Captures package-local functions calls\n (call_expression function: (identifier) @symbol)\n ",
haskell = " ;query\n ;explicit import\n ((import_item [(variable)]) @symbol)\n ;symbols that may be imported implicitly\n ((type) @symbol)\n (qualified_variable (variable) @symbol)\n (exp_apply (exp_name (variable) @symbol))\n ((constructor) @symbol)\n ((operator) @symbol)\n ",
java = " ;query\n ;captures imported classes\n (import_declaration\n (scoped_identifier name: ((identifier) @symbol))\n )\n ",
javascript = ' ;query\n ;Captures named imports\n (import_specifier name: (identifier) @symbol)\n ;Captures default import\n (import_clause (identifier) @symbol)\n ;Capture require statements\n (variable_declarator \n name: (identifier) @symbol\n value: (call_expression (identifier) @function (#eq? @function "require")))\n ;Capture namespace imports\n (namespace_import (identifier) @symbol)\n',
lua = ' ;query\n ;Captures module names in require calls\n (function_call\n name: ((identifier) @function (#eq? @function "require"))\n arguments: (arguments (string) @symbol))\n ',
python = " ;query\n ;Captures imports and modules they're imported from\n (import_from_statement (_ (identifier) @symbol))\n (import_statement (_ (identifier) @symbol))\n ",
ruby = ' ;query\n ;rspec - class name\n (call\n method: (identifier) @_ (#match? @_ "^(describe|context)")\n arguments: (argument_list (constant) @symbol )\n )\n\n ;rspec - namespaced class name\n (call\n method: (identifier)\n arguments: (argument_list\n (scope_resolution\n name: (constant) @symbol))\n )\n ',
rust = " ;query\n ;submodule import\n (mod_item\n name: (identifier) @symbol)\n ;single import\n (use_declaration\n argument: (scoped_identifier\n name: (identifier) @symbol))\n ;import list\n (use_declaration\n argument: (scoped_use_list\n list: (use_list\n [(scoped_identifier\n path: (identifier)\n name: (identifier) @symbol)\n ((identifier) @symbol)])))\n ;wildcard import\n (use_declaration\n argument: (scoped_use_list\n path: (identifier)\n [(use_list\n [(scoped_identifier\n path: (identifier)\n name: (identifier) @symbol)\n ((identifier) @symbol)\n ])]))\n ",
tsx = ' ;query\n ;Captures named imports\n (import_specifier name: (identifier) @symbol)\n ;Captures default import\n (import_clause (identifier) @symbol)\n ;Capture require statements\n (variable_declarator \n name: (identifier) @symbol\n value: (call_expression (identifier) @function (#eq? @function "require")))\n ;Capture namespace imports\n (namespace_import (identifier) @symbol)\n',
typescript = ' ;query\n ;Captures named imports\n (import_specifier name: (identifier) @symbol)\n ;Captures default import\n (import_clause (identifier) @symbol)\n ;Capture require statements\n (variable_declarator \n name: (identifier) @symbol\n value: (call_expression (identifier) @function (#eq? @function "require")))\n ;Capture namespace imports\n (namespace_import (identifier) @symbol)\n'
}
}
}
<
*neotest.setup_project()*
`setup_project`({project_root}, {project_config})
Configure a project individually.
Parameters~
{project_root} `(string)`
{project_config} `(neotest.CoreConfig)`
==============================================================================
neotest.config *neotest.config*
*neotest.CoreConfig*
Fields~
{adapters} `(neotest.Adapter[])`
{discovery} `(neotest.Config.discovery)`
{running} `(neotest.Config.running)`
{default_strategy} `(string|function)`
*neotest.Config*
Inherits: `neotest.CoreConfig`
Fields~
{log_level} `(number)` Minimum log levels, one of vim.log.levels
{consumers} `(table<string, neotest.Consumer>)`
{icons} `(table)` Icons used throughout the UI. Defaults use VSCode's codicons
{highlights} `(table<string, string>)`
{floating} `(neotest.Config.floating)`
{strategies} `(neotest.Config.strategies)`
{run} `(neotest.Config.run)`
{summary} `(neotest.Config.summary)`
{output} `(neotest.Config.output)`
{output_panel} `(neotest.Config.output_panel)`
{quickfix} `(neotest.Config.quickfix)`
{status} `(neotest.Config.status)`
{state} `(neotest.Config.state)`
{watch} `(neotest.Config.watch)`
{diagnostic} `(neotest.Config.diagnostic)`
{projects} `(table<string, neotest.CoreConfig>)` Project specific settings,
keys
are project root directories (e.g "~/Dev/my_project")
*neotest.Config.discovery*
Fields~
{enabled} `(boolean)`
{concurrent} `(integer)` Number of workers to parse files concurrently. 0
automatically assigns number based on CPU. Set to 1 if experiencing lag.
{filter_dir} `(nil)` | fun(name: string, rel_path: string, root: string):
boolean A function to filter directories when searching for test files.
Receives the name, path relative to project root and project root path
*neotest.Config.running*
Fields~
{concurrent} `(boolean)` Run tests concurrently when an adapter provides
multiple commands to run
*neotest.Consumer*
Alias~
`neotest.Consumer` → `fun(client: neotest.Client): table`
*neotest.Config.floating*
Fields~
{border} `(string)` Border style
{max_height} `(number)` Max height of window as proportion of NeoVim window
{max_width} `(number)` Max width of window as proportion of NeoVim window
{options} `(table)` Window local options to set on floating windows (e.g.
winblend)
*neotest.Config.strategies.integrated*
Fields~
{width} `(integer)` Width to pass to the pty runnning commands
*neotest.Config.strategies*
Fields~
{integrated} `(neotest.Config.strategies.integrated)`
*neotest.Config.run*
Fields~
{enabled} `(boolean)`
{augment?} `(fun(tree: neotest.Tree, arg:
neotest.run.RunArgs):neotest.run.RunArgs)` A function to augment the arguments
any tests being run
*neotest.Config.summary*
Fields~
{enabled} `(boolean)`
{animated} `(boolean)` Enable/disable animation of icons
{follow} `(boolean)` Expand user's current file
{expand_errors} `(boolean)` Expand all failed positions
{mappings} `(neotest.Config.summary.mappings)` Buffer mappings for summary
window
{open} `(string)` | fun(): integer A command or function to open a window for
the summary
{count} `(boolean)` Display number of tests found beside the adapter name
*neotest.Config.summary.mappings*
Fields~
{expand} `(string|string[])` Expand currently selected position
{expand_all} `(string|string[])` Expand all positions under currently selected
{output} `(string|string[])` Show output for position
{short} `(string|string[])` Show short output for position (if exists)
{attach} `(string|string[])` Attach to process for position
{jumpto} `(string|string[])` Jump to the selected position
{stop} `(string|string[])` Stop selected position
{run} `(string|string[])` Run selected position
{debug} `(string|string[])` Debug selected position
{mark} `(string|string[])` Mark the selected position
{run_marked} `(string|string[])` Run the marked positions for selected suite.
{debug_marked} `(string|string[])` Debug the marked positions for selected
suite.
{clear_marked} `(string|string[])` Clear the marked positions for selected
suite.
{target} `(string|string[])` Target a position to be the only shown position
for its adapter
{clear_target} `(string|string[])` Clear the target position for the selected
adapter
{next_failed} `(string|string[])` Jump to the next failed position
{prev_failed} `(string|string[])` Jump to the previous failed position
{watch} `(string|string[])` Toggle watching for changes
*neotest.Config.output*
Fields~
{enabled} `(boolean)`
{open_on_run} `(string|boolean)` Open nearest test result after running
*neotest.Config.state*
Fields~
{enabled} `(boolean)`
*neotest.Config.output_panel*
Fields~
{enabled} `(boolean)`
{open} `(string|fun():integer)` A command or function to open a window for the
output panel
*neotest.Config.quickfix*
Fields~
{enabled} `(boolean)`
{open} `(boolean|function)` Set to true to open quickfix on startup, or a
function to be
called when the quickfix results are set
*neotest.Config.diagnostic*
Fields~
{enabled} `(boolean)`
{severity} `(number)` Diagnostic severity, one of vim.diagnostic.severity
*neotest.Config.status*
Fields~
{enabled} `(boolean)`
{virtual_text} `(boolean)` Display status using virtual text
{signs} `(boolean)` Display status using signs
*neotest.Config.watch*
Fields~
{enabled} `(boolean)`
{symbol_queries} `(table<string, string|fun(root, content: string, path:
string):integer[][]>)` Treesitter queries or functions to capture symbols that
are used for querying the LSP server for defintions to link files. If it is a
function then the return value should be a list of node ranges.
{filter_path?} `(fun(path: string, root: string): boolean)` Returns whether
the watcher should inspect a path for dependencies. Default ignores paths not
under root or common package manager directories.
==============================================================================
neotest.consumers *neotest.consumers*
Consumers provide user consumable APIs by wrapping the lower level client
object. If you are developing a consumer, it is strongly recommended to enable
type checking of the `neotest` repo, as it will provide very helpful type
hints/docs. You can use https://github.com/folke/lua-dev.nvim to do this easily.
A consumer is a function which takes a neotest.Client object. The function can
optionally return a table containing functions which will be directly accessable
on the `neotest` module under the consumers name. For example, the `run`
consumer returns a table with `run`, `attach` and `stop` and so users can call
`neotest.run.run`, `neotest.run.attach` and `neotest.run.stop`
The client interface provides methods for interacting with tests, fetching
results as well as event listeners. To listen to an event, just assign the event
listener to a function:
>lua
client.listeners.discover_positions = function (adapter_id, tree)
...
end
<
Available events and the listener signatures are visible as properties on the
`client.listeners` table
The majority of interactions with the client will involved the use of the
positions tree. Each adapter instance has a separate tree, so you should track
which adapter ID you are using throughout several calls.
==============================================================================
neotest.output *neotest.output*
A consumer that displays the output of test results.
*neotest.consumers.output.OpenArgs*
Fields~
{open_win} `(function?)` Function that takes a table with width and height
keys
and opens a window for the output. If a window ID is not returned, the current
window will be used
{short} `(boolean?)` Show shortened output
{enter} `(boolean?)` Enter output window
{quiet} `(boolean?)` Suppress warnings of no output
{last_run} `(boolean?)` Open output for last test run
{position_id} `(string?)` Open output for position with this ID, opens nearest
position if not given
{adapter} `(string?)` Adapter ID, defaults to first found with matching
position
{auto_close} `(boolean?)` Close output window when leaving it, or when cursor
moves outside of window
*neotest.output.open()*
`open`({opts})
Open the output of a test result
>vim
lua require("neotest").output.open({ enter = true })
<
Parameters~
{opts?} `(neotest.consumers.output.OpenArgs)`
==============================================================================
neotest.output_panel *neotest.output_panel*
A consumer that streams all output of tests to a terminal window.
*neotest.output_panel.open()*
`open`()
Open the output panel
>vim
lua require("neotest").output_panel.open()
<
*neotest.output_panel.close()*
`close`()
Close the output panel
>vim
lua require("neotest").output_panel.close()
<
*neotest.output_panel.toggle()*
`toggle`()
Toggle the output panel
>vim
lua require("neotest").output_panel.toggle()
<
*neotest.output_panel.clear()*
`clear`()
Clears the output panel
>vim
lua require("neotest").output_panel.clear()
<
==============================================================================
neotest.run *neotest.run*
A consumer providing a simple interface to run tests.
*neotest.run.RunArgs*
Inherits: `neotest.client.RunTreeArgs`
Fields~
{[1]} `(string?)` Position ID to run
{suite} `(boolean)` Run the entire suite instead of a single position
*neotest.run.run()*
`run`({args})
Run the given position or the nearest position if not given.
All arguments are optional
Run the current file
>vim
lua require("neotest").run.run(vim.fn.expand("%"))
<
Run the nearest test
>vim
lua require("neotest").run.run()
<
Debug the current file with nvim-dap
>vim
lua require("neotest").run.run({vim.fn.expand("%"), strategy = "dap"})
<
Parameters~
{args} `(string|neotest.run.RunArgs?)` Position ID to run or args.
*neotest.run.run_last()*
`run_last`({args})
Re-run the last position that was run.
Arguments are optional
Run the last position that was run with the same arguments and strategy
>vim
lua require("neotest").run.run_last()
<
Run the last position that was run with the same arguments but debug with
nvim-dap
>vim
lua require("neotest").run.run_last({ strategy = "dap" })
<
Parameters~
{args} `(neotest.run.RunArgs?)` Argument overrides
*neotest.run.StopArgs*
Inherits: `neotest.client.StopArgs`
Fields~
{interactive} `(boolean)` Select a running position interactively
*neotest.run.stop()*
`stop`({args})
Stop a running process
Parameters~
{args} `(string|neotest.run.StopArgs?)` Position ID to stop or args. If
args then args[1] should be the position ID.
*neotest.run.AttachArgs*
Inherits: `neotest.client.AttachArgs`
Fields~
{interactive} `(boolean)` Select a running position interactively
*neotest.run.attach()*
`attach`({args})
Attach to a running process for the given position.
Parameters~
{args} `(string|neotest.run.AttachArgs?)` Position ID to attach to or args. If
args then
args[1] should be the position ID.
*neotest.run.get_last_run()*
`get_last_run`()
Get last test position ID and args
Return~
`(string|nil)` position_id
Return~
`(neotest.run.RunArgs|nil)` args
==============================================================================
neotest.watch *neotest.watch*
Allows watching tests and re-running them whenever related files are
changed. When watching a directory, all files are run in separate processes.
Otherwise the tests are run in the same process (if allowed by the adapter).
Related files are determined through an LSP client through a "best effort"
which means there are cases where a file may not be determined as related
despite it having an effect on a test.
To determine file relationships, a treesitter query is used to find symbols
that are queried for using the `textDocument/definition` LSP request. The
query can be configured through the watch consumer's config. Any captures
named `symbol` will be used. If your language is not present in the default
config, please submit a PR to add support out of the box!
*neotest.watch.WatchArgs:*
Fields~
{run_predicate?} `(fun(bufnr: integer):boolean)` Can be used to check whether
tests should be rerun
*neotest.watch.watch()*
`watch`({args})
Watch a position and run it whenever related files are changed.
Arguments are the same as the `neotest.run.run`, which allows
for custom runner arguments, env vars, strategy etc. If a position is
already being watched, the existing watcher will be stopped.
An additional `run_predicate` function, which takes a buffer handle,
can be passed in to determine whether tests should be rerun.
This can be useful, e.g. for only rerunning if there are no LSP
error diagnostics.
Parameters~
{args?} `(neotest.watch.WatchArgs|string)`
*neotest.watch.toggle()*
`toggle`({args})
Toggle watching a position and run it whenever related files are changed.
Arguments are the same as the `neotest.run.run`, which allows
for custom runner arguments, env vars, strategy etc.
Toggle watching the current file
>vim
lua require("neotest").watch.toggle(vim.fn.expand("%"))
<
Parameters~
{args?} `(neotest.watch.WatchArgs|string)`
*neotest.watch.stop()*
`stop`({position_id})
Stop watching a position. If no position is provided, all watched positions are stopped.
Parameters~
{position_id} `(string)`
*neotest.watch.is_watching()*
`is_watching`({position_id})
Check if a position is being watched.
Parameters~
{position_id} `(string)`
Return~
`(boolean)`
==============================================================================
neotest.status *neotest.status*
A consumer that displays the results of tests as signs beside their declaration.
This consumer is completely passive and so has no interface.
==============================================================================
neotest.diagnostic *neotest.diagnostic*
A consumer that displays error messages using the vim.diagnostic API.
This consumer is completely passive and so has no interface.
You can configure the diagnostic API for neotest using the "neotest" namespace
See also ~
|vim.diagnostic.config()|
==============================================================================
neotest.summary *neotest.summary*
A consumer that displays the structure of the test suite, along with results and
allows running tests.
See also ~
|neotest.Config.summary.mappings| for all mappings in the summary window
*neotest.summary.open()*
`open`()
Open the summary window
>vim
lua require("neotest").summary.open()
<
*neotest.summary.close()*
`close`()
Close the summary window
>vim
lua require("neotest").summary.close()
<
*neotest.summary.toggle()*
`toggle`()
the summary window
>vim
lua require("neotest").summary.toggle()
<
*neotest.summmary.RunMarkedArgs*
Inherits: `neotest.run.RunArgs`
*neotest.summary.run_marked()*
`run_marked`({args})
Run all marked positions
Parameters~
{args?} `(neotest.summmary.RunMarkedArgs)`
*neotest.summary.marked()*
`marked`()
Return a table<adapter id, position_id[]> of all marked positions
@return table<string, string[]>
*neotest.summary.ClearMarkedArgs*
Fields~
{adapter?} `(string)` Adapter ID, if not given all adapters are cleared
*neotest.summary.clear_marked()*
`clear_marked`({args})
Clear all marked positions
Parameters~
{args?} `(neotest.summary.ClearMarkedArgs)`
*neotest.summary.target()*
`target`({adapter_id}, {position_id})
Set the target for an adapter tree
Parameters~
{adapter_id} `(string)`
{position_id} `(string|nil)` Position ID to target, nil to reset target
==============================================================================
neotest.jump *neotest.jump*
A consumer that allows jumping between tests
Example mappings to jump between test failures
>vim
nnoremap <silent>[n <cmd>lua require("neotest").jump.prev({ status = "failed" })<CR>
nnoremap <silent>]n <cmd>lua require("neotest").jump.next({ status = "failed" })<CR>
<
*neotest.jump.JumpArgs*
Fields~
{status} `(string)` Only jump to positions with given status
*neotest.jump.next()*
`next`({args})
Jump to the position after the cursor position in the current file
Parameters~
{args?} `(neotest.jump.JumpArgs)`
*neotest.jump.prev()*
`prev`({args})
to the position after the cursor position in the current file
Parameters~
{args?} `(neotest.jump.JumpArgs)`
==============================================================================
neotest.quickfix *neotest.quickfix*
A consumer that sends results to the quickfix list.
==============================================================================
neotest.state *neotest.state*
A consumer that tracks various pieces of state in Neotest.
Most of the internals of Neotest are asynchronous so this consumer allows
tracking the state of the test suite and test results without needing to
write asynchronous code.
*neotest.state.adapter_ids()*
`adapter_ids`()
Get the list of all adapter IDs currently active
Return~
`(string[])`
*neotest.state.status_counts()*
`status_counts`({adapter_id}, {args})
Get the counts of the various states of tests for the entire suite or for a
buffer.
Parameters~
{adapter_id} `(string)`
{args?} `(neotest.state.StatusCountsArgs)`
Return~
`(neotest.state.StatusCounts)` | nil
*neotest.state.StatusCountsArgs*
Fields~
{buffer?} `(integer)` Returns statuses for this buffer
*neotest.state.StatusCounts*
Fields~
{total} `(integer)`
{passed} `(integer)`
{failed} `(integer)`
{skipped} `(integer)`
{running} `(integer)`
*neotest.state.positions()*
`positions`({adapter_id}, {args})
Get the known positions for the entire suite or for a buffer.
Parameters~
{adapter_id} `(string)`
{args?} `(neotest.state.PositionsArgs)`
Return~
`(neotest.Tree)` | nil
*neotest.state.PositionsArgs*
Fields~
{buffer?} `(integer)` Returns positions for this buffer
==============================================================================
*neotest.Client*
`Client`
The neotest client is the core of neotest, it communicates with adapters,
running tests and collecting results.
Most of the client methods are async and so need to be run in an async
context (i.e. `require("nio").run(function() ... end))
The client starts lazily, meaning that no parsing of tests will be performed
until it is required. Care should be taken to not use the client methods on
start because it can slow down startup.
{listeners} `(neotest.ConsumerListeners)`
*neotest.ConsumerListeners*
Fields~
{discover_positions} `(fun(adapter_id: string, tree: neotest.Tree))`
{run} `(fun(adapter_id: string, root_id: string, position_ids: string[]))`
{results} `(fun(adapter_id: string, results: table<string, neotest.Result>,
partial: boolean))`
{test_file_focused} `(fun(adapter_id: string, file_path: string)>)`
{test_focused} `(fun(adapter_id: string, position_id: string)>)`
{starting} `(fun())`
{started} `(fun())`
Type ~
neotest.Client
*neotest.client.RunTreeArgs*
Fields~
{adapter?} `(string)` Adapter ID, if not given the first adapter found with
chosen position is used.
{strategy?} `("integrated"|"dap"|string|neotest.Strategy)` Strategy to run
commands with
{extra_args?} `(string[])` Arguments supplied to the test adapter to add to
the test process arguments
{env?} `(table<string, string>)` Environment variables for the test process
{cwd?} `(string)` Working directory for the test process
{concurrent?} `(false|number)` Override concurrency settings for running tests
*neotest.Client:run_tree()*
`Client:run_tree`({tree}, {args})
Run the given tree
Parameters~
{tree} `(neotest.Tree)`
{args} `(neotest.client.RunTreeArgs)`
*neotest.Client:running_positions()*
`Client:running_positions`()
Return~
`(table[])`
*neotest.client.StopArgs*
Fields~
{adapter} `(string)` Adapter ID
*neotest.Client:stop()*
`Client:stop`({position}, {args})
Parameters~
{position} `(neotest.Tree)`
{args?} `(neotest.client.StopArgs)`
*neotest.client.AttachArgs*
Fields~
{adapter} `(string)` Adapter ID
*neotest.Client:attach()*
`Client:attach`({position}, {args})
Attach to the given running position.
Parameters~
{position} `(neotest.Tree)`
{args?} `(neotest.client.AttachArgs)`
*neotest.client.GetNearestArgs*
Fields~
{adapter} `(string)` Adapter ID
*neotest.Client:get_nearest()*
`Client:get_nearest`({file_path}, {row}, {args})
Parameters~
{file_path} `(string)`
{row} `(integer)` Zero-indexed row
{args} `(neotest.client.GetNearestArgs)`
Return~
`(neotest.Tree|nil,string|nil)`
*neotest.Client:get_adapters()*
`Client:get_adapters`()
all known active adapters
Return~
`(string[])`
*neotest.client.GetPositionArgs*
Fields~
{adapter?} `(string)` Adapter ID
*neotest.Client:get_position()*
`Client:get_position`({position_id}, {args})
Parameters~
{position_id?} `(string)`
{args} `(neotest.client.GetPositionArgs)`
Return~
`(neotest.Tree|nil,string|nil)`
*neotest.Client:get_results()*
`Client:get_results`({adapter})
Parameters~
{adapter} `(string)` Adapter ID
Return~
`(table<string, neotest.Result>)`
*neotest.client.IsRunningArgs*
Fields~
{adapter} `(string)` Adapter ID
*neotest.Client:is_running()*
`Client:is_running`({position_id}, {args})
Parameters~
{position_id} `(string)`
{args} `(neotest.client.IsRunningArgs)`
Return~
`(boolean)`
*neotest.Client:get_adapter()*
`Client:get_adapter`({file_path})
Parameters~
{file_path} `(string)`
Return~
`(string?)`
Return~
`(neotest.Adapter?)`
==============================================================================
neotest.lib *neotest.lib*
Neotest provides several modules that can be used for common tasks.
Some of the modules are quite generic while others are highly tailored to
building adapters or consumers.
The libraries are not meant for general users but are treated as a
public API and so will remain mostly stable. The libraries should only be
used by accessing require("neotest.lib"). The module structure within the
library is considered private and may change without notice.
==============================================================================
neotest.lib.files *neotest.lib.files*
Helper functions for interacting with files
*neotest.lib.files.read()*
`read`({file_path})
Read a file asynchronously
Parameters~