Move takeScreenshot() function into a test helper file
This commit is contained in:
11
test/integration/helpers.cjs
Normal file
11
test/integration/helpers.cjs
Normal file
@@ -0,0 +1,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');
|
||||
};
|
||||
Reference in New Issue
Block a user