Repository navigation
Accept record metadata in the Cypress adapter - #7
SilinMykola wants to merge 2 commits into
Conversation
The Playwright adapters already add a metadata object to each record. Cypress records could only be identified by spec, title path and retry, which cannot tell apart two tests with the same title in one spec. A metadata function, called once per test in afterEach, now adds fields such as a test attempt ID without replacing the record's own fields.
|
Thanks, @SilinMykola! Could we also update the Playwright fixture here? The low-level Could we preserve custom metadata while keeping the built-in fields protected, and add a regression test confirming that the attempt ID survives through the wrapper? Then, in [MageLens/MageLens#85](MageLens/MageLens#85), we can pass The existing object-based Playwright API should be sufficient—we just need to carry that ID through the full integration. 🙂 |
withTemplateCoverage replaced the metadata of templateCoverageOptions with the test identity fields, so a test attempt ID passed per test was dropped. Custom fields are now kept, and spec, test, retry, project and worker still describe the running test.
|
Done in 5048972. |
Adds a
metadataoption to the CypressregisterTemplateCoverage, matching the Playwrightmetadataoption, and keeps custommetadatapassed to the PlaywrightwithTemplateCoveragefixture throughtemplateCoverageOptions; the fixture used to replace it with the test identity fields.metadatais a function called once per test inafterEach; the object it returns is spread into the record before the record's own fields, soschemaVersion,recordId,spec,test,retry,ids,hitsandreferencescannot be replaced. A non-function option or a non-object result throws. Without the option, records are unchanged.MageLens needs it to match Cypress template records to test attempts (MageLens/MageLens#72, MageLens/MageLens#85): spec, title path and retry cannot tell apart two tests with the same title in one spec. Agreed in MageLens/MageLens#72 (comment).
Tests
New
test/playwright/metadata.spec.js: anattemptfield passed throughtemplateCoverageOptionsreaches the record written by the fixture, whilespec,testandretrystill describe the running test. It fails when the fixture drops custom metadata or lets it replace those fields.New
test/cypress-support.test.jsruns the adapter'safterEachwith stand-ins for the Cypress globals: records without metadata are unchanged, metadata fields are added without replacing the record's own fields, and invalid options are rejected. Each case fails when the behavior is removed.npm test: 55/55 andnpm run test:playwright: 14/14 with Chrome 157,npm run test:typespasses. On macOS both suites needTMPDIRset to its real path:/varis a symlink to/private/var, and the fixtures' symlink protection rejects the temporary copies otherwise; that happens onmaintoo.Not run: the Magento Cypress harness
npm run test:browser, which needs a Magento checkout.