bjowes / cypress-ntlm-auth

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

Unable to use cypress-ntlm-auth with yarn 3.0 starting from version 3.2.4 #219

Closed TomasMacikas closed 1 year ago

TomasMacikas commented 1 year ago

Hi,

Last version working with yarn 3.0 is 3.2.3.

v3.2.4: @ cypress % yarn cypress-ntlm:open /Users/_/Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.4-1ad75a9cc4-f08397d18b.zip/node_modules/cypress-ntlm-auth/dist/launchers/cypress.ntlm.js:2 import { run, open, argumentsToCypressMode, argumentsToOptions } from "../index.js"; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.externalmodule.Module.load (/Users//Documents/Repositories/abc/.pnp.cjs:72879:14) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47

v3.2.6: @- cypress % yarn cypress-ntlm:open cypress-ntlm-auth requires Cypress to be installed. Error: cypress-ntlm-auth requires Cypress to be installed. at Startup.checkCypressIsInstalled (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:39:19) at Startup. (/Users//Documents/Repositories/abci/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:64:18) at Generator.next () at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/node_modules/cypress-ntlm-auth/dist/startup/startup.js:20:71 at new Promise () at _awaiter (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:16:12) at Startup.prepareOptions (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:63:16) at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/nodemodules/cypress-ntlm-auth/dist/index.js:62:30 at Generator.next () at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-3.2.6-6b8c76cd3a-7d199a4bea.zip/node_modules/cypress-ntlm-auth/dist/index.js:8:71

Same with latest v4.1.0 @- cypress % yarn cypress-ntlm:open cypress-ntlm-auth requires Cypress to be installed. Error: cypress-ntlm-auth requires Cypress to be installed. at Startup.checkCypressIsInstalled (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:39:19) at Startup. (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:64:18) at Generator.next () at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/node_modules/cypress-ntlm-auth/dist/startup/startup.js:20:71 at new Promise () at _awaiter (/Users//Documents/Repositories/abc.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:16:12) at Startup.prepareOptions (/Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/nodemodules/cypress-ntlm-auth/dist/startup/startup.js:63:16) at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/nodemodules/cypress-ntlm-auth/dist/index.js:62:30 at Generator.next () at /Users//Documents/Repositories/abc/.yarn/cache/cypress-ntlm-auth-npm-4.1.0-a83a7ae28e-ac9bc6b71e.zip/node_modules/cypress-ntlm-auth/dist/index.js:8:71

Also tried multiple cypress versions, still nothing help unless degraded to 3.2.3

yarn --version 3.0.2 npm --version 8.1.2

Thanks

bjowes commented 1 year ago

Interesting, I haven't tried the plugin with Yarn before. Cypress has its own "npm install caching" so it might not give any significant improvements on installation time. Could you also share the package.json file? Makes it easier to replicate.

TomasMacikas commented 1 year ago

{ "name": "@tests/cypress", "version": "0.0.0", "private": true, "dependencies": { "azure-devops-node-api": "^11.2.0", "cypress": "~8.4.1" }, "devDependencies": { "@commons/eslint-config-frontends": "workspace:commons/eslint-config-frontends", "@types/eslint": "^7", "@typescript-eslint/eslint-plugin": "^4.13.0", "@typescript-eslint/parser": "^4.13.0", "cross-env": "^7.0.3", "cypress-ntlm-auth": "3.2.3", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-config-react-app": "^6.0.0", "eslint-plugin-filename-rules": "^1.2.0", "eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-import": "^2.22.1", "eslint-plugin-jest": "^24.1.3", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.22.0", "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-sonarjs": "^0.10.0", "eslint-plugin-testing-library": "^3.10.1", "prettier": "^2.3.2", "typescript": "^4.0.3" }, "scripts": { "start": "echo 'not used in cypress package'", "build": "echo 'not used in cypress package'", "test": "echo 'not used in cypress package'", "test:integration": "yarn cypress-ntlm:run", "cypress-ntlm:open": "cross-env CYPRESS_REMOTE_DEBUGGING_PORT=9222 NO_PROXY='<-loopback>,ws://localhost:8090' cypress-ntlm open", "cypress-ntlm:run": "cypress-ntlm run" } }

Also, 3.2.3 works with newest cypress("cypress": "10.11.0"), tested it out today,

NO_PROXY='<-loopback>,ws://localhost:8090' can be ignored, used it for testing recently, but seems like it's ignored in 3.2.3 version.

TomasMacikas commented 1 year ago

Also, adding .yarnrc.yml as this might be useful nodeLinker: pnp

packageExtensions: '@apollo/client@': dependencies: graphql: 15.0.0 react: 17.0.0 '@date-io/date-fns@': dependencies: date-fns: '' '@emotion/styled@': dependencies: '@emotion/react': '' '@mui/core@': dependencies: '@mui/system': '' '@mui/styled-engine@': dependencies: '@emotion/react': '' '@emotion/styled': '' '@node-ts/logger-core@': dependencies: tslib: ^2.0.0 '@node-ts/logger-winston@': dependencies: tslib: ^2.0.0 '@storybook/preset-create-react-app@': peerDependencies: webpack-hot-middleware: '' cypress-ntlm-auth@: dependencies: debug: ^4.1.0 cypress@: dependencies: cypress/webpack-batteries-included-preprocessor: '' typescript: '' react-csv@: dependencies: prop-types: '' react-dev-utils@: peerDependencies: typescript: ^2.7.0 webpack: ^4.0.0 react-scripts@: dependencies: sass-loader: '' peerDependencies: sass: '' react-table@*: dependencies: prop-types: ^15.7.0

plugins:

yarnPath: .yarn/releases/yarn-3.0.2.cjs

bjowes commented 1 year ago

I did a local setup, with yarn 3.2.4. Tried to mimic your setup by adding the same plugins and then applying packageExtensions. I'm on node 18.9.0, platform OS X. With this setup I could not reproduce your issue. Cypress launches! With Cypress 8.4.1 it opened the UI but was stuck on a spinner - this may be related to that the repo i incomplete, no cypress folder with specs or config. I upgraded to the latest version and then it opens correctly.

Before setting packageExtensions, yarn correctly complained about the missing dependency of "debug" from my package. I guess it always works anyway since cypress requires debug. But I will fix that.

TomasMacikas commented 1 year ago

Thanks @bjowes for checking this!

I was running node v16.13.1, so I though this might be an issue so updated to v18.12.0 then to 18.9.0, but still same issue. Also, I am running on MacOS Monterey version 12.6

I am running on monorepo setup the path of cypress is under /tests/cypress

So, I tried to build the source, move it and run it inside my cypress folder and it actually run(after adding debug dependency)

Now I am very confused what's the issue here

bjowes commented 1 year ago

Yeah, due to my limited experience with yarn I'm afraid I'm not able to help much here. I'll close this, if you identify that the issue is indeed from my plugin then please reopen it.