量角器/Typescript - 在 "mocha-allure-reporter" 中找不到名称 'allure'
Protractor / Typescript - Cannot find name 'allure' in "mocha-allure-reporter"
基本上我有 个问题,但在 mocha-allure-reporter 和 typescript 中。我将量角器与 mocha 一起使用,并决定添加魅力报告
'allure' 无法全局访问使用 mocha-allure 的对象。
这是protractor.conf.js
mochaOpts: {
bail: false,
ui: 'bdd',
reporter: 'spec',
compiler: 'ts:ts-node/register'
}
这是 package.json
中的 devDependencies
"devDependencies": {
"chai": "^4.0.2",
"mocha": "^6.2.2",
"allure-commandline": "^2.0.0",
"mocha-allure-reporter": "^1.4.0",
"mocha-tags": "^1.0.1"
}
和依赖关系
"dependencies": {
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.6",
"chai": "^4.2.0",
"mocha-allure-reporter": "^1.4.0",
"chai-as-promised": "^7.1.1",
"graphviz": "0.0.9",
"lodash": "^4.17.15",
"minimist": "^1.2.0",
"mocha": "^6.2.2",
"npm-failsafe": "^0.4.1",
"protractor": "^5.4.2",
"rimraf": "^2.7.1",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"typescript": "^3.8.2",
"typescript-logging": "^0.6.4",
"webdriver-manager": "^12.1.7",
"yargs": "^13.3.0"
}
这里是无法全局访问'allure'的ts文件:
当我尝试添加 declare const allure: any;
时,
注意:请使用 typescript,我对 javascript
没有太多了解
require("mocha-allure-reporter");
declare const allure: any;
describe("Initial Test", function() {
it("Add Feature" async function() {
allure.feature("Sample Feature");
})
})
基本上我有
'allure' 无法全局访问使用 mocha-allure 的对象。
这是protractor.conf.js
mochaOpts: {
bail: false,
ui: 'bdd',
reporter: 'spec',
compiler: 'ts:ts-node/register'
}
这是 package.json
中的 devDependencies"devDependencies": {
"chai": "^4.0.2",
"mocha": "^6.2.2",
"allure-commandline": "^2.0.0",
"mocha-allure-reporter": "^1.4.0",
"mocha-tags": "^1.0.1"
}
和依赖关系
"dependencies": {
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.6",
"chai": "^4.2.0",
"mocha-allure-reporter": "^1.4.0",
"chai-as-promised": "^7.1.1",
"graphviz": "0.0.9",
"lodash": "^4.17.15",
"minimist": "^1.2.0",
"mocha": "^6.2.2",
"npm-failsafe": "^0.4.1",
"protractor": "^5.4.2",
"rimraf": "^2.7.1",
"ts-node": "^8.5.4",
"tslint": "^5.20.1",
"typescript": "^3.8.2",
"typescript-logging": "^0.6.4",
"webdriver-manager": "^12.1.7",
"yargs": "^13.3.0"
}
这里是无法全局访问'allure'的ts文件:
当我尝试添加 declare const allure: any;
时,
require("mocha-allure-reporter");
declare const allure: any;
describe("Initial Test", function() {
it("Add Feature" async function() {
allure.feature("Sample Feature");
})
})