bjowes / cypress-ntlm-auth

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

3.0.0 - cypress-ntlm-auth plugin must be loaded before using this method #137

Closed oleghansen closed 3 years ago

oleghansen commented 3 years ago

Hi, I set up a project recently where I'll be using cucumber and cypress-ntlm-auth. I'm getting this error when running a simple test: 1

As I understood from the update to 3.0.0 I'm not supposed to need anything special in support/index.js. I imagined I could solve the problem by using the command npx cypress-ntlm open. I do use .feature files and when I try to use the command npx cypress-ntlm open or npx ntlm-proxy the .feature files are not picked up, only the spec-files in integration/example. Trying the (outdated, as I've understood) approach, adding ntmlAuth in plugins/index.js doesn't seem to be valid anymore.

I'd like to be able to run with authentication either by 1) simply by running yarn cypress open or 2) with npx cypress-ntlm open, but then I'd need the .feature files to be picked up. These are my files:

support/index.js:

import './commands';
import 'cypress-ntlm-auth/dist/commands';

plugins/index.js (after removing ntlm-related-stuff):

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = (on) => {
  on('file:preprocessor', cucumber());
}

cypress.json

{
    "testFiles": "**/*.{feature,features}"
}
bjowes commented 3 years ago

Hi @oleghansen

For the plugin to work, you must use npx cypress-ntlm open (or npx cypress-ntlm run). If you just start cypress, the environment is not setup and you will get the error posted.

In my own test setup, cucumber works fine with the plugin. Your setup looks correct, the only difference is that I have not set the "testFiles" property in cypress.json. I do see both .spec.js files and .feature files in cypress, and I guess the intent of that property is to only show feature files. Try running with cypress-ntlm with the "testFiles" property removed. If the .feature files works in that scenario, please troubleshoot the "testFiles" setting.

I noted that the setting recommended by the cucumber preprocessor docs is "testFiles": "**/*.feature"

bjowes commented 3 years ago

Please run the npx cypress-ntlm open command from the project root folder (the e2e folder in your case).

On Wed, Oct 14, 2020 at 7:37 AM oleghansen notifications@github.com wrote:

Thanks for your reply. Unfortunately this didn't work as expected. Another strange thing that happened is that another set of cypress-files/folders are created when I run npx cypress-ntlm-open : [image: image] https://user-images.githubusercontent.com/3908524/95948024-0f9a1380-0df0-11eb-9d41-505daf28772b.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bjowes/cypress-ntlm-auth/issues/137#issuecomment-708168612, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHR3FTGM47KNSGYWGH3YLSKU2JNANCNFSM4SO6ROYQ .

oleghansen commented 3 years ago

Thank you for your quick replies. Adding "testFiles": "**/*.feature" did the trick. I had that originally but must have tried to switch it out to "testFiles": "**/*.{feature,features}" when it didn't pick up feature files as expected, but that was probably just me running from cypress folder and not the root folder. Thanks!