blob: 5643bfd1c801896bf28c25586cb56d3b9fa3e7ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
const { mkdir, writeFile } = require('node:fs/promises')
, path = require('path')
;
global.takeScreenshot = async (driver) => {
const dir = './test/screenshots';
const fileName = path.relative(process.cwd(), __filename) + ' "' + global.expect.getState().currentTestName + `" ${new Date().toISOString()}.png`;
const image = await driver.takeScreenshot();
await mkdir(dir, { recursive: true });
await writeFile(`${dir}/${fileName.replaceAll('/', '-')}`, image, 'base64');
};
|