blob: 7e3e0fd5e5048985d25c3614cc8c1be20b991824 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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');
};
global.url = (relativeOrAbsolute) => {
const location = new URL(relativeOrAbsolute, global.testServerUrl);
return location.href;
}
|