The --env flag is not recognized by the nx e2e command.
I would like to be able to use an --env flag to specify custom variables for Cypress on the command line, as we can do with the cypress run command.
apps/my-app-e2e/cypress.json:{
"env": {
"myEnvKey": "myEnvDefaultValue"
},
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": true,
"videosFolder": "../../dist/cypress/apps/my-app-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/my-app-e2e/screenshots",
"chromeWebSecurity": false
}
$> yarn run nx e2e --project=my-app-e2e --env.myEnvKey myEnvValue
yarn run v1.21.1
$ nx e2e --project=my-app-e2e --env.myEnvKey foo
> ng run my-app-e2e:e2e --env=[object Object]
Unknown option: '--env'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Unknown option: '--env'
$> yarn run nx report
yarn run v1.21.1
$ nx report
> NX Report complete - copy this into the issue template
nx : Not Found
@nrwl/angular : 10.0.13
@nrwl/cli : 10.0.10
@nrwl/cypress : 10.0.10
@nrwl/eslint-plugin-nx : 10.0.10
@nrwl/express : Not Found
@nrwl/jest : 10.0.10
@nrwl/linter : Not Found
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 10.0.10
@nrwl/web : Not Found
@nrwl/workspace : 10.0.10
typescript : 3.9.7
Done in 2.35s.
Experienced the same issue. I will open a PR later today!
@hadrien-toma @mehrad-rafigh I think this is related to the way we parse the extra arguments. I have a PR open already to fix the arrays, but I will change it to a more generic approach so we can avoid such issues in the future. Stay tuned 馃槃
@hadrien-toma my PR solves the issue of --env=[object Object] but even then I get this error for ng:
yarn run nx e2e --project=my-app-e2e --env.myEnvKey myEnvValue
> ng run my-app-e2e:e2e --env.myEnvKey myEnvValue
Unknown option: '--env.myEnvKey'
Unknown option: 'myEnvValue'
error Command failed with exit code 1.
Have to investigate it more!
@bekos Ah sorry, I think the correct command should in fact be: --env myEnvKey=myEnvValue like in the Cypress documentation. Thank you very much for the help!
@hadrien-toma my PR solves the issue of
--env=[object Object]but even then I get this error forng:yarn run nx e2e --project=my-app-e2e --env.myEnvKey myEnvValue > ng run my-app-e2e:e2e --env.myEnvKey myEnvValue Unknown option: '--env.myEnvKey' Unknown option: 'myEnvValue' error Command failed with exit code 1.Have to investigate it more!
Hi. How does it fix your problem?? #2 used to work for me, 20 odd days back. What changed now ?
PS C:\Workspaces\git\kiosk-react> nx custom myProject --env build=PR-122
nx run myProject :custom --env=build=PR-122
Schema validation failed with the following errors:
Data path ".env" should be object.
Or.
PS C:\Workspaces\git\kiosk-react> nx custom myProject --env.build PR-122
nx run myProject :custom --env=[object Object]
Schema validation failed with the following errors:
Data path ".env" should be object.
@panraj01 As you see that PR was merged 10 days ago, so it is not released yet. What version of Nx are you using?
@bekos - I am on 9.3.0. Any idea on what release version it is targeted and time of release ? In the interim, is there a way to get it to work, i know for sure, this has worked for me in the past: How do i get this to work while your release is in flight?
PS C:\Workspaces\git\kiosk-react> nx custom myApp-e2e --env.build PR-122
nx run myApp-e2e:custom --env=[object Object]
Schema validation failed with the following errors:
Data path ".env" should be object.
This is driving me nuts. It worked yesterday, its not working today again.
nx custom app-name-e2e --env.build 1.1.79 --watch
Schema validation failed with the following errors:
Data path ".env" should be object.
Most helpful comment
@hadrien-toma @mehrad-rafigh I think this is related to the way we parse the extra arguments. I have a PR open already to fix the arrays, but I will change it to a more generic approach so we can avoid such issues in the future. Stay tuned 馃槃