Cypress TypeScript error : Cannot find module @angular/core for my react app

Viewed 36

I'm trying to migrate to Cypress 10.7.0 from 9.70. However almost fixed all the bug but stuck here at strange message, which says @angular/core or its corresponding type declarations cannot be found.

My app is a react app so why Cypress look for Angular not even mentioned in any config.

TypeScript error: /Users/vinay/cypress_testing_service/node_modules/cypress/angular/dist/mount.d.ts(5,22): Error TS2307: Cannot find module '@angular/core' or its corresponding type declarations.
    at ProjectConfigIpc.<anonymous> (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigManager.js:216:60)
    at Object.onceWrapper (node:events:646:26)
    at ProjectConfigIpc.emit (node:events:526:28)
    at ProjectConfigIpc.emit (node:domain:475:12)
    at ProjectConfigIpc.emit (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigIpc.js:64:22)
    at ChildProcess.<anonymous> (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigIpc.js:40:18)
    at ChildProcess.emit (node:events:526:28)
    at ChildProcess.emit (node:domain:475:12)
    at emit (node:internal/child_process:938:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)

Including Cypress.config.ts contents for ref.

import { defineConfig } from "cypress";

export default defineConfig({
  viewportWidth: 1366,
  viewportHeight: 768,
  reporter: "mocha-junit-reporter",

  reporterOptions: {
    mochaFile: "cypress/reports/junit/test-results.[hash].xml",
    testsuitesTitle: false,
  },

  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    // https://docs.cypress.io/guides/references/migration-guide#Plugins-File-Removed
    setupNodeEvents(on, config) {
      return require("./cypress/plugins/index.ts")(on, config);
    },
    baseUrl: "http://localhost:8082/",
    specPattern: "cypress/e2e/**/*.feature",
  },

  component: {
    devServer: {
      framework: "create-react-app",
      bundler: "webpack",
    },
  },
});
1 Answers

Reading the error TypeScript error: /Users/vinay/cypress_testing_service/node_modules/cypress/angular/dist/mount.d.ts(5,22): Error TS2307: Cannot find module '@angular/core' or its corresponding type declarations.

It looks like the new component testing feature type definitions mount.d.ts are being loaded for angular (instead of react).

Your config looks correct i.e.

component: {
    devServer: {
      framework: "create-react-app",
      bundler: "webpack",
    },
  },

So, Create an issue here : https://github.com/cypress-io/cypress/issues with a reproducible example

Related