docs(formatter): add vitest-test-call to known divergences (#28006)

This commit is contained in:
leaysgur committed 2026-10-21 02:15:22 +00:00
1 parent bd70a9ba97
commit 880d229614
4 files changed
+152

No files matched your search

+38
View File
@@ -772,6 +772,44 @@ Prettier's compact test call layout merges and reverses the comments, and is not
We fall back to the regular argument layout when comments sit around the arguments, following prettier/prettier#20043.
A same-line block comment also falls back, the same output as the other special call layouts (React hook, `require`).
## vitest-test-call
- Why: uniform-rule (same construct, same output: `it.only(name, callback)`)
- Pin: `tests/fixtures/js/calls/vitest-test-call.js`
```js
// input (printWidth: 80)
it.only("does something really long and descriptive with the formatter output", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output", async () => {
expect(1).toBe(1);
});
// ours: both keep the compact test call layout
it.only("does something really long and descriptive with the formatter output", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output", async () => {
expect(1).toBe(1);
});
// prettier: `it.only` keeps it, `it.concurrent` breaks the arguments
it.only("does something really long and descriptive with the formatter output", async () => {
expect(1).toBe(1);
});
it.concurrent(
"does something really long and descriptive with the formatter output",
async () => {
expect(1).toBe(1);
},
);
```
Vitest's test calls (`.concurrent`, `.sequential`, `.fails`, `.shuffle`, `bench`) and `Deno.test` take the same `(name, callback)` arguments as `it.only`, and get its compact test call layout.
Prettier's callee list covers only the Jest / Jasmine / Playwright names, so the others print like any other call.
The full callee list is `contains_a_test_pattern` in `src/utils/call_expression.rs`.
## callee-arguments-gap-comment
- Why: invariant
@@ -190,6 +190,13 @@ pub fn callee_name_iterator<'b>(expr: &'b Expression<'_>) -> Option<impl Iterato
/// └─ Deno.test
/// ```
///
/// Names outside Prettier's list are DIVERGENCES.md#vitest-test-call.
///
/// NOTE: `skipIf`, `runIf` and `extend` match only a direct `(name, callback)` call,
/// which is not how Vitest uses them.
/// `it.skipIf(cond)("name", fn)` has a call as its callee, so it is not a test call here, same as Prettier.
/// `test.extend` takes a fixtures object, not a test call either.
///
/// Implementation (trie-tree) is inspired by the article:
/// <https://craftinginterpreters.com/scanning-on-demand.html#tries-and-state-machines>
pub fn contains_a_test_pattern(expr: &Expression<'_>) -> bool {
@@ -0,0 +1,23 @@
it.only("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
describe.shuffle("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
test.fails("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
bench("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
Deno.test("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
@@ -0,0 +1,84 @@
---
source: crates/oxc_formatter/tests/fixtures/mod.rs
---
==================== Input ====================
it.only("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
describe.shuffle("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
test.fails("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
bench("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
Deno.test("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
==================== Output ====================
------------------
{ printWidth: 80 }
------------------
it.only("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
describe.shuffle("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
test.fails("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
bench("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
Deno.test("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
-------------------
{ printWidth: 100 }
-------------------
it.only("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
it.concurrent("does something really long and descriptive with the formatter output, over the print width", async () => {
expect(1).toBe(1);
});
describe.shuffle("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
test.fails("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
bench("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
Deno.test("does something really long and descriptive with the formatter output, over the print width", () => {
run();
});
===================== End =====================