Skip to content

test: refactor formatter testing infra#9588

Merged
ematipico merged 1 commit intomainfrom
test/refactor-testing-infra
Mar 22, 2026
Merged

test: refactor formatter testing infra#9588
ematipico merged 1 commit intomainfrom
test/refactor-testing-infra

Conversation

@ematipico
Copy link
Copy Markdown
Member

Summary

This PR is a big one, but I believe it's for the best.

The current formatter infrastructure is old and not very well maintainable. Nowadays, every time we add a new top-level option, we need to implement Display, and all existing snapshots need updating. This isn't good for users and us maintainers.

This PR refactors the infra, and it uses the Workspace for easy implementation. It removes the Display implementation and shows it as it is.

It also removes the double output. While it was useful at the beginning, I don't think it's as useful now. We have plenty of tests and if there's a regression, we should be able to catch it.

I developed the refactor with a coding agent.

Test Plan

Green CI

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 22, 2026

⚠️ No Changeset found

Latest commit: 7cea2cd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ematipico ematipico changed the title test: refactor test infra test: refactor formatter testing infra Mar 22, 2026
@ematipico ematipico requested review from a team March 22, 2026 18:02
@github-actions github-actions Bot added A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS and super languages L-JSON Language: JSON and super languages L-HTML Language: HTML and super languages L-Grit Language: GritQL L-Markdown Language: Markdown labels Mar 22, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 22, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 159 skipped benchmarks1


Comparing test/refactor-testing-infra (7cea2cd) with main (956e367)

Open in CodSpeed

Footnotes

  1. 159 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 22, 2026

Walkthrough

This PR introduces similar-asserts as a workspace dependency and refactors formatter test infrastructure across CSS, GraphQL, Grit, and HTML formatters. The changes migrate from direct parsing/formatting pipelines to a workspace-based approach using biome_service::workspace, simplifying test setup by replacing generic TestFormatLanguage wiring with concrete Configuration objects. The SpecSnapshot struct is refactored from a generic type to store an initial_configuration and handle formatting through the workspace API, including idempotency checks and error recovery logic.

Possibly related PRs

Suggested labels

A-Formatter, A-Project, A-Tooling, L-CSS, L-HTML, L-Grit

Suggested reviewers

  • dyc3
  • siketyan
  • chansuke
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: a refactor of the formatter testing infrastructure across multiple formatter crates.
Description check ✅ Passed The description directly relates to the changeset, explaining the motivation behind the testing infrastructure refactor and removal of the Display-based approach.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/refactor-testing-infra

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_html_formatter/tests/quick_test.rs (1)

12-20: ⚠️ Potential issue | 🟡 Minor

Open this sample as Svelte, not plain HTML.

{#snippet ...} is Svelte syntax, but test.html with document_file_source: None will be treated as HTML. If someone unignores this, they’ll be debugging the wrong parser.

🛠️ One simple fix
-    let path = BiomePath::new("test.html");
+    let path = BiomePath::new("test.svelte");

Based on learnings: Inspect AST structure before implementing parser/formatter changes using the parser crate's quick_test.

Also applies to: 31-43

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_html_formatter/tests/quick_test.rs` around lines 12 - 20, The
sample test input (variable src) contains Svelte-specific syntax (`{`#snippet`
...}`) but is being run as plain HTML; update the test invocation that calls the
parser/quick_test helper (in this file's test function using quick_test from the
parser crate) to provide a Svelte document source/extension so the parser treats
it as Svelte (for example set document_file_source to Some("test.svelte") or
otherwise pass a filename with .svelte) before running assertions; locate the
call that consumes src in quick_test.rs and change its test harness/argument to
indicate Svelte so the Svelte AST is produced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_formatter_test/src/spec.rs`:
- Around line 309-312: The test currently skips assertions when re-formatting
fails or produces empty output, masking formatter regressions; in the block
handling the formatter result (the match that yields Err(_) and the subsequent
check using re_printed.as_code()), change the Err(_) => return early-return into
a test failure or logged panic that includes the error details from the
formatter, and remove (or at least replace with an explicit assertion) the
!re_printed.as_code().is_empty() guard so that empty formatted output causes the
test to fail and surface the issue (use the existing re_printed and its
as_code() for the message).

In `@crates/biome_html_formatter/tests/spec_test.rs`:
- Around line 10-12: The test currently panics when SpecTestFile::try_from_file
returns None (e.g., for options.json), so change the panic into a graceful skip:
replace the `let Some(test_file) = SpecTestFile::try_from_file(...) else {
panic!(...) }` pattern with an explicit match or if-let that returns early or
continues the test harness when None is returned (e.g., `if let Some(test_file)
= SpecTestFile::try_from_file(...) { /* run assertions */ } else { return; }`),
ensuring the harness skips spec directories that intentionally produce None
instead of failing; keep all processing logic that uses the resulting test_file
(the test_file variable / SpecTestFile) unchanged.

---

Outside diff comments:
In `@crates/biome_html_formatter/tests/quick_test.rs`:
- Around line 12-20: The sample test input (variable src) contains
Svelte-specific syntax (`{`#snippet` ...}`) but is being run as plain HTML; update
the test invocation that calls the parser/quick_test helper (in this file's test
function using quick_test from the parser crate) to provide a Svelte document
source/extension so the parser treats it as Svelte (for example set
document_file_source to Some("test.svelte") or otherwise pass a filename with
.svelte) before running assertions; locate the call that consumes src in
quick_test.rs and change its test harness/argument to indicate Svelte so the
Svelte AST is produced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7ad2119e-c644-4758-bbae-961e1e35827f

📥 Commits

Reviewing files that changed from the base of the PR and between 956e367 and 7cea2cd.

⛔ Files ignored due to path filters (282)
  • Cargo.lock is excluded by !**/*.lock and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/charset.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/color_profile.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/container.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/counter_style.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/document.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/font_face.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/font_feature_values.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/function.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/import.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/keyframes.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/layer.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/media.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/namespace.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/page.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/page_complex.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/property.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/scope.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/starting_style.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/supports.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/supports_complex.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/tailwind/source-not.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/unknown.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/atrule/value.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/attr.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/block.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/casing.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/color/functional_colors.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/color/hex_colors.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/comma_separated_values.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/composes.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/declaration_empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/declaration_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/dimensions.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/functions.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/global_suppression.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/if.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/important.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/issue_3229.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/issue_4298.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/issue_8636.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/namespace.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/nesting/conditional_at_rule.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/nesting/nesting.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/nesting/nesting_1.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/number.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/all.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/border.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/custom.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/generic.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/grid.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/unicode_range.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/properties/z-index.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/is.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/not.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_compound_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_compound_selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_custom_identifier_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_nth.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_relative_selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_state.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_function_value_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_class_identifier.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/pseudo_element_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/pseudo/where.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/quote_style/normalize_quotes.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/between_rules.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/keyframes.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/mid_value.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/selector_list.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/single_declaration.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/single_rule.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/range/single_value.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/ratio/issue_9249.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/at-root.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/container-general-enclosed.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/container-scroll-state.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/content.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/debug-warn-error.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/declaration-block-interpolation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/each.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/else.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/extend.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/for.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/forward.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/function.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/if-else.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/import.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/include.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/mixin.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/return.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/supports-expression.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/supports-general-enclosed.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/use.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/at-rule/while.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/ambiguous-selector-vs-nesting.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/bracketed-values.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/global-flag.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/interpolation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/mixed.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/namespaced.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/nested-properties-complex-value.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/nested-properties-empty-value.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/nested-properties-with-value.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/page-at-rule.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/parent-and-colon-values.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/simple-variable.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/declaration/spacing-after-colon.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/bracketed-values.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/edge-cases.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/formatting.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/function-call.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/interpolation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/list-map-paren.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/precedence.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/qualified-names.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/expression/signed-numeric-operator.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/scss/selector/interpolation.scss.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/attribute_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/class_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/complex_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/id_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/pseudo_class/pseudo_class_has.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/selector_lists.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/selectors/type_selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/simple.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/long-apply.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/plugin-no-options.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/plugin-with-options.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/shadcn-default.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/source-inline.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/supports.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/tailwind/utility.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/trailing_newline/simple.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/unary-precedence.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/units.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/url.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/value_fill.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/value_one_group_per_line.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/value_one_per_line.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_formatter/tests/specs/css/variables.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/directive_definition.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/enum.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/enum_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/fragment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/input_object.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/input_object_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/interface.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/interface_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/object.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/object_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/scalar.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/scalar_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/schema.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/schema_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/union.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/definitions/union_extension.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/directive.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/newline_clrf.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/object/spacing/global/object_spacing.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/object/spacing/object_spacing.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/operation.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/selection_set.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/simple.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/suppression.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/trailing_newline/simple.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/type.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_formatter/tests/specs/graphql/value.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/bubble.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/comments/multifile.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/comments/top-comments.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/file_node.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/function_definition.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/global_suppression.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/list.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/map.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/complex.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/engine.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/go_code.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/go_unknown.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/python.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/react_hooks.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/marzano/shadow_scope.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/multifile.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/any.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/contains.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/create_new_files.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/definition_body.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/file_node.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/if_else.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/like.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/list_pattern.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/or.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/orelse.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/regex.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/patterns/where_pattern.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/predicates/and.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/predicates/any.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/predicates/assignment.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/predicates/or.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/sequential.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_grit_formatter/tests/specs/grit/version.grit.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/astro/component.astro.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/astro/directives.astro.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/astro/lowercase-member.astro.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/break.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/multiline/break.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/multiline/no-break.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/no-break.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/normalize-attr-casing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/self-closing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/attributes/single-quotes.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/bracket-same-line/void_elements.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/after-text-inside-div.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/after-text.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/before-text-2.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/before-text-inside-div.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/before-text.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/inline-with-block-element.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/inline.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/comments/inside-text.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/component-frameworks/html-canonical-lowercasing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/component-frameworks/large-self-closing.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/component-frameworks/svelte-component-casing.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/component-frameworks/vue-component-casing.vue.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/content-breaks-when-attr-breaks.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/directive/lowercase.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/directive/uppercase.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/directive/uppercase2.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/element.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/bracket-same-line/self-closing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/empty-extra-lines.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/iframe-allow.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/inline-before-self-closing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/mixed-block-inline.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/tags-dont-hug-content-2.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/tags-dont-hug-content.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/tags-hug-content-longer-w-attr.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/tags-hug-content-w-attr.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/inline/tags-hug-content.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/normalize-tag-casing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/pre-with-brackets.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/pre-with-braille.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/pre.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/spacing/case0.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/spacing/case1.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/spacing/case2.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/spacing/case3.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/spacing/case4.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/elements/whitespace/ignore/long-content.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/embedded/strict-whitespace-sensitivity/sensitive-style.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/interpolation/interpolation.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/long-content.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/long-inline-elements.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/many-children.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/self-closing.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/self-closing/always.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/self-closing/never.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/basic-suppression-2.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/basic-suppression.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/global_suppression.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/inline-content.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/inline-elements.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/suppressions/suppress-inside-element.html.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/attach.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_array_destructuring.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_basic.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_catch_only.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_complex_expression.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_destructuring.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_dynamic_import.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_inline.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_long_expression.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_multiline.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_multiple.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_nested.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_no_catch.svelte.snap is excluded by !**/*.snap and included by **
  • crates/biome_html_formatter/tests/specs/html/svelte/await_one_liner.svelte.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (18)
  • Cargo.toml
  • crates/biome_css_formatter/Cargo.toml
  • crates/biome_css_formatter/tests/quick_test.rs
  • crates/biome_css_formatter/tests/spec_test.rs
  • crates/biome_formatter_test/Cargo.toml
  • crates/biome_formatter_test/src/lib.rs
  • crates/biome_formatter_test/src/snapshot_builder.rs
  • crates/biome_formatter_test/src/spec.rs
  • crates/biome_graphql_formatter/Cargo.toml
  • crates/biome_graphql_formatter/tests/quick_test.rs
  • crates/biome_graphql_formatter/tests/spec_test.rs
  • crates/biome_grit_formatter/Cargo.toml
  • crates/biome_grit_formatter/tests/language.rs
  • crates/biome_grit_formatter/tests/quick_test.rs
  • crates/biome_grit_formatter/tests/spec_test.rs
  • crates/biome_html_formatter/Cargo.toml
  • crates/biome_html_formatter/tests/quick_test.rs
  • crates/biome_html_formatter/tests/spec_test.rs
💤 Files with no reviewable changes (1)
  • crates/biome_grit_formatter/tests/language.rs

Comment on lines +309 to +312
Err(_) => return, // Re-formatting failed (e.g., file with errors), skip check
};

if re_printed.as_code() != output_code && !re_printed.as_code().is_empty() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Early return and empty-output check could mask formatter bugs.

  • Line 309: Returning early when re-formatting fails means if the formatter produces syntactically invalid output from valid input, the test silently passes without building a snapshot.
  • Line 312: The !re_printed.as_code().is_empty() condition means if re-formatting produces empty output, no assertion fires. An empty result from valid formatted code is likely a bug worth catching.

Consider whether these silent exits are intentional or should at least emit a warning.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_formatter_test/src/spec.rs` around lines 309 - 312, The test
currently skips assertions when re-formatting fails or produces empty output,
masking formatter regressions; in the block handling the formatter result (the
match that yields Err(_) and the subsequent check using re_printed.as_code()),
change the Err(_) => return early-return into a test failure or logged panic
that includes the error details from the formatter, and remove (or at least
replace with an explicit assertion) the !re_printed.as_code().is_empty() guard
so that empty formatted output causes the test to fail and surface the issue
(use the existing re_printed and its as_code() for the message).

Comment on lines +10 to 12
let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path) else {
panic!("Failed to set up snapshot test");
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don’t turn the intentional None case into a failing test.

SpecTestFile::try_from_file returns None for options.json on purpose. Panicking here means HTML spec directories with formatter options will blow up instead of being skipped, unlike the other harnesses in this refactor.

🩹 Straightforward fix
-    let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path) else {
-        panic!("Failed to set up snapshot test");
-    };
+    let Some(test_file) = SpecTestFile::try_from_file(spec_input_file, root_path) else {
+        return;
+    };

Based on learnings: Create tests/specs/<language>/options.json to specify non-default formatter options for tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_html_formatter/tests/spec_test.rs` around lines 10 - 12, The
test currently panics when SpecTestFile::try_from_file returns None (e.g., for
options.json), so change the panic into a graceful skip: replace the `let
Some(test_file) = SpecTestFile::try_from_file(...) else { panic!(...) }` pattern
with an explicit match or if-let that returns early or continues the test
harness when None is returned (e.g., `if let Some(test_file) =
SpecTestFile::try_from_file(...) { /* run assertions */ } else { return; }`),
ensuring the harness skips spec directories that intentionally produce None
instead of failing; keep all processing logic that uses the resulting test_file
(the test_file variable / SpecTestFile) unchanged.

@ematipico ematipico merged commit 81b530c into main Mar 22, 2026
33 checks passed
@ematipico ematipico deleted the test/refactor-testing-infra branch March 22, 2026 18:57
@coderabbitai coderabbitai Bot mentioned this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-CSS Language: CSS and super languages L-Grit Language: GritQL L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants