@tracetest/cypress
TypeScript icon, indicating that this package has built-in type declarations

0.0.37 • Public • Published

@tracetest/cypress

NPM Published Version

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(() => {
  cy.visit('/', {
    // this also initializes the test creation and execution
    onBeforeLoad: win => tracetest.capture(win.document),
  });
});

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

> pokeshop@1.0.0 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

Package Sidebar

Install

npm i @tracetest/cypress

Repository

tracetest.io

Homepage

tracetest.io

Weekly Downloads

1,411

Version

0.0.37

License

ISC

Unpacked Size

415 kB

Total Files

89

Last publish

Collaborators

  • xoscar
  • olensmar