簡體   English   中英

賽普拉斯 TypeScript 錯誤:找不到我的反應應用程序的模塊 @angular/core

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

我正在嘗試從 9.70 遷移到 Cypress 10.7.0。 然而幾乎修復了所有的錯誤,但是卻卡在了奇怪的消息中,上面寫着@angular/core或其相應的類型聲明找不到。

我的應用程序是一個反應應用程序,所以為什么賽普拉斯尋找 Angular 甚至在任何配置中都沒有提到。

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)

包括 ref 的 Cypress.config.ts 內容。

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",
    },
  },
});

讀取錯誤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.

看起來新的組件測試功能類型定義mount.d.ts正在為angular加載(而不是反應)。

您的配置看起來正確,即

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

所以,在這里創建一個問題: https://github.com/cypress-io/cypress/issues帶有可重現的示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM