npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cypress-utils-criteo

v2.0.2

Published

A set of utils used at Criteo for Cypress

Downloads

92

Readme

cypress-utils-criteo

This package offers custom Cypress commands, recommended checks, and Angular Material selectors to ease the development of Cypress tests.

Usage

Install this package npm install cypress-utils-criteo --save-dev

If you use Typescript: in the tsconfig.json file used by Cypress add the types definition: "types": ["cypress", "cypress-utils-criteo"] (under compilerOptions)

Depending on what you want to use:

For commands, in cypress/support/commands.js, add:

  • import 'cypress-utils-criteo/commands'; to import all exposed commands
  • import 'cypress-utils-criteo/commands/selectors'; to import specific ones

For recommended checks, in cypress/support/e2e.js, add:

  • import 'cypress-utils-criteo/recommended-checks'; to import all recommended checks
  • import 'cypress-utils-criteo/recommended-checks/no-open-mat-snack-bar'; to import specific ones

Commands

selectors/getByTestAttr

Get one or more DOM elements by their data-test attribute. Internally, it relies on cy.get.

Example: <input data-test="name-input" /> can be retrieved with cy.getByTestAttr('name-input')

selectors/findByTestAttr

Get the descendent DOM element(s) by their data-test attribute. Internally, it relies on cy.find.

Example: <div data-test="form-container"><input data-test="name-input" /></div> can be retrieved with cy.getByTestAttr('form-container').findByTestAttr('name-input')

drag-and-drop/dragAndDrop

Drag and drop an element in another one.

Example: cy.getByTestAttr('draggable').dragAndDrop(cy.getByTestAttr('droppable'))

analytics/checkAnalyticsCall

Checks analytics endpoint was called with expected properties.

Example:

cy.checkAnalyticsCall({
  event_type_id: 'EVENT_ID',
  extra_property: value,
});

state-management/dispatchActions

Dispatch ngxs actions.

Controlling state to achieve the desired setup for your test is a best practice (see the cypress documentation).

Your store must be exposed in the global window of your app to use it:

// app.component.ts
constructor(private readonly store: Store) {
  if ('Cypress' in window) {
    window.store = this.store;
  }
}

Example: cy.dispatchActions([{ type: 'InitData' }])

logger/logStep

Identifies a test step with separator lines before and after. Internally, it relies on cy.log.

Example: cy.logStep('Step 1')

viewport/changeViewport

Set the viewport to the correct resolution Internally, it relies on cy.viewport.

Example: cy.changeViewport(ViewportType.Mobile)

assertions/assertSort

Assert that an array is sorted in the correct order, ignoring case. Internally, it relies on cy.should and deep equality assertion.

Example: cy.assertSort(['Z', 'Y', 'X'], true)

assertions/assertInnerTextEquals

Assert that the inner text of an element matches the expected text after trimming.

Example: cy.assertInnerTextEquals('data-test-button', 'Click me')

assertions/assertInnerTextContains

Assert that the inner text of an element contains the expected text.

Example: cy.assertInnerTextContains('data-test-button', 'Partial text')

assertions/assertUrlParams

Assert that the current URL contains the specified query parameters. Internally, it relies on cy.url.

Example: cy.assertUrlParams(['param1=123', 'param2=abc'])

Recommended checks

no-open-mat-snack-bar

Ensures there is no remaining snack bar open once a test ends: it could cover some components in the following tests, prevent Cypress from interacting with them, and make the tests fail.

Material interactions

Overlay

Allows to close overlays (used for dropdowns, selects, dialogs, ...).

Example: Overlay.close()

Snackbar

Allows to easily check the status of a snackbar. The snackbar is closed automatically.

Example: Snackbar.successShouldBeVisible() or Snackbar.errorShouldBeVisible()

Tooltip

Allows to easily check whether a tooltip exists and contains some texts (optional).

Example: Tooltip.shouldExist(cy.getByTestAttr('help-icon'), ['The tooltip should contain this text.', 'It should also contain this one.'])

Development

Please use Node v16.14.0 and npm v8.3.1

Before submitting a PR, run npm run build && npm run lint:fix.