根据mocha-allure文档,如果你想在之前/beforeEach之外使用诱惑力,你应该直接导入报告器。或者,一旦添加了mocha- allure -reporter,就会使用以下API创建全局诱惑对象:
https://github.com/allure-framework/allure-mocha
https://github.com/allure-examples/mocha-allure-example/blob/master/test/simple.spec.js
然而,我遵循了文档中的示例,但在之前或afterEach中使用它时,我得到了Cannot find name 'allure'.。
测试文件:
require('mocha-allure-reporter');
// const allure = require('mocha-allure-reporter'); // also tried this
describe( 'test', () => {
// code
before(async () => {
// code here
});
afterEach('first step', function () {
const testStep = allure.createStep('initial', () => {
console.log('create step');
});
});配置:
mochaOpts: {
reporterOptions: {
reporterEnabled:
mocha-allure-reporter,
mochaAllureReporterReporterOptions: {
targetDir: './reports/allure-results',
},发布于 2019-03-12 21:00:17
试试下面的
const allure = require('mocha-allure-reporter');诱惑是一个全局标识符,由reporter注入到您的代码中。
将下面这一行添加到文件的顶部,以告知Typescript
declare const allure: any;希望能对你有所帮助
https://stackoverflow.com/questions/55105020
复制相似问题