@christianacca/angular-swa-auth-e2e-util
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

public-angular-swa-auth-e2e-util

Helper library for faking Azure Static Web App authentication endpoints in a cypress test project

Usage

1. Install library

npm install @christianacca/angular-swa-auth-e2e-util -D

2. Wire-up to support files

In your cypress test project include the following code in the support files:

// support/add-commands.ts

import { loggedIn, loggedInAs, loggedOut } from '@christianacca/angular-swa-auth-e2e-util';

declare global {
  // eslint-disable-next-line @typescript-eslint/no-namespace
  namespace Cypress {
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    interface Chainable<Subject> {
      loggedIn: typeof loggedIn;
      loggedInAs: typeof loggedInAs;
      loggedOut: typeof loggedOut;
    }
  }
}

//
// -- This is a parent command --
Cypress.Commands.add('loggedIn', loggedIn);
Cypress.Commands.add('loggedInAs', loggedInAs);
Cypress.Commands.add('loggedOut', loggedOut);
// support/global-before-each.ts

import { fakeStaticWebAppAuth } from '@christianacca/angular-swa-auth-e2e-util';

beforeEach(fakeStaticWebAppAuth);
// support/index.ts

import './add-commands';
import './global-before-each';

3. Fake login in your tests

describe('app', () => {
  context('user logged in', () => {
    beforeEach(() => {
      cy.loggedIn();
    });

    it('...', () => {
      cy.visit('/');

      // snip
    });
  });
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    2

Package Sidebar

Install

npm i @christianacca/angular-swa-auth-e2e-util

Weekly Downloads

2

Version

0.1.0

License

none

Unpacked Size

43.7 kB

Total Files

18

Last publish

Collaborators

  • christianacca