簡體   English   中英

Karma + Jasmine Testing安裝程序打破了離子包裝

[英]Karma + Jasmine Testing setup breaks the ionic packaging

我有一個離子應用程序,我介紹了使用業力+茉莉的測試。 我也使用打字稿預處理器進行測試。

我有以下依賴項,除了前兩個之外,都必須添加進行測試:

"devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.9"

    "@types/core-js": "^0.9.35",
    "@types/jasmine": "^2.5.41",
    "angular-cli": "^1.0.0-beta.26",
    "jasmine-core": "^2.5.2",
    "karma": "^1.4.0",
    "karma-jasmine": "^1.1.0",
    "karma-safari-launcher": "^1.0.0",
    "karma-typescript": "^2.1.6",
    "reflect-metadata": "^0.1.9",
  },

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

這是我的karma.conf.js文件:

module.exports = function(config) {
  config.set({

    basePath: '',
    frameworks: ["jasmine", "karma-typescript"],
    files: [
      {pattern: "src/**/*.spec.ts"},
      {pattern: "test/**/*.spec.ts"},
      {pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: true}
    ],

    preprocessors: {
      "**/*.ts": ["karma-typescript"], // *.tsx for React Jsx
    },

    reporters: ["progress", "karma-typescript"],

    port: 9876,

    colors: true,

    logLevel: config.LOG_INFO,

    autoWatch: false,

    browsers: ['Safari'],

    singleRun: true,

    concurrency: Infinity
  })
}

問題

現在,使用以下命令可以正常進行測試:

./node_modules/karma/bin/karma start karma.conf.js 

但是,當我現在運行ionic serve ,會收到如下真正的隱秘錯誤消息:

  • 后續變量聲明必須具有相同的類型。 變量“ [Symbol.unscopables]”的類型必須為“ {copyWithin:boolean; 條目:布爾值; 填充:布爾 查找:布爾值; findIndex:布爾值; 鍵:...”,但此處鍵入“ any”。

  • 打字稿錯誤所有'name'聲明必須具有相同的修飾符。

  • 打字稿錯誤重復的標識符“ PropertyKey”。

我的看法是devDependencies弄亂了應用程序其余部分的“加載路徑”。 所以我想知道如何讓我的應用程序再次運行。

問題是您將es2015定義與core-js定義一起使用。

Core-JS提供了polyfill,因此與TypeScript ES6 +標准定義沖突。

刪除@types/core-js和添加karmaTypescriptConfig: { compilerOptions: { lib: ['dom', 'es2015'] } }karma.conf.js使噶打字稿使用es2015的定義。

暫無
暫無

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

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