Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins folder not supported #2

Open
AlphaGeek opened this issue Dec 6, 2022 · 8 comments · Fixed by #4
Open

Plugins folder not supported #2

AlphaGeek opened this issue Dec 6, 2022 · 8 comments · Fixed by #4

Comments

@AlphaGeek
Copy link

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+?

@xec
Copy link
Member

xec commented Dec 7, 2022

Ah yes, they changed cypress config in 10.* :(

It should be fairly similar though, can you test something like this and see if it works for you?

in cypress.config.js (should be on project root, not under cypress/, I believe)

import { defineConfig } from 'cypress'
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);

export default defineConfig({
  // ...other cypress settings here...
  e2e: {
    setupNodeEvents(on, config) {
      // `on` is used to hook into various events Cypress emits
      on('task', {
        // register a task named login which calls the generated login from @intility/cypress-msal
        login
      })
    }
  }
})

@AlphaGeek
Copy link
Author

Thanks, tried this but am getting the error below...may be due to the import { defineConfig } from 'cypress' line:

ReferenceError
The following error originated from your test code, not from Cypress.

process is not defined

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.
node_modules/ci-info/index.js:5:1
3 | const vendors = require('./vendors.json')
4 |

5 | const env = process.env
| ^
6 |
7 | // Used for testing only
8 | Object.defineProperty(exports, '_vendors', {

@h3rmanj
Copy link
Member

h3rmanj commented Feb 3, 2023

Hi @AlphaGeek, I merged the updated getting started section, which hopefully resolves your issue 😊

@AlphaGeek
Copy link
Author

AlphaGeek commented Mar 20, 2023

still getting the "login is not a function" error in the before()

using latest Cypress version

@xec
Copy link
Member

xec commented Mar 22, 2023

still getting the "login is not a function" error in the before()

using latest Cypress version

@AlphaGeek can you share (the important parts of) your config / setup?

@h3rmanj h3rmanj reopened this Mar 22, 2023
@AlphaGeek
Copy link
Author

AlphaGeek commented Mar 23, 2023

cypress.config.ts (does it matter that it is a TS file?) [client_id] is replaced by our QA client id and [tenant] is replaced by our tentant

import { defineConfig } from "cypress";
import generateLogin from "@intility/cypress-msal"

let publicClientConfig = {
auth: {
clientId: "[client_id]",
authority: "https://login.microsoftonline.com/[tenant]",
},
};

let requests = [
{
scopes: [our_scope],
},
];

let login = generateLogin(publicClientConfig, requests);

export default defineConfig({
e2e: {
defaultCommandTimeout: 20000,
"retries": {
// Configure retry attempts for cypress run
// Default is 0
"runMode": 2,
// Configure retry attempts for cypress open
// Default is 0
"openMode": 2
},
"viewportHeight": 1080,
"viewportWidth": 1920,
"baseUrl": "https://localhost:5173", //"https://summitqa.blairnet.net"
"redirectionLimit": 5,
"specPattern": "cypress/e2e/**/*.{js,jsx,ts,tsx,feature}",
setupNodeEvents(on, config) {
on("task", {
// register a task named login which calls the generated login from @intility/cypress-msal
login,
});
}
}
});

my cypress test (smokeTest.js):

describe("Ensure site is up and running", () => {
/before(() => {
cy.exec('npm run get-token')
cy.wait(1000)
})
/
before(() => cy.login());

it("Home page should open", () => {
cy.visit("/")
cy.wait(14000)
})

it("Should display the WB logo", () => {
cy.get('.logo').should('be.visible')
})

it("Should have All Active silos", () => {
cy.get('.p-carousel-item-active').contains('All Activity')
})

it("Should have Trading Desk Commentary silos", () => {
cy.get('.p-carousel-item-active').contains('Trading Desk Commentary')
})

after(() => {
cy.exec('npm run clear-token')
})
})

run using "npx cypress open"

currently running 10.11.0 of Cypress but have tried with 12.* and had same issue

@AlphaGeek
Copy link
Author

tried using: before(() => cy.task('login')); instead of: before(() => cy.login); and that seemed to help in that I think it found it but then it timed out

@h3rmanj
Copy link
Member

h3rmanj commented Nov 23, 2023

Sorry the late response, we haven't really had time to maintain this package. Just ran into something similar myself; #5 (comment)

Did you find another solution to your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants