Sunny
Sunny

Reputation: 932

Write text to a file using testcafe

I was wondering if there's a way I can create a file and save the data in a file using 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);
});

I have written some dummy test to explain what I need. Is it possible to do something of this sort in testcafe? How could we do that?

Upvotes: 0

Views: 940

Answers (1)

Alex Skorkin
Alex Skorkin

Reputation: 4274

You can safely treat a testcafe test as a nodejs application where you can use any standard nodejs API and/or any other third-party modules to write/read files:

How do I write files in Node.js?

Import Third-Party Modules

Upvotes: 2

Related Questions