I have an Angular library project where I have a lot of components that I use in a handful of Angular applications.
Now I want to start testing these components using Cypress component testing. Setting up Cypress with an Angular application is super easy, but trying to do it for a library project is definitely not.
I don’t really have any code to show as all my efforts are leading to the same error which is:
Error: Could not resolve "@angular-devkit/build-angular/src/webpack/configs/common.js". Do you have "@angular-devkit/build-angular" and "@angular-devkit/core" installed?
at C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdisthelpersangularHandler.js:106:19
at Array.map ()
at getAngularCliModules (C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdisthelpersangularHandler.js:100:151)
at async getAngularCliWebpackConfig (C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdisthelpersangularHandler.js:159:101)
at async angularHandler (C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdisthelpersangularHandler.js:205:27)
at async getPreset (C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdistdevServer.js:94:20)
at async Function.devServer.create (C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdistdevServer.js:111:61)
at async C:UsersMeAppDataLocalCypressCache13.11.0Cypressresourcesappnode_modules@packagesservernode_modules@cypresswebpack-dev-serverdistdevServer.js:26:24
I’ve tried setting Cypress up both using the @cypress/schematic
and by using npm install cypress --save-dev
, to no avail.
I stumbled upon this github issue while trying to find information on how to accomplish what I want. Which talks about a library project needing an application set up in order to make it work but I have no clue how to do that and there are no examples provided either.
If anyone have succeeded in setting this up I would love some guidance!
I currently use Angular version 18 and Cypress version 13.