0.1.6 • Published 2 years ago

@lightspeed/cypress-utilities v0.1.6

Weekly downloads
6
License
MIT
Repository
-
Last release
2 years ago

@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

NameDescriptionDefault
authBaseUrlBase URL for the authentication server, including https://.Cypress.env('authBaseUrl')
authUserIdThe username of the user to log in.Cypress.env('authUserId')
authUserPasswordThe 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
0.1.6

2 years ago

0.1.5

3 years ago

0.1.4

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago