使用 testcafe 将文本写入文件

Write text to a file using testcafe

我想知道是否有一种方法可以使用 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 and/or 任何其他 third-party 模块到 write/read 文件:

How do I write files in Node.js?

Import Third-Party Modules