@@ -80,22 +80,35 @@ npx prettier --config=fmt.json <file>
8080
8181## Test Organization (` test/ ` directory)
8282
83- Tests are organized by domain and colocated with strict structural rules.
84-
85- - 1:1:1 Rule: Each test directory contains exactly
86- - 1 test file (` *.test.ts ` with the same name with directory)
87- - 0 or 1 ` fixtures/ ` directory (if needed)
88- - Snapshots are colocated automatically by Vitest
89- - No Upward References (except ` utils.ts ` and ` oxfmt ` binary)
90- - Test files may only reference:
91- - Files within their own directory
92- - Shared ` utils.ts ` in parent directories
93-
94- When adding new tests:
95-
96- - Place test in the appropriate domain directory
97- - If the test needs fixtures, create a ` fixtures/ ` subdirectory
98- - If multiple test cases share a fixture structure, use subdirectories within ` fixtures/ ` (e.g., ` fixtures/basic/ ` , ` fixtures/nested/ ` )
83+ Tests are organized into specific domains, each with its own structure.
84+
85+ ### ` test/api/ ` : Formatting result tests
86+
87+ Focuses on verifying formatting output. Use the Node.js API. No fixtures, test inputs are inline in each test file.
88+
89+ - Multiple ` *.test.ts ` files coexist in a flat directory (no subdirectories)
90+ - Snapshots are colocated in ` __snapshots__/ ` by Vitest
91+
92+ ### ` test/cli/ ` : CLI fixture-driven tests
93+
94+ A single ` cli.test.ts ` auto-discovers and runs all fixture directories via ` utils.ts ` .
95+
96+ - Each fixture directory contains:
97+ - ` options.json ` — array of test cases (args, cwd, env, stdin, etc.)
98+ - ` fixtures/ ` — input files for the test cases
99+ - ` *.snap.md ` — file snapshots (one per test case, named ` 0.snap.md ` , ` 1.snap.md ` , …)
100+ - Adding a new CLI test: create a new directory with ` options.json ` and ` fixtures/ ` , then run the test to generate snapshots
101+ - If exceptional test cases are required, place a separate ` *.test.ts ` file for them
102+
103+ ### ` test/lsp/ ` : LSP integration tests
104+
105+ Each test directory follows the 1:1:1 rule:
106+
107+ - 1 test file (` *.test.ts ` with the same name as the directory)
108+ - 0 or 1 ` fixtures/ ` directory
109+ - Snapshots are colocated in ` __snapshots__/ ` by Vitest
110+
111+ Shared helpers are in ` utils.ts ` at the ` test/lsp/ ` level.
99112
100113## After updating ` Oxfmtrc ` (Under ` src/core/oxfmtrc ` )
101114
0 commit comments