@tracetest/cypress
v0.2.1
Published
Tracetest x Cypress integration package
Downloads
178
Readme
@tracetest/cypress
About
This module provides a way to enhance your existing Cypress E2E tests with trace-based testing. It allows you to create, run, and orchestrate Tracetest Tests based on your existing Cypress scripts with minimal configuration and code.
To find a detailed step-by-step tutorial on how to use this module head out to the main integration page in our docs.
Usage
Import and Create the Tracetest Instance
import Tracetest, { Types } from '@tracetest/cypress';
const TRACETEST_API_TOKEN = Cypress.env('TRACETEST_API_TOKEN') || '';
let tracetest: Types.TracetestCypress | undefined = undefined;
before(done => {
Tracetest({ apiToken: TRACETEST_API_TOKEN }).then(instance => {
tracetest = instance;
done();
});
});
Follow the guide in the Tracetest documentation website to generate the
TRACETEST_API_TOKEN
Capture the Tracetest Parent for the Current Test
beforeEach(() => {
tracetest.capture();
cy.visit('/');
});
Wait for the Trace-Based Tests to Complete
// Optional: You can add this to the code to fail the execution based on the trace-based tests results
after(done => {
tracetest.summary().then(() => done());
});
Output
> [email protected] cy:run
> cypress run
DevTools listening on ws://127.0.0.1:61188/devtools/browser/2608646e-0c44-42a6-8d91-78e31ca6f11f
2024-02-15 13:22:51.018 Cypress[3505:41151705] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped
====================================================================================================
(Run Starting)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 13.6.3 │
│ Browser: Electron 114 (headless) │
│ Node Version: v20.11.0 (/Users/oscar/.nvm/versions/node/v20.11.0/bin/node) │
│ Specs: 1 found (home.cy.ts) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
────────────────────────────────────────────────────────────────────────────────────────────────────
Running: home.cy.ts (1 of 1)
Home
✓ imports a pokemon (1471ms)
1 passing (14s)
(Results)
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 13 seconds │
│ Spec Ran: home.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
====================================================================================================
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ home.cy.ts 00:13 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! 00:13 1 1 - - -
Useful Links
- For a detailed step-by-step tutorial on how to use this module: visit https://docs.tracetest.io/tools-and-integrations/cypress
- For a blog post written around this integration: visit https://tracetest.io/blog/cloud-native-observability-and-cypress-an-unlikely-marriage
- If you want to get in touch with the Tracetest team: visit https://dub.sh/tracetest-community