nx icon indicating copy to clipboard operation
nx copied to clipboard

Cypress end-to-end test fails when ciBuildId is parseable as number

Open Ghostbird opened this issue 4 years ago • 7 comments

When I try to run cypress through nx the command line string value for ciBuildId is parsed as a number if the string can be interpreted as a valid base 10 number. Then it complains that it should be a string and aborts.

Parsing shouldn't happen if unnecessary, let alone if the result would be program failure.

For now I'll try to workaround this by calling cypress directly outside nx

Current Behavior

Property 'ciBuildId' does not match the schema. '12345' should be a 'string'.

Expected Behavior

nx e2e runs successfully. 12345 is passed as a string on the command line, so there's no reason to parse it to a number and then complain that it isn't a string.

Steps to Reproduce

Use nx e2e to run a cypress end-to-end test and pass in the --ciBuildId manually (required for Azure DevOps).

Note: I've tried to pass the ci-build-id flag directly to cypress, however when I do that, the nx command will add a duplicated value as --ciBuildId to the command line, and still complain about it.

Failure Logs

npx nx e2e myapp-e2e --ciBuildId='12345'

> nx run myapp-e2e:e2e --ciBuildId=12345
Property 'ciBuildId' does not match the schema. '12345' should be a 'string'.

Environment

Node : 16.0.0 OS : win32 x64 npm : 7.10.0

nx : Not Found @nrwl/angular : 11.6.1 @nrwl/cli : 11.6.1 @nrwl/cypress : 11.6.1 @nrwl/devkit : 11.6.1 @nrwl/eslint-plugin-nx : 11.6.1 @nrwl/express : Not Found @nrwl/jest : 11.6.1 @nrwl/linter : 11.6.1 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 11.6.1 @nrwl/web : Not Found @nrwl/workspace : 11.6.1 @nrwl/storybook : 11.6.1 @nrwl/gatsby : Not Found typescript : 4.1.5

Ghostbird avatar Jun 08 '21 14:06 Ghostbird

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Dec 09 '21 00:12 github-actions[bot]

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! pray

I haven't retried this recently, as the workaround still holds. However I don't think this should be closed.

Ghostbird avatar Dec 13 '21 20:12 Ghostbird

Hello @Ghostbird Can you give me the workaround ? I have the same issue. Thanks for the helps.

kpl1 avatar Dec 14 '21 10:12 kpl1

Hello @Ghostbird Can you give me the workaround ? I have the same issue. Thanks for the helps.

I mentioned it briefly (third paragraph in the initial post). Try calling it directly npx cypress run. That might work for you. In my case, I ultimately just gave up on passing the build number. You could also try adding this to your job config:

variables:
  CI_BUILD_ID: $[variables['Build.BuildId']]

I'm not sure whether that will work.

Ghostbird avatar Dec 14 '21 11:12 Ghostbird

I found that changing the name in the azure pipelines yaml file fixed this for us. Setting it like this allowed it to run correctly. name: $(TeamProject)_$(Build.DefinitionName)_$(Build.BuildId)

From what I can tell azure sets the build id to the name you specified. This is currently running for us nightly so can confirm it works

aiecee avatar Dec 20 '21 15:12 aiecee

Big thanks to you @aiecee !

Works for me too.

kpl1 avatar Feb 07 '22 17:02 kpl1

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Aug 07 '22 00:08 github-actions[bot]

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Mar 22 '23 01:03 github-actions[bot]