Skip to content

Commit 6876726

Browse files
committed
refactor(oxfmt): Migrate all tests to JS based (#15285)
Previously, `oxfmt`'s e2e tests were written in Rust. However, after migrating our CLI to napi, e2e tests using Vitest were also added. As a result, there is no longer any reason to maintain tests on the Rust side. Additionally, while tests using `napi` are possible in Vitest, they are not possible in Rust. So consolidated everything to Vitest. Additionally, I added tests that were not included in the previous PR for `embeddedLanguageFormatting: "auto" | "off"`.
1 parent ea0c9b1 commit 6876726

File tree

125 files changed

+1669
-1340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1669
-1340
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxfmt/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_o
5757
mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_on_exit", "local_dynamic_tls", "no_opt_arch"] }
5858

5959
[dev-dependencies]
60-
insta = { workspace = true }
61-
lazy-regex = { workspace = true }
6260

6361
[features]
6462
default = ["napi"]

apps/oxfmt/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build-napi-test": "pnpm run build-napi",
1515
"build-napi-release": "pnpm run build-napi --release --features allocator",
1616
"build-js": "node scripts/build.js",
17-
"test": "tsc && vitest --dir ./test run"
17+
"test": "tsc && vitest --dir test run"
1818
},
1919
"engines": {
2020
"node": "^20.19.0 || >=22.12.0"
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`config_file > auto discovery > nested 1`] = `
4+
"--------------------
5+
arguments: --check
6+
working directory: fixtures/config_file/nested
7+
exit code: 1
8+
--- STDOUT ---------
9+
Checking formatting...
10+
deep/test.js (<variable>ms)
11+
12+
Format issues found in above 1 files. Run without \`--check\` to fix.
13+
Finished in <variable>ms on 1 files using 1 threads.
14+
--- STDERR ---------
15+
16+
--------------------"
17+
`;
18+
19+
exports[`config_file > auto discovery > nested_deep 1`] = `
20+
"--------------------
21+
arguments: --check
22+
working directory: fixtures/config_file/nested/deep
23+
exit code: 1
24+
--- STDOUT ---------
25+
Checking formatting...
26+
test.js (<variable>ms)
27+
28+
Format issues found in above 1 files. Run without \`--check\` to fix.
29+
Finished in <variable>ms on 1 files using 1 threads.
30+
--- STDERR ---------
31+
32+
--------------------"
33+
`;
34+
35+
exports[`config_file > auto discovery > root 1`] = `
36+
"--------------------
37+
arguments: --check
38+
working directory: fixtures/config_file
39+
exit code: 1
40+
--- STDOUT ---------
41+
Checking formatting...
42+
nested/deep/test.js (<variable>ms)
43+
44+
Format issues found in above 1 files. Run without \`--check\` to fix.
45+
Finished in <variable>ms on 1 files using 1 threads.
46+
--- STDERR ---------
47+
48+
--------------------"
49+
`;
50+
51+
exports[`config_file > explicit config 1`] = `
52+
"--------------------
53+
arguments: --check --config ./fmt.json
54+
working directory: fixtures/config_file
55+
exit code: 1
56+
--- STDOUT ---------
57+
Checking formatting...
58+
nested/deep/test.js (<variable>ms)
59+
60+
Format issues found in above 1 files. Run without \`--check\` to fix.
61+
Finished in <variable>ms on 1 files using 1 threads.
62+
--- STDERR ---------
63+
64+
--------------------
65+
--------------------
66+
arguments: --check --config ./fmt.jsonc
67+
working directory: fixtures/config_file
68+
exit code: 1
69+
--- STDOUT ---------
70+
Checking formatting...
71+
nested/deep/test.js (<variable>ms)
72+
73+
Format issues found in above 1 files. Run without \`--check\` to fix.
74+
Finished in <variable>ms on 1 files using 1 threads.
75+
--- STDERR ---------
76+
77+
--------------------
78+
--------------------
79+
arguments: --check --config NOT_EXISTS.json
80+
working directory: fixtures/config_file
81+
exit code: 1
82+
--- STDOUT ---------
83+
Failed to load configuration file.
84+
Failed to read config <cwd>/NOT_EXISTS.json: File not found
85+
--- STDERR ---------
86+
87+
--------------------"
88+
`;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`config_ignore_patterns > should respect ignorePatterns in config 1`] = `
4+
"--------------------
5+
arguments: --check
6+
working directory: fixtures/config_ignore_patterns
7+
exit code: 1
8+
--- STDOUT ---------
9+
Checking formatting...
10+
11+
Expected at least one target file
12+
--- STDERR ---------
13+
14+
--------------------
15+
--------------------
16+
arguments: --check --config fmtrc.jsonc
17+
working directory: fixtures/config_ignore_patterns
18+
exit code: 1
19+
--- STDOUT ---------
20+
Checking formatting...
21+
22+
Expected at least one target file
23+
--- STDERR ---------
24+
25+
--------------------"
26+
`;

0 commit comments

Comments
 (0)