Skip to content

Commit 37aadf0

Browse files
committed
test(language_server): add test_and_snapshot_multiple_file (#13966)
For some tests, you need to run multiple `cargo test -p oxc_language_server` commands, to catch all changes. With this method, we can lint multiple files at ones and create a single snapshot for it.
1 parent 0c93f33 commit 37aadf0

26 files changed

+148
-65
lines changed

crates/oxc_language_server/src/linter/server_linter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,7 @@ mod test {
562562
#[test]
563563
fn test_cross_module_no_cycle_nested_config() {
564564
Tester::new("fixtures/linter/cross_module_nested_config", None)
565-
.test_and_snapshot_single_file("dep-a.ts");
566-
Tester::new("fixtures/linter/cross_module_nested_config", None)
567-
.test_and_snapshot_single_file("folder/folder-dep-a.ts");
565+
.test_and_snapshot_multiple_file(&["dep-a.ts", "folder/folder-dep-a.ts"]);
568566
}
569567

570568
#[test]
@@ -603,8 +601,10 @@ mod test {
603601
#[test]
604602
fn test_root_ignore_patterns() {
605603
let tester = Tester::new("fixtures/linter/ignore_patterns", None);
606-
tester.test_and_snapshot_single_file("ignored-file.ts");
607-
tester.test_and_snapshot_single_file("another_config/not-ignored-file.ts");
604+
tester.test_and_snapshot_multiple_file(&[
605+
"ignored-file.ts",
606+
"another_config/not-ignored-file.ts",
607+
]);
608608
}
609609

610610
#[test]

crates/oxc_language_server/src/snapshots/fixtures_linter_astro@debugger.astro.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/astro/debugger.astro
43
---
4+
##########
5+
file: fixtures/linter/astro/debugger.astro
6+
----------
7+
58
code: "eslint(no-debugger)"
69
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
710
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"

crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@debugger.ts.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/cross_module/debugger.ts
43
---
4+
##########
5+
file: fixtures/linter/cross_module/debugger.ts
6+
----------
7+
58
code: "eslint(no-debugger)"
69
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
710
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"

crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module@dep-a.ts.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/cross_module/dep-a.ts
43
---
4+
##########
5+
file: fixtures/linter/cross_module/dep-a.ts
6+
----------
7+
58
code: "eslint-plugin-import(no-cycle)"
69
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html"
710
message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./dep-b.ts - fixtures/linter/cross_module/dep-b.ts\n-> ./dep-a.ts - fixtures/linter/cross_module/dep-a.ts"

crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_extended_config@dep-a.ts.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/cross_module_extended_config/dep-a.ts
43
---
4+
##########
5+
file: fixtures/linter/cross_module_extended_config/dep-a.ts
6+
----------
7+
58
code: "eslint-plugin-import(no-cycle)"
69
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html"
710
message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./dep-b.ts - fixtures/linter/cross_module_extended_config/dep-b.ts\n-> ./dep-a.ts - fixtures/linter/cross_module_extended_config/dep-a.ts"

crates/oxc_language_server/src/snapshots/fixtures_linter_cross_module_nested_config@dep-a.ts.snap

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts
43
---
4+
##########
5+
file: fixtures/linter/cross_module_nested_config/dep-a.ts
6+
----------
7+
No diagnostic reports
8+
##########
9+
file: fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts
10+
----------
11+
512
code: "eslint-plugin-import(no-cycle)"
613
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/import/no-cycle.html"
714
message: "Dependency cycle detected\nhelp: These paths form a cycle: \n-> ./folder-dep-b.ts - fixtures/linter/cross_module_nested_config/folder/folder-dep-b.ts\n-> ./folder-dep-a.ts - fixtures/linter/cross_module_nested_config/folder/folder-dep-a.ts"

crates/oxc_language_server/src/snapshots/fixtures_linter_deny_no_console@hello_world.js.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/deny_no_console/hello_world.js
43
---
4+
##########
5+
file: fixtures/linter/deny_no_console/hello_world.js
6+
----------
7+
58
code: "eslint(no-console)"
69
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-console.html"
710
message: "Unexpected console statement.\nhelp: Delete this console statement."

crates/oxc_language_server/src/snapshots/fixtures_linter_ignore_patterns@ignored-file.ts.snap

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
---
22
source: crates/oxc_language_server/src/tester.rs
3-
input_file: crates/oxc_language_server/fixtures/linter/ignore_patterns/another_config/not-ignored-file.ts
43
---
4+
##########
5+
file: fixtures/linter/ignore_patterns/ignored-file.ts
6+
----------
7+
File is ignored
8+
##########
9+
file: fixtures/linter/ignore_patterns/another_config/not-ignored-file.ts
10+
----------
11+
512
code: "eslint(no-debugger)"
613
code_description.href: "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html"
714
message: "`debugger` statement is not allowed\nhelp: Remove the debugger statement"

0 commit comments

Comments
 (0)