基本上我有this问题,但在mocha-allure-reporter和typescript中。我将量角器与摩卡咖啡配合使用,决定添加吸引力报告
无法使用mocha-allure的'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
"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" }
以下是无法全局访问“诱惑”的ts文件:
并且当我尝试添加declare const allure: any;
时,注意:请用打字稿,我在javascript中没有太多背景
基本上我有这个问题,但是在mocha-allure-reporter和打字稿中。我将量角器与Mocha结合使用,并决定使用无法访问的Mocha-allure添加魅力报告“魅力”对象...
您不能只声明一个const变量。声明时需要赋值。
const allure = require("mocha-allure-reporter");
declare const allure: any;
describe("Initial Test", function() {
it("Add Feature" async function() {
allure.feature("Sample Feature");
})
})