A cypress plugin for projects using @azure/msal-browser

Overview


@intility/cypress-msal

A cypress plugin for projects using @azure/msal-browser.

pipeline package version

Installation

npm install @intility/cypress-msal

Usage

Register the package in support/index.js:

import "@intility/cypress-msal/command";

Configure and load the plugin in plugins/index.js:

{ on("task", { login, }); };">
import generateLogin from "@intility/cypress-msal";

let publicClientConfig = {
  auth: {
    clientId: "APP_CLIENT_ID",
    authority: "https://login.microsoftonline.com/TENANT_ID",
  },
};

let requests = [
  {
    scopes: ["User.Read"],
  },
];

let login = generateLogin(publicClientConfig, requests);

module.exports = (on, config) => {
  on("task", {
    login,
  });
};

You can now login by using the login command before running your tests.

before(() => cy.login());

Azure Configuration

The App registration needs to be a Public Application to be able to use the Device Code flow.

generateLogin

Syntax

let login = generateLogin(publicClientConfiguration, requests);

Parameters

publicClientConfiguration

A Configuration that will be used to initialize a PublicClientApplication from @azure/msal-node.

requests

An array of Requests ({ scopes: string[] }) that will be used for acquireTokenByDeviceCode and acquireTokenSilent.

Return value

A task plugin named login that should be registered with on("task", { login }).

cy.login

Syntax

cy.login()

Return value

A Promise that get resolves when all tokens are acquired and registered in sessionStorage to be used by @azure/msal-browser.

You might also like...

Live demo using Angular, github.dev, codespaces, copilot, azure static web apps, and devcontainers

Live demo using Angular, github.dev, codespaces, copilot, azure static web apps, and devcontainers

Cloud Computing with Codespaces First seen in the presentation One More Change! @ NgConf 2022 This is a quick project template for demoing github.dev,

Sep 13, 2022

An Azure blob storage executor module for Runnerty

An Azure blob storage executor module for Runnerty

Smart Processes Management Azure blob storage executor for Runnerty: Installation: To be described after packaging. Tested locally using: npm link exe

Oct 13, 2021

Our project for The Microsoft Azure Trial Hackathon on Dev.to

Our project for The Microsoft Azure Trial Hackathon on Dev.to

Moodflix your mood, our suggestions. 🎯 About Overview of our project We have started this project with the purpose of participating to the Microsoft

Dec 22, 2022

Talk about Azure SQL + Prisma

Talk - Power Up Your BackEnd Applications with Serverless Architecture & Azure SQL A demo related with the talk Power Up Your BackEnd Applications wit

Sep 13, 2022

A template repo that contains a NodeJS app that will consume messages from a RabbitMQ queue and immediately send them to an Azure EventHub.

README.md Summary This repo (RabbitMQ to EventHub Shovel) is a template that contains a NodeJS app that will consume messages from a RabbitMQ queue an

Jul 2, 2022

The simplest way to use AWS/GCP/Azure. From code to cloud in a few minutes.

The simplest way to use AWS/GCP/Azure. From code to cloud in a few minutes.

Utopiops Utopiops is the best way for teams of any size to use cloud (AWS/Azure/GCP), with or without prior experience. We provide a platform that hel

Dec 25, 2022

Create deployment files and configure GitHub Actions workflows to deploy applications to Azure Kubernetes Service (AKS).

Create deployment files and configure GitHub Actions workflows to deploy applications to Azure Kubernetes Service (AKS).

Azure Kubernetes Service (AKS) DevX (Developer experience) Extension for Visual Studio Code (Preview) The AKS DevX extension for Visual Studio Code (P

Oct 1, 2022

🚀Starter project with Angular 13, Ngx-admin, NestJS, Nx Workspace, Jest, Cypress, ESLint & Prettier 🚀

🚀Starter project with Angular 13, Ngx-admin, NestJS, Nx Workspace, Jest, Cypress, ESLint & Prettier 🚀

Angular 13 + Ngx-admin + NestJs + NX Starter project with Angular 13, Ngx-admin, NestJs, Nx Workspace, Jest, Cypress, ESLint & Prettier Features ✅ Ang

Jan 4, 2023

Projeto de exemplo para realização de testes de integração (API) utilizando o Cypress

Projeto de exemplo para realização de testes de integração (API) utilizando o Cypress

Nov 28, 2022
Comments
  • Plugins folder not supported

    Plugins folder not supported

    Docs say to include the code with the publicClientConfig, module.exports, etc in the /plugins/index.js file however I am using Cypress 10.4 and the plugins folder is no longer supported. Is there an example of how to use this with Cypress 10+?

    opened by AlphaGeek 2
Owner
Intility
Intility is a fully managed platform service that covers all areas of your business. From your managed computer to the server hosting your applications.
Intility
A Cypress plugin that generates test scripts from your interactions, a replacement Cypress Studio for Cypress v10 🖱 ⌨

DeploySentinel Cypress Recorder Plugin Create Cypress tests scripts within the Cypress test browser by simply interacting with your application, simil

DeploySentinel 13 Dec 15, 2022
JavaScript Express.js app serving static vanilla JS. This sample app is used in Microsoft Docs to demonstrate how to integrate Azure Storage, Azure Cosmos DB, and Azure Active Directory.

JavaScript on Azure Learn Path - Module 2 - Deploying a basic app to Azure This Learn module requires the following Azure resources to deploy correctl

Azure Samples 13 Dec 31, 2022
Chat app using Azure Web PubSub, Static Web Apps and other Azure services

Chatr - Azure Web PubSub Sample App This is a demonstration & sample application designed to be a simple multi-user web based chat system. It provides

Ben Coleman 55 Dec 31, 2022
Vamos a realizar un juego muy sencillo en TypeScript, posteriormente lo vamos a desplegar en Microsoft Azure con Servicio de Azure Static Web Apps.

Taller TypeScript Descripción Vamos a realizar un juego muy sencillo en TypeScript, posteriormente lo vamos a desplegar en Microsoft Azure con Servici

Manuel Ortiz 7 Oct 10, 2022
Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command

cypress-thenify Rationale Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command. Howev

Mikhail Bolotov 15 Oct 2, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A template for your Next.js projects including Typescript, Eslint, Prettier, Jest, Cypress and Docker.

Next.js Template Quickly start a new Next.js project A template for your Next.js projects including Typescript, Eslint, Prettier, Jest, Cypress and Do

Lorenzo Carneli 2 Oct 7, 2022
Live demo using Angular, github.dev, codespaces, copilot, azure static web apps, and devcontainers

One More Change! @ NgConf 2022 This is a quick project template for demoing github.dev, Codespaces, Copilot, Azure Static Web Apps, and Visual Studio

John Papa 14 Dec 15, 2022