withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.31k stars 2.45k forks source link

dev: identifying flaky tests? #5195

Closed mrienstra closed 1 year ago

mrienstra commented 1 year ago

I noticed some tests: packages/create-astro/test/typescript-step.test.js#L37-L83 (which I feel somewhat responsible for, since I added them) ... seem to be flaky. I first noticed them failing in this PR: https://github.com/withastro/astro/actions/runs/3316348321/jobs/5478061799 And then again today in this PR: https://github.com/withastro/astro/actions/runs/3324584748/jobs/5496363068

I've seen other failing tests recently that didn't seem to be related to the PR, I can dig some other examples up later, or if anyone else knows of some off hand, please chime in.

Anyway -- putting aside for the moment that I need to fix those tests -- it would be great to have some way of analyzing test failures and spotting patterns. Or maybe that already exists for the Astro repo and I'm just not aware of it. So opening this issue to see what others think.

I skimmed a few articles on the subject:

CircleCI can detect flaky tests and offers free credits for open source, but that might be overkill.

Kiwi TCMS also looks like overkill, but maybe there's any easy way to just use it for testing telemetry...?

retries can be helpful for flaky tests: Mocha docs for retries. WebdriverIO has a nice summary. (Astro already retries Playwright tests 3 times in CI, 5 times in packages/integrations/prefetch) Not recommended for unit tests, but the packages/create-astro tests I mentioned are an example of tests that are kind of in between unit tests & e2e tests, maaaybe some of the other flaky test also fall into this category.

Found this package:

matthewp commented 1 year ago

We have a few. I have a list on Discord (I'll move to the #dev channel and ping you). Would love to continue the discussion there if possible. My opinion is that there are only 2 or 3 of these that cause false-positives in PRs and we should just skip or remove them. Happy to continue the discussion on discord.