diff --git a/tests/_shared.ts b/tests/_shared.ts new file mode 100644 index 0000000..3a03a51 --- /dev/null +++ b/tests/_shared.ts @@ -0,0 +1,6 @@ +export const removeColors = (text: string) => + text.replace( + // biome-ignore lint/suspicious/noControlCharactersInRegex: + /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, + "", + ) diff --git a/tests/help.test.ts b/tests/help.test.ts index 32cd62c..d77dfd5 100644 --- a/tests/help.test.ts +++ b/tests/help.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test" -import { reset } from "kolorist" +import { removeColors } from "./_shared" const helpOutput = ` Usage: localpen [options] @@ -34,7 +34,7 @@ test("print help message", async () => { await child.exited - expect(reset(text)).toBe(helpOutput) + expect(removeColors(text)).toBe(helpOutput) }) test("print help message on wrong template", async () => { @@ -43,6 +43,6 @@ test("print help message on wrong template", async () => { await child.exited - expect(reset(text)).toContain(helpOutput) - expect(reset(text)).toContain(" not found") + expect(removeColors(text)).toContain(helpOutput) + expect(removeColors(text)).toContain(" not found") })