prettier-cli icon indicating copy to clipboard operation
prettier-cli copied to clipboard

Consider switching from jest to vitest

Open 43081j opened this issue 8 months ago • 4 comments

it should speed up test runs a fair bit, and simplify the DX for us

jest is a bit clunky these days and heavyweight. we can make a branch and compare, if needed though.

43081j avatar Apr 25 '25 13:04 43081j

As I understand, the CLI test heavily relay on child process, the Jest part only do assertion, not really important, also Prettier currently still runs on Jest, stay with Jest maybe a better choice, so it will be easier when we merge code into core.

fisker avatar Apr 25 '25 15:04 fisker

that's a fair point

we would probably need to move prettier to vitest first

i think that's the only thing preventing us from doing it. the process stuff should still be fine in theory, but would need some testing

let's leave this for now then 👍

43081j avatar Apr 25 '25 15:04 43081j

I thought about it before, my concern is transforming, I don't want the test lib to do transforming which can potentially hide bugs. I haven't check how vitest works, but I assume it also supports transform: {} like Jest.

I hope to move to node --test directly someday. There are already several repos using Vitest in Prettier org.

fisker avatar Apr 25 '25 16:04 fisker

stay with Jest maybe a better choice, so it will be easier when we merge code into core.

That's maybe the main thing to think about. Though I'm not sure switching to something else would make it significantly harder?

As I understand, the CLI test heavily relay on child process, the Jest part only do assertion, not really important

The speedup would come from parallelizing test() calls within a file, which as I understand it currently isn't the case in Jest (?) and there's no option to enable it. Maybe Vite doesn't support this either, but whatever we may switch to should support that or there isn't much speedup to be gained I think.

fabiospampinato avatar Jun 14 '25 19:06 fabiospampinato