testcafe - 源文件不包含有效的 'fixture' 和 'test' 声明

testcafe - Source files do not contain valid 'fixture' and 'test' declarations

我第一次在 testcafe 中编写测试,并尝试执行 forEach 循环以迭代各种文件。 尝试 运行 测试时,出现此错误 Source files do not contain valid 'fixture' and 'test' declarations.

import testcafe from 'testcafe';
import { promises } from 'fs';
import { parse } from 'node-html-parser';

let specFiles: string[] = [];

fixture ('OpsLevel test cafe reporter').before( async t => {
    specFiles = await promises.readdir('./gauge-reports/html-report/specs')    
});

specFiles.forEach(specFile => {
    test(`Generate testcafe report from ${specFile}`, async t => {
        const gaugeReport = await promises.readFile(specFile, {encoding: 'utf8', flag: 'r'});
        const parsedReport = parse(gaugeReport);
        const structuredText = parsedReport.structuredText;
    
        await t.expect(structuredText.includes('Success Rate 100%')).eql(true);
    });
});

请指教

不支持数据驱动测试的运行时数据集初始化。请参阅 documentation 了解如何正确初始化数据集。