bjowes / cypress-ntlm-auth

Windows authentication plugin for Cypress
MIT License
54 stars 10 forks source link

Plugin do not work with Cucumber plugin #96

Closed varunpradhan closed 4 years ago

varunpradhan commented 4 years ago

Hi @bjowes

I have cucumber plugin too along with ntlm-auth

I have added cy.ntlm('', '', '') inside Given block and it failed with an error that The cypress-ntlm-auth plugin must be loaded before using this method

example :

Given('I go to URL', () => { cy.ntlm('', '', '') cy.visit(Cypress.env('url')) cy.wait(3000) })

bjowes commented 4 years ago

Hi @varunpradhan !

We are using ntlm-auth together with cucumber at work so it should work fine. Since the plugin can't detect the proxy I am guessing there is a configuration issue.

varunpradhan commented 4 years ago

Hi @bjowes

-Yes the plugin was working before I started to use cucumber. -Yes I had added the initialization code for the plugin in cypress/plugins/index.js as described in the readme

Below is my index.js file image

-Yes I am launching cypress with the plugins launcher (cypress-ntlm) as described in the readme

image

I get this error:

image

bjowes commented 4 years ago

Thanks for pasting the plugins/index.js file, i can see the issue. You have the correct initalization for ntlm-auth and for cucumber separately, but you need to combine them. The second module.exports = ... overwrites the first assignment to modules.exports, which removes the initalization for ntlm-auth. Try combining them like this:

module.exports = (on, config) => {
  on('file:preprocessor', cucumber());
  config = ntlmAuth.initNtlmAuth(config);
  return config;
}
varunpradhan commented 4 years ago

Hi @bjowes

Now I am facing this issue:

image

This is my update plugins/index.js image

bjowes commented 4 years ago

Oh, my bad. I just wrote that code example from my head, didn't test it. Replace file.preprocessorwith file:preprocessorlike you had it in the first place.

varunpradhan commented 4 years ago

Ya I got it. Yes now it's working. Thank you for the help.