简体   繁体   English

类型'typeof jasmine'上不存在属性'Ajax'

[英]Property 'Ajax' does not exist on type 'typeof jasmine'

I'm trying to install the jasmine plugin "jasmine-ajax" in an angular-cli project. 我正在尝试在angular-cli项目中安装jasmine插件“jasmine-ajax”。 The instructions seem pretty standard, but I keeping getting this error: 说明似乎很标准,但我一直收到这个错误:

"ERROR in src/app/app.component.spec.ts(8,13): error TS2339: Property 'Ajax' does not exist on type 'typeof jasmine'." “src / app / app.component.spec.ts(8,13)中的错误:错误TS2339:'typeof jasmine'类型中不存在属性'Ajax'。”

I keep seeing an error on jasmine.Ajax.install() 我一直看到jasmine.Ajax.install()上的错误

In my karma.conf.js file, I have this: 在我的karma.conf.js文件中,我有这个:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine-ajax', 'jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-jasmine-ajax')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

I also tried to add the plugin using the helpers section in the jasmine.json. 我还尝试使用jasmine.json中的helpers部分添加插件。 This is what my jasmine.json file looks like: 这是我的jasmine.json文件的样子:

{
    "spec_dir": "spec",
    "spec_files": [
        "**/*[sS]pec.js"
    ],
    "helpers": [
        "helpers/**/*.js",
        "../../../node_modules/jasmine-ajax/lib/mock-ajax.js"
    ],
    "stopSpecOnExpectationFailure": false,
    "random": true
}

Has anyone installed the jasmine-ajax plugin successfully lately? 有没有人最近成功安装了jasmine-ajax插件?

Could it be the version of jasmine-ajax? 它可能是jasmine-ajax的版本吗?

You are on the rigth path. 你正处于艰难的道路上。 You need to install the type definitions for TypeScript: 您需要安装TypeScript的类型定义:

npm i @types/jasmine-ajax

and include them in your e2e/tsconfig.e2e.json : 并将它们包含在您的e2e / tsconfig.e2e.json中

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/e2e",
    "baseUrl": "./",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "jasminewd2",
      "node",
      "jasmine-ajax"
    ]
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 排毒配置 - 类型“typeof jasmine”上不存在属性“getEnv” - Detox configuration - Property 'getEnv' does not exist on type 'typeof jasmine' Ionic + Jasmine + Tslint - 属性'和'在类型上不存在 - Ionic + Jasmine + Tslint - Property 'and' does not exist on type jasmine.spy类型的值不存在andCallThrough()属性 - The property andCallThrough() does not exist on the value of type jasmine.spy WebStorm 将自定义 Jasmine 匹配器强调为“TypeScript error TS2339: Property 'matcher' does not exist on type 'ArrayLikeMatchers'。” - WebStorm underlines custom Jasmine matchers as errors with `TypeScript error TS2339: Property 'matcher' does not exist on type 'ArrayLikeMatchers '.` Angular jasmine:属性没有访问类型获取 - Angular jasmine: Property does not have access type get 类型“ DebugElement”上不存在属性“ click” - Property 'click' does not exist on type 'DebugElement' 类型“ TestBed”上不存在属性“ createAsync” - Property 'createAsync' does not exist on type 'TestBed' “IAngularStatic”类型上不存在属性“模拟” - Property 'mock' does not exist on type 'IAngularStatic' Jasmine 试图读取不存在的属性 - Jasmine trying to read property that doesn't exist Angular2 Jasmine SpyOn方法不存在 - Angular2 Jasmine SpyOn Method Does Not Exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM