Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular component test fails with error 'Missing executor options "main"'. #20269

Closed
2 of 4 tasks
cmurczek-it opened this issue Nov 16, 2023 · 3 comments
Closed
2 of 4 tasks

Comments

@cmurczek-it
Copy link

Current Behavior

Running a component test for an angular project using latest (17.1.2) nx fails with error 'Missing executor options "main"'.

Expected Behavior

Component test can be started

GitHub Repo

No response

Steps to Reproduce

  1. generate angular application using nx @nx/angular:application
  2. generate angular lib using nx g @nx/angular:library
  3. generate component test setup in lib using nx @nx/angular:zypress-componet-configuration referencing the build configuration of the app
  4. start component test using nx component-test for lib using the --watch flag

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.9.0
   OS     : linux-x64
   npm    : 10.2.3
   
   nx                 : 17.1.2
   @nx/js             : 17.1.2
   @nx/jest           : 17.1.2
   @nx/linter         : 17.1.2
   @nx/eslint         : 17.1.2
   @nx/workspace      : 17.1.2
   @nx/angular        : 17.1.2
   @nx/cypress        : 17.1.2
   @nx/devkit         : 17.1.2
   @nx/eslint-plugin  : 17.1.2
   @nrwl/tao          : 17.1.2
   @nx/web            : 17.1.2
   @nx/webpack        : 17.1.2
   typescript         : 5.2.2
   ---------------------------------------
   Community plugins:
   @jscutlery/semver    : 4.0.0
   @ngrx/effects        : 17.0.0-rc.0
   @ngrx/entity         : 17.0.0-rc.0
   @ngrx/store          : 17.0.0-rc.0
   @ngrx/store-devtools : 17.0.0-rc.0

Failure Logs

Cypress configuration error
Try again
Error
Your configFile is invalid: /home/---/---/---/---/libs/shared/ng-charts/cypress.config.ts

It threw an error when required, check the stack trace below:

../../../node_modules/@nx/angular/plugins/component-testing.js:206:15
  204 |     // }
  205 |     if (!options.main) {
> 206 |         throw new Error('Missing executor options "main"');
      |               ^
  207 |     }
  208 |     if (!options.index) {
  209 |         throw new Error('Missing executor options "index"');
  210 |     }
Stack trace
Error: Missing executor options "main"
    at withSchemaDefaults (/home/---/---/---/---/node_modules/@nx/angular/plugins/component-testing.js:206:15)
    at normalizeBuildTargetOptions (/home/---/---/---/---/node_modules/@nx/angular/plugins/component-testing.js:108:26)
    at nxComponentTestingPreset (/home/---/---/---/---/node_modules/@nx/angular/plugins/component-testing.js:58:36)
    at Object. (/home/---/---/---/---/libs/shared/ng-charts/cypress.config.ts:5:38)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module.m._compile (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/ts-node/dist/index.js:857:29)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Object.require.extensions. [as .ts] (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/ts-node/dist/index.js:859:16)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Function.Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at loadFile (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)
    at EventEmitter. (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)
    at EventEmitter.emit (node:events:514:28)
    at EventEmitter.emit (node:domain:488:12)
    at process. (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:514:28)
    at process.emit (node:domain:488:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/home/---/.cache/Cypress/13.5.1/Cypress/resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:951:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

As can be seen in the Failure Log above, the withSchemaDefaults method in component-testing.js ignores the options.browser property and only checks for the main property of the provided build options.

A locally working quick-fix is to patch the value of options.browser prop to options.main before checking the existence of options.main:

...
function withSchemaDefaults(options) {
    if (options.browser) {
      options.main = options.browser;
    }
    if (!options.main) {
        throw new Error('Missing executor options "main"');
    }
...
@leosvelperez
Copy link
Member

Fixed by #20214.

@FabienDehopre
Copy link

Any estimate for the 17.2 release date?

Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants