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:
import { loggedIn, loggedInAs, loggedOut } from '@christianacca/angular-swa-auth-e2e-util';
declare global {
namespace Cypress {
interface Chainable<Subject> {
loggedIn: typeof loggedIn;
loggedInAs: typeof loggedInAs;
loggedOut: typeof loggedOut;
}
}
}
Cypress.Commands.add('loggedIn', loggedIn);
Cypress.Commands.add('loggedInAs', loggedInAs);
Cypress.Commands.add('loggedOut', loggedOut);
import { fakeStaticWebAppAuth } from '@christianacca/angular-swa-auth-e2e-util';
beforeEach(fakeStaticWebAppAuth);
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('/');
});
});
});