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

0.1.6 • Public • Published

@lightspeed/cypress-utilities

npm version

Introduction

Set of commands to use in Cypress to simplify writing tests.

Quick Start

Install

yarn add -D @lightspeed/cypress-utilities

Setup

Add the custom commands to your Cypress installation:

// In `cypress/support/commands.js`:
import '@lightspeed/cypress-utilities/add-commands';

If you use TypeScript, import types in tsconfig.json.

{
  "compilerOptions": {
    "types": ["cypress", "@lightspeed/cypress-utilities"]
  }
}

Commands

cy.login

Allows to log in the application using OAuth requests, without the UI.

cy.login({
  authBaseUrl: 'https://accounts.myapp.com',
  authUserId: 'first.last@lightspeedhq.com',
  authUserPassword: 'password123',
  // By default `authLoginUrl` uses `${authBaseUrl}/login`, but you can change it
  // if the login URL has a different base URL or login route:
  authLoginUrl: 'https://accounts.myotherapp.com/my-other-login',
});

Since those options are most probably environment based, they all default to Cypress.env() equivalent values. We recommend defining them in your cypress.env.json (see docs) as environment variables, and simply call cy.login() in your tests.

For example, in your cypress.env.json:

{
  "authBaseUrl": "https://accounts.myapp.com",
  "authUserId": "first.last@lightspeedhq.com",
  "authUserPassword": "password123"
}

Then in your Cypress tests simply write:

cy.login();

You can read the Cypress documentation on how to override these values on other environments such as CI.

Options

Name Description Default
authBaseUrl Base URL for the authentication server, including https://. Cypress.env('authBaseUrl')
authUserId The username of the user to log in. Cypress.env('authUserId')
authUserPassword The password of the user to log in. Cypress.env('authUserPassword')
authLoginUrl (optional) Login URL to send the XHR request with username and password. ${authBaseUrl}/login

Readme

Keywords

none

Package Sidebar

Install

npm i @lightspeed/cypress-utilities

Weekly Downloads

1

Version

0.1.6

License

MIT

Unpacked Size

8.42 kB

Total Files

11

Last publish

Collaborators

  • kurt.bergeron
  • lightspeedhq
  • ls-guillaume-lambert
  • ls-frederic-bouchard
  • anomen