How to Store Artifacts After Tests Fail

I have a playwright test suite that runs well on my local environment but continues to hang on CI. I wanted to run the trace results outputted by playwright after the test fails but I’m unsure how to store the artifacts if I need to call - store_artifacts after the failing test step.

Hi @jimjeffers, and welcome to the CircleCI community!

You would indeed need to store whichever file contains the generated trace results. But prior to that, you need to ensure said trace results are generated upon the test failure.

To do so:

  1. Add a step (after the actual “test run” step) that generates the trace results, and add the when: on_fail attribute to that additional step.
  2. Add the store_artifacts step with the appropriate path. (Note: by design, store_artifacts has an implicit when: always attribute, so it runs regardless of the outcome of previous steps in the job.)

Let me know if this helps.