Videos
» npm install @cypress/angular
First of all, seems you're using Cypresss 13.11.0 whilst latest is 13.12.0 at moment of writing this. This is relevant as 13.12.0 introduces Component Testing support for Angular v18
About setting it up, I've managed to setup Cypress component testing for Angular v18 by adding a dummy application to the workspace (ng g app dummy). This is because Cypress reads Angular application config to build the component and if there's no app, doesn't know which config to use. This is mentioned in the GitHub issue you pointed out. This seems the easiest & low maintenance cost for now.
Checkout more details in this repository:
https://github.com/davidlj95/angular-lib-cypress-component-testing
Didn't manage to reproduce your specific error though. But hope that those 2 things solve your issue :)
You can specify sourceRoot: 'projects/sample-lib/src/lib' in the devServer options to avoid having a dummy application.
From Angular - Options API and the source code for angularHandler, this are the minimum configuration I came up with to make a sample lib testable:
import { defineConfig } from "cypress";
export default defineConfig({
component: {
devServer: {
framework: "angular",
bundler: "webpack",
options: {
projectConfig: {
root: '',
sourceRoot: 'projects/sample-lib/src/lib',
buildOptions: {
outputPath: 'dist/sample-lib',
}
}
}
},
specPattern: "**/*.cy.ts",
},
});
