index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-28 17:46:32 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-28 18:44:28 -0700 |
commit | 7e5aedeb0a1ffa727005c98d80044429bf20ff45 (patch) | |
tree | e50e71d53cf77f6cb850d3fab01d24e91c9551ae /test/integration/helpers.cjs | |
parent | 2df718998a89cb622bb9a76655abdeafc33d9aa5 (diff) |
Move takeScreenshot() function into a test helper file
Diffstat (limited to 'test/integration/helpers.cjs')
-rw-r--r-- | test/integration/helpers.cjs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/integration/helpers.cjs b/test/integration/helpers.cjs new file mode 100644 index 0000000..5643bfd --- /dev/null +++ b/test/integration/helpers.cjs @@ -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'); +}; |