问题描述
我想知道是否可以使用testcafe创建文件并将数据保存到文件中。
test('copy data',async t => {
await someAction(t);
const data = RequestLogger(data,{ logRequestBody: true,stringifyRequestBody: true });
await t.clearContent('data/output.js');
await t.writeText('data/output.js',data);
});
我写了一些虚拟测试来解释我的需求。是否可以在testcafe中进行此类操作?我们该怎么做?
解决方法
您可以将testcafe测试安全地视为nodejs应用程序,可以在其中使用任何标准的nodejs API和/或任何其他第三方模块来写入/读取文件: