Skip to content

Angular schematic does not generate working component test #33021

@mikem-of

Description

@mikem-of

Current behavior

  1. Create a fresh Angular app with ng new fresh-app

  2. Set up cypress using the schematic:

PS C:\test\angular-test-app2> ng e2e 
Cannot find "e2e" target for the specified project.
You can add a package that implements these capabilities.                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                           
For example:                                                                                                                                                                                                                                                                                                                                                               
  Playwright: ng add playwright-ng-schematics                                                                                                                                                                                                                                                                                                                              
  Cypress: ng add @cypress/schematic                                                                                                                                                                                                                                                                                                                                       
  Nightwatch: ng add @nightwatch/schematics                                                                                                                                                                                                                                                                                                                                
  WebdriverIO: ng add @wdio/schematics                                                                                                                                                                                                                                                                                                                                     
  Puppeteer: ng add @puppeteer/ng-schematics                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                           
Would you like to add a package with "e2e" capabilities now? Cypress
√ Determining Package Manager
  › Using package manager: npm
√ Searching for compatible package version
  › Found compatible package version: 4.1.4.
√ Loading package information from registry
√ Confirming installation
√ Installing package
✔ Would you like the default `ng e2e` command to use Cypress? [ Protractor to Cypress Migration Guide: https://on.cypress.io/protractor-to-cypress?cli=true ] Yes
✔ Would you like to add Cypress component testing?  This will add all files needed for Cypress component testing. Yes
  1. Try to run component tests. this throws:

our configFile threw an error from: cypress.config.js

We stopped running your tests because your config file crashed.

Error: Could not resolve "@angular-devkit/build-angular/src/utils/webpack-browser-config.js". Do you have "@angular-devkit/build-angular" and "@angular-devkit/core" installed?
    at C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\helpers\angularHandler.js:103:19
    at Array.map ()
    at getAngularCliModules (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\helpers\angularHandler.js:90:151)
    at getAngularCliWebpackConfig (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\helpers\angularHandler.js:155:107)
    at angularHandler (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\helpers\angularHandler.js:208:33)
    at getPreset (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\devServer.js:62:62)
    at devServer.create (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\devServer.js:79:67)
    at C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\devServer.js:22:40
    at new Promise ()
    at devServer (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\node_modules\@cypress\webpack-dev-server\dist\devServer.js:21:12)
    at Object.handler (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:174:24)
    at invoke (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:181:18)
    at C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:77:14
    at tryCatcher (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\bluebird\js\release\util.js:16:23)
    at Promise.attempt.Promise.try (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\bluebird\js\release\method.js:39:29)
    at Object.wrapChildPromise (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:76:23)
    at Object.wrap (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\dev-server.js:18:8)
    at RunPlugins.execute (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:151:26)
    at EventEmitter. (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_plugins.js:56:12)
    at EventEmitter.emit (node:events:519:28)
    at process. (C:\Users\mikem\AppData\Local\Cypress\Cache\15.7.0\Cypress\resources\app\node_modules\@packages\server\lib\plugins\util.js:51:22)
    at process.emit (node:events:519:28)
    at emit (node:internal/child_process:949:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:91:21)

As mentioned here; this can be fixed by installing @angular-devkit/build-angular as a devDependency

Debug logs


Cypress Version

15.7.0

Node version

22.21.1

Package Manager

npm

Package Manager Version

11.6.4

Operating system

Windows

Operating System Version

Windows 11 Enterprise

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: installationIssue during installation or downloading Cypress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions