Web Dev Solutions

Catalin Mititiuc

From 7e5aedeb0a1ffa727005c98d80044429bf20ff45 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Tue, 28 May 2024 17:46:32 -0700 Subject: Move takeScreenshot() function into a test helper file --- test/integration/page.test.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'test/integration/page.test.js') diff --git a/test/integration/page.test.js b/test/integration/page.test.js index db0bf0d..8bb703e 100644 --- a/test/integration/page.test.js +++ b/test/integration/page.test.js @@ -1,9 +1,7 @@ const { Builder } = require('selenium-webdriver'), chrome = require('selenium-webdriver/chrome.js'), chromeOptions = new chrome.Options(), - { expect, it } = require('@jest/globals'), - { mkdir, writeFile } = require('node:fs/promises'), - path = require('path'); + { expect, it } = require('@jest/globals'); chromeOptions.addArguments('--headless', '--disable-gpu', '--no-sandbox'); chromeOptions.enableBidi(); @@ -22,11 +20,3 @@ it('loads the page', async () => { afterEach(async () => { await driver.quit(); }); - -async function takeScreenshot(driver) { - const dir = './test/screenshots'; - const fileName = path.relative(process.cwd(), __filename) + ' "' + expect.getState().currentTestName + `" ${new Date().toISOString()}.png`; - const image = await driver.takeScreenshot(); - await mkdir(dir, { recursive: true }); - await writeFile(`${dir}/${fileName.replaceAll('/', '-')}`, image, 'base64'); -} -- cgit v1.2.3