You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SmartMotion uses [mini.test](https://github.com/echasnovski/mini.test) for automated testing. The test suite runs headlessly and requires no extra dependencies beyond Neovim.
4
+
5
+
---
6
+
7
+
## Running Tests
8
+
9
+
```bash
10
+
# Full suite (470 tests)
11
+
make test
12
+
13
+
# Single file
14
+
make test-file FILE=test_history.lua
15
+
```
16
+
17
+
Both commands run `nvim --headless -u tests/run_tests.lua`. Output shows `o` for pass and `x` for fail.
18
+
19
+
---
20
+
21
+
## What's Tested
22
+
23
+
The suite covers the non-interactive core of the plugin:
|**Public API**| All registry interfaces, consts, custom registration |
40
+
41
+
Interactive functions (visualizer label selection, `getchar()`-based input, operator inference) are tested manually using the [playground files](https://github.com/FluxxField/smart-motion.nvim/tree/dev/tests#interactive-playground-files).
42
+
43
+
---
44
+
45
+
## Writing Tests
46
+
47
+
### File Structure
48
+
49
+
Create `tests/test_<name>.lua`:
50
+
51
+
```lua
52
+
localMiniTest=require("mini_test")
53
+
localexpect=MiniTest.expect
54
+
localhelpers=require("tests.helpers")
55
+
56
+
localT=MiniTest.new_set({
57
+
hooks= {
58
+
pre_case=function()
59
+
helpers.setup_plugin()
60
+
end,
61
+
post_case=helpers.cleanup,
62
+
},
63
+
})
64
+
65
+
T["group"]["describes the behavior"] =function()
66
+
helpers.create_buf({ "hello world" })
67
+
helpers.set_cursor(1, 0)
68
+
69
+
localresult=some_function()
70
+
expect.equality(result, expected)
71
+
end
72
+
73
+
returnT
74
+
```
75
+
76
+
The runner auto-discovers all `tests/test_*.lua` files.
77
+
78
+
### Key Helpers
79
+
80
+
```lua
81
+
helpers.setup_plugin(overrides?) -- fresh plugin with test config
82
+
helpers.create_buf(lines) -- scratch buffer with content
83
+
helpers.set_cursor(row, col) -- 1-indexed row, 0-indexed col
84
+
helpers.build_ctx() -- minimal SmartMotionContext
85
+
helpers.cleanup() -- wipe buffers, clear modules
86
+
```
87
+
88
+
The test config disables timing (`flow_state_timeout_ms = 0`), search UI (`native_search = false`), and background dimming to keep tests deterministic.
89
+
90
+
### Testing Pipeline Modules
91
+
92
+
For collectors, extractors, and filters, test the raw `.run()` function directly rather than the wrapped registry version:
Copy file name to clipboardExpand all lines: tests/README.md
+130-6Lines changed: 130 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,132 @@
1
-
# SmartMotion Playground / Test Files
1
+
# SmartMotion Tests
2
2
3
-
Interactive test files for every SmartMotion preset. Open them in Neovim with SmartMotion loaded and follow the comment instructions.
3
+
SmartMotion has two kinds of tests: an **automated test suite** run headlessly via [mini.test](https://github.com/echasnovski/mini.test), and **interactive playground files** for manual testing in Neovim.
4
4
5
-
## Quick Start
5
+
---
6
+
7
+
## Automated Test Suite
8
+
9
+
470 tests across 41 files covering pipeline engine, registries, filters, config validation, history persistence, and more.
10
+
11
+
### Running Tests
12
+
13
+
```bash
14
+
# Run the full suite
15
+
make test
16
+
17
+
# Run a single test file
18
+
make test-file FILE=test_history.lua
19
+
```
20
+
21
+
Both commands launch Neovim in headless mode. Output shows `o` for pass and `x` for fail.
0 commit comments