nx
nx copied to clipboard
Angular - Cypress component test failure
Current Behavior
Trying to run a component-test with following command npx nx component-test login, but it fails with Error: Missing executor options "main"
Expected Behavior
To run Cypress Component Testing
Steps to Reproduce
Used following guide: https://nx.dev/cypress/cypress-component-testing
npx nx g @nrwl/angular:cypress-component-configuration --project=login --generate-tests --build-target=login:build
npx nx component-test login
The generator created this file login.component.cy.ts
import { mount, MountConfig } from 'cypress/angular';
import { LoginComponent } from './login.component';
describe(LoginComponent.name, () => {
const config: MountConfig<LoginComponent> = {
declarations: [],
imports: [],
providers: [],
};
it('renders', () => {
mount(LoginComponent, {
...config,
componentProperties: {
invalidCredentials: false,
logo: '',
},
});
});
});
My Cypress config file: test-ui/libs/login/cypress.config.ts
import { nxComponentTestingPreset } from '@nrwl/angular/plugins/component-testing';
import { defineConfig } from 'cypress';
export default defineConfig({
// eslint-disable-next-line unicorn/prefer-module
component: nxComponentTestingPreset(__filename)
});
Failure Logs
~/workspace/test-ui main* ❯ npx nx component-test login
> nx run login:component-test
Your configFile is invalid: /Users/siyalrach/workspace/test-ui/libs/login/cypress.config.ts
It threw an error when required, check the stack trace below:
Error: Missing executor options "main"
at withSchemaDefaults (/Users/siyalrach/workspace/test-ui/packages/angular/plugins/component-testing.ts:231:11)
at normalizeBuildTargetOptions (/Users/siyalrach/workspace/test-ui/packages/angular/plugins/component-testing.ts:167:24)
at nxComponentTestingPreset (/Users/siyalrach/workspace/test-ui/packages/angular/plugins/component-testing.ts:95:34)
at Object.<anonymous> (/Users/siyalrach/workspace/test-ui/libs/login/cypress.config.ts:6:38)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module.m._compile (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .ts] (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadFile (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:89:14)
at EventEmitter.<anonymous> (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:116:38)
at EventEmitter.emit (node:events:527:28)
at EventEmitter.emit (node:domain:475:12)
at process.<anonymous> (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
at process.emit (node:events:527:28)
at process.emit (node:domain:475:12)
at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/siyalrach/Library/Caches/Cypress/10.8.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
at emit (node:internal/child_process:938:14)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
Environment
~/workspace/test-ui main* ❯ npx nx report
> NX Report complete - copy this into the issue template
Node : 16.15.1
OS : darwin arm64
npm : 8.19.2
nx : 14.7.6
@nrwl/angular : 14.7.6
@nrwl/cypress : 14.7.6
@nrwl/detox : Not Found
@nrwl/devkit : 14.7.6
@nrwl/eslint-plugin-nx : 14.7.6
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 14.7.6
@nrwl/js : 14.7.6
@nrwl/linter : 14.7.6
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.7.6
@nrwl/web : Not Found
@nrwl/workspace : 14.7.6
typescript : 4.8.3
---------------------------------------
Local workspace plugins:
---------------------------------------
Community plugins:
@storybook/angular: 6.5.12