chromaui / chromatic-e2e

Archive end-to-end tests to be replayed in Storybook and Chromatic
MIT License
21 stars 4 forks source link

Cypress: Pass archive along instead of re-bufferizing it #168

Closed skitterm closed 3 months ago

skitterm commented 3 months ago

AP-4729

Why This Change?

Many folks (see #128) have had Cypress test runs error out when they add Chromatic. This is happening because if Chrome Devtools Protocol fails to send a method, we add an entry on the archives that has an error but no body. However, in Cypress we have been assuming all archive entries have a body, so when we bufferize the body, things error out.

What Changed

  1. In Cypress, we no longer try to rebufferize the archived resources' body-s. This rebufferize code was added when we were listening for Cypress resource requests client-side, so after sending to the server we needed to do a Buffer.from on them. But since we are now using CDP with Cypress, we already bufferize the resource body.
  2. Renamed the Watcher class (where we listen for the network and put things on the archive) to ResourceArchiver. This was to a) make clear what the class does and b) align this exported class name with the file name for consistency.

How to test

@tevanoff @mea36 I really wanted to put in a test that covers this case (CDP sends error without breaking the entire test run), but I wasn't able to pin down what exactly was causing the CDP method to fail (there's the error: invalid InterceptionId that CDP hits, but I could not figure out how to reliably tell when it will happen). I spent 30 minutes trying to nail that down, but couldn't see how to set up a test in such a way that would recreate that issue, so I left off on that.

codacy-production[bot] commented 3 months ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.00% (target: -1.00%) :white_check_mark: 100.00% (target: 80.00%)
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (fdf95bd11a1d7b1539c0228fc3bbb953c767d74a) | 259 | 245 | 94.59% | | | Head commit (1702f2194e44f809af4fceba91094c24ff16a01d) | 259 (+0) | 245 (+0) | 94.59% (**+0.00%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#168) | 3 | 3 | **100.00%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences


:rocket: Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more