From 00e6baa6b570cc22a9b45fee8fd3a692741017fb Mon Sep 17 00:00:00 2001 From: Seiya <20365512+seiyab@users.noreply.github.com> Date: Thu, 30 Oct 2025 23:39:44 +0900 Subject: [PATCH] Remove flaky test (#18154) --- tests/unit/doc-printer.js | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/tests/unit/doc-printer.js b/tests/unit/doc-printer.js index 86988d922..cd58fa8cf 100644 --- a/tests/unit/doc-printer.js +++ b/tests/unit/doc-printer.js @@ -1,4 +1,3 @@ -// TODO: Find a better way to test the performance import { fill, join, line } from "../../src/document/builders.js"; import { printDocToString } from "../../src/document/printer.js"; @@ -33,38 +32,10 @@ test("`printDocToString` should not manipulate docs", () => { ); const orignalLength = hugeParts.length; - const startTime = performance.now(); const { formatted } = printDocToString(fill(hugeParts), printOptions); - const endTime = performance.now(); expect(hugeParts.length).toBe(orignalLength); const lines = formatted.split("\n"); expect(lines.length).toBeGreaterThan(1000); - expect(endTime - startTime).toBeLessThan(150); - } -}); - -describe("`printDocToString` has linear time complexity at most to print fill()", () => { - const baseSize = 3_000; - const relativeMargin = 0.7; - const baseTime = time(makeFill(baseSize)); - test.each([20_000, 40_000, 60_000])("numWords=%d", (numWords) => { - const doc = makeFill(numWords); - const ellapsed = time(doc); - const ratio = numWords / baseSize; - expect(ellapsed).toBeLessThan(baseTime * ratio * (1 + relativeMargin)); - }); - - function makeFill(numWords) { - const WORD = "word"; - const parts = Array.from({ length: numWords }, () => WORD); - return fill(join(line, parts)); - } - - function time(doc) { - const printOptions = { printWidth: 40, tabWidth: 2 }; - const start = performance.now(); - printDocToString(doc, printOptions); - return performance.now() - start; } });