Repository navigation
fix(typescript): discover active Jest/Vitest test modifiers #3506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
EffortlessSteven
merged 13 commits into
main
from
fix/typescript-active-test-modifiers-3500
Aug 29, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d21f88b
fix(typescript): discover active test modifiers
EffortlessSteven 28463c4
test(typescript): cover active suite declaration grammar
EffortlessSteven 6e84234
test(typescript): isolate declaration extraction proof
EffortlessSteven 46d8e63
refactor(typescript): keep extraction proof in its own module
EffortlessSteven cf6072e
test(typescript): register focused extraction tests
EffortlessSteven 26d10ca
fix(typescript): reject invalid modifier chains
EffortlessSteven 2be3645
test(typescript): reject impossible modifier chains
EffortlessSteven 03b8035
test(typescript): prove modifier order symmetry
EffortlessSteven 45cd2bd
fix(typescript): preserve valid chainable modifiers
EffortlessSteven 3c2f038
test(typescript): preserve chainable modifier semantics
EffortlessSteven 5b9fa56
style(typescript): apply rustfmt to extraction proof
EffortlessSteven ab772a9
Merge branch 'main' into fix/typescript-active-test-modifiers-3500
EffortlessSteven 1b1fc1a
test(typescript): pin mixed active+disabled chains and refresh the ea…
EffortlessSteven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
223 changes: 223 additions & 0 deletions
223
crates/ripr/src/analysis/language/typescript/tests_extract_tests.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,223 @@ | ||
| //! Focused extraction tests for active Jest/Vitest declaration forms. | ||
|
|
||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn extracts_active_test_modifiers_with_assertions() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| test.only("focused", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| it.concurrent("parallel", () => { | ||
| expect(add(1, 2)).toBe(3); | ||
| }); | ||
| test.sequential("serial", () => { | ||
| expect(normalize("x")).toBe("x"); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert_eq!(tests.len(), 3); | ||
| assert_eq!(tests[0].local_name, "focused"); | ||
| assert_eq!(tests[1].local_name, "parallel"); | ||
| assert_eq!(tests[2].local_name, "serial"); | ||
| assert!(tests.iter().all(|test| test.assertions.len() == 1)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn recurses_active_describe_modifiers() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| describe.only("focused suite", () => { | ||
| test("focused case", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| }); | ||
| describe.concurrent("parallel suite", () => { | ||
| it("parallel case", () => { | ||
| expect(add(1, 2)).toBe(3); | ||
| }); | ||
| }); | ||
| describe.sequential("serial suite", () => { | ||
| test("serial case", () => { | ||
| expect(normalize("x")).toBe("x"); | ||
| }); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert_eq!(tests.len(), 3); | ||
| assert_eq!(tests[0].name, "focused suite focused case"); | ||
| assert_eq!(tests[1].name, "parallel suite parallel case"); | ||
| assert_eq!(tests[2].name, "serial suite serial case"); | ||
| assert!(tests.iter().all(|test| test.describe_names.len() == 1)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn recurses_bare_and_modified_parameterized_suites() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| describe.each([[100], [150]])("amount %i", () => { | ||
| test("discount", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| }); | ||
| describe.concurrent.each([[1], [2]])("parallel %i", () => { | ||
| it.only("adds", () => { | ||
| expect(add(1, 2)).toBe(3); | ||
| }); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert_eq!(tests.len(), 2); | ||
| assert_eq!(tests[0].name, "amount %i discount"); | ||
| assert_eq!(tests[0].describe_names, vec!["amount %i".to_string()]); | ||
| assert_eq!(tests[1].name, "parallel %i adds"); | ||
| assert_eq!(tests[1].describe_names, vec!["parallel %i".to_string()]); | ||
| assert!(tests.iter().all(|test| test.assertions.len() == 1)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn recognizes_active_modifier_chains_before_each_in_either_order() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| test.only.each([ | ||
| [100, 90], | ||
| [150, 140], | ||
| ])("discounts %#", (amount, expected) => { | ||
| expect(applyDiscount(amount, 100)).toBe(expected); | ||
| }); | ||
| it.concurrent.only.each([ | ||
| [1, 2, 3], | ||
| ])("adds concurrently %#", (left, right, expected) => { | ||
| expect(add(left, right)).toBe(expected); | ||
| }); | ||
| test.only.sequential.each([ | ||
| ["x", "x"], | ||
| ])("normalizes sequentially %#", (value, expected) => { | ||
| expect(normalize(value)).toBe(expected); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert_eq!(tests.len(), 3); | ||
| assert_eq!(tests[0].local_name, "discounts %#"); | ||
| assert_eq!(tests[1].local_name, "adds concurrently %#"); | ||
| assert_eq!(tests[2].local_name, "normalizes sequentially %#"); | ||
| assert!(tests.iter().all(|test| test.assertions.len() == 1)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn keeps_repeated_and_mixed_active_modifier_chains_discoverable() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| test.only.only("repeated focus", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.concurrent.concurrent("repeated concurrent", () => { | ||
| expect(add(1, 2)).toBe(3); | ||
| }); | ||
| test.concurrent.sequential("mixed execution flags", () => { | ||
| expect(add(2, 3)).toBe(5); | ||
| }); | ||
| describe.sequential.concurrent("mixed suite flags", () => { | ||
| test("nested active", () => { | ||
| expect(normalize("x")).toBe("x"); | ||
| }); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert_eq!(tests.len(), 4); | ||
| assert_eq!(tests[0].local_name, "repeated focus"); | ||
| assert_eq!(tests[1].local_name, "repeated concurrent"); | ||
| assert_eq!(tests[2].local_name, "mixed execution flags"); | ||
| assert_eq!(tests[3].name, "mixed suite flags nested active"); | ||
| assert!(tests.iter().all(|test| test.assertions.len() == 1)); | ||
| } | ||
|
|
||
| #[test] | ||
| fn keeps_disabled_conditional_expected_failure_and_unknown_declarations_uncredited() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| test.skip("skipped", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| it.todo("todo"); | ||
| describe.skip("disabled suite", () => { | ||
| test("nested", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| }); | ||
| test.runIf(true)("conditional", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.skipIf(false)("conditional skip", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.fails("expected failure", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| runner.only("unknown root", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.retry("unknown modifier", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.only.skip("active then disabled", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| test.skip.only("disabled then active", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| describe.only.skip("active then disabled suite", () => { | ||
| test("nested", () => { | ||
| expect(applyDiscount(100, 100)).toBe(90); | ||
| }); | ||
| }); | ||
| "#, | ||
| ); | ||
|
|
||
| assert!(tests.is_empty()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn extracted_active_test_reaches_direct_owner_relation() { | ||
| let tests = extract_tests( | ||
| Path::new("tests/pricing.test.ts"), | ||
| r#" | ||
| test.only("discount boundary", () => { | ||
| const result = applyDiscount(100, 100); | ||
| expect(result).toBe(90); | ||
| }); | ||
| "#, | ||
| ); | ||
| assert_eq!(tests.len(), 1); | ||
|
|
||
| let owner = TypeScriptOwner { | ||
| name: "applyDiscount".to_string(), | ||
| file: PathBuf::from("src/pricing.ts"), | ||
| start_line: 1, | ||
| end_line: 20, | ||
| owner_kind: OwnerKind::Function, | ||
| class_name: None, | ||
| decorated: false, | ||
| imports: Vec::new(), | ||
| }; | ||
| let candidates = related_test_candidates(&owner, &tests, None, &ReExportIndex::empty(), None); | ||
|
|
||
| assert_eq!(candidates.len(), 1); | ||
| assert_eq!( | ||
| candidates[0].relation, | ||
| TypeScriptRelationKind::DirectOwnerCall | ||
| ); | ||
| assert_eq!(candidates[0].test.name, "discount boundary"); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.eachtestsFailure mode: when the new grammar extracts
test.only.each(...)orit.concurrent.each(...)with a row-derived expected value,table_case_testinstatic_limit.rsstill recognizes only bodies beginning withtest.each(orit.each(. The test therefore receives the generic dynamic-assertion limitation but loses the more specifictypescript_table_case_unresolvedevidence, even though row binding remains unsupported. Fix direction: share the accepted.eachgrammar with table-case detection or store this fact during extraction, then add an output-level regression for a modified table test. Validation: run the focused TypeScript tests pluscargo xtask goldens check. Confidence: High, based on the direct predicate mismatch; compilation could not be run because the environment could not downloadoxc_allocator.AGENTS.md reference: AGENTS.md:L262-L271
Useful? React with 👍 / 👎.