nx icon indicating copy to clipboard operation
nx copied to clipboard

Creating a Cypress App for a React Storybook Library Fails

Open smasala opened this issue 2 years ago • 0 comments

Current Behavior

npx nx g @nx/storybook:cypress-project myReactLibWithStorybook fails

>  NX   Cannot read properties of undefined (reading 'options')


TypeError: Cannot read properties of undefined (reading 'options')
    at updateAngularJsonBuilder (/node_modules/@nx/storybook/src/generators/cypress-project/cypress-project.js:96:26)

Expected Behavior

A Cypress App for the UI library is generated

GitHub Repo

No response

Steps to Reproduce

  1. generate React UI library
  2. add storybook configuration to the react library
  3. run npx nx g @nx/storybook:cypress-project myReactLibWithStorybook

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 21.6.1
   OS     : linux-x64
   npm    : 10.2.4
   
   nx                 : 18.0.4
   @nx/js             : 18.0.4
   @nx/jest           : 18.0.4
   @nx/linter         : 18.0.4
   @nx/eslint         : 18.0.4
   @nx/workspace      : 18.0.4
   @nx/cypress        : 18.0.4
   @nx/devkit         : 18.0.4
   @nx/eslint-plugin  : 18.0.4
   @nx/react          : 18.0.4
   @nx/rollup         : 18.0.4
   @nx/storybook      : 18.0.4
   @nrwl/tao          : 18.0.4
   @nx/web            : 18.0.4
   @nx/webpack        : 18.0.4
   typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

No response

Operating System

  • [ ] macOS
  • [ ] Linux
  • [X] Windows
  • [ ] Other (Please specify)

Additional Information

https://github.com/nrwl/nx/blob/11e139c7ec42d77dee96af9bf3afd71bc7f717a2/packages/storybook/src/generators/cypress-project/cypress-project.ts#L147 should read:

The line should read ...e2eTarget?.options - there is no app, since we are generating it at this point, so e2eTarget is of course undefined. If you manually add ? then the generator run successfully.

smasala avatar Feb 10 '24 22:02 smasala