我正在尝试将茉莉花插件“jasmine”安装到一个角-cli项目中。这些指令看上去很标准,但我一直收到这样的错误:
src/app/app.Component.spec.ts(8,13)中的错误:错误TS2339:属性'Ajax‘不存在于’类型茉莉花‘上。
我一直在jasmine.Ajax.install()上看到一个错误
在我的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
});
};我还尝试使用jasmine.json中的helpers部分添加插件。这就是我的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
}最近有人成功地安装了茉莉花-ajax插件吗?
它会是茉莉花-ajax的版本吗?
发布于 2019-02-06 09:14:57
你在艰难的道路上。您需要安装TypeScript的类型定义:
npm i @types/jasmine-ajax并将它们包含在e2e/tsconfig.e2e.json中。
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"baseUrl": "./",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node",
"jasmine-ajax"
]
}
}https://stackoverflow.com/questions/48979689
复制相似问题