bjowes / cypress-ntlm-auth

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

cy.ntlmSso is not a function #213

Closed tomer953 closed 2 years ago

tomer953 commented 2 years ago

Hi,

GREAT plugin, we added cypress to our main angular project, and to our CI process. things seems to work well!

one small thing I can't figure out - I added cypress using the angular schematics tool: https://www.npmjs.com/package/@cypress/schematic

now I have support folder with: cypress/support/commands.ts cypress/support/e2e.ts

so If I put the import command: import "cypress-ntlm-auth/dist/commands"; in e2e.ts or even in commands.ts (and then import ./commands )

I have valid types in the IDE (vscode) - but on the cypress runner \ UI - I cannot run the tests duo to the error:

TypeError: cy.ntlmSso() is not a function

However if I put the import command in the test file itself - everything is working.

How to global import the command properly?

angular 14.2.0, cypress 10.7.0

bjowes commented 2 years ago

Thanks for reporting. I can reproduce this. Investigating.

bjowes commented 2 years ago

For some reason, the schematic disables the support file. I have started a discussion on the cypress Github about this. To resolve, you can simply edit the file cypress.config.ts and remove the line supportFile: false.

However, when this is fixed you can start the test but it will still fail on cy.ntlmSso(). This plugin requires that cypress is bootstrapped by the plugins own launcher, cypress-ntlm. The cypress schematic is hardwired to launch cypress directly, so the NTLM support won't be there. You can run cypress-ntlm with npx cypress-ntlm open instead of using ng e2e, but I suspect that you might lose some bootstrapping required for Angular component testing. For a more streamlined approach, I guess a schematic for cypress-ntlm would be required. There are currently no plans to implement such a schematic (I am concerned that this will require maintenance for each Angular release), but if anyone is interested to pitch in I am willing to discuss.

tomer953 commented 2 years ago

I use npx cypress-ntlm open (For local development) Or cypress-ntlm run in the Docker CI, like you specified in the documentation.

Not using components testing nor ng e2e But still have the problem, what am I missing?

bjowes commented 2 years ago

Did you modify cypress.config.ts? If it still doesn’t work, please provide a minimal reproduction repo

fre 16 sep. 2022 kl. 08:00 skrev Tomer953 @.***>:

I use npx cypress-ntlm open (For local development) Or cypress-ntlm run in the Docker CI, like you specified in the documentation.

Not using components testing nor ng e2e But still have the problem, what am I missing?

— Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/213#issuecomment-1248950705, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3CWJDQKOAOTZ5JHRNLV6QEI3ANCNFSM6AAAAAAQNLJ7TI . You are receiving this because you commented.Message ID: @.***>

-- /Björn W

Skickat från min iPhone

tomer953 commented 2 years ago

Oops, not sure how I missed that part. anyway, it works now. 👍

Why they added support files but then disabled them in the config? it should be enable anyway regardless of this plugin if we want to use them, right?

bjowes commented 2 years ago

I totally agree! Vote on the discussion to help others in the same situation https://github.com/cypress-io/cypress/discussions/23847

fre 16 sep. 2022 kl. 09:03 skrev Tomer953 @.***>:

Oops, not sure how I missed that part. anyway, it works now. 👍

Why they added support files but then disabled them in the config? it should be enable anyway regardless of this plugin if we want to use them, right?

— Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/213#issuecomment-1248995101, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3A7MO76LDLXSQPLV5LV6QLTTANCNFSM6AAAAAAQNLJ7TI . You are receiving this because you commented.Message ID: @.***>

-- /Björn W

Skickat från min iPhone

tomer953 commented 2 years ago

much appreciated. closed