cycles-quartz/examples/transfers/frontend/tests/global.setup.ts

24 lines
814 B
TypeScript
Raw Permalink Normal View History

2024-08-28 08:07:41 +00:00
import { existsSync } from 'fs'
import { Readable } from 'stream'
import path from 'path'
import unzipper from 'unzipper'
async function globalSetup() {
const folderName = `keplr-extension-manifest-v3-v${process.env.TEST_KEPLR_EXTENSION_VERSION}`
const folderPath = path.join(__dirname, 'e2e', 'extensions', folderName)
// Download and decompress Keplr extension if it does not exist yet
if (!existsSync(folderPath)) {
const downloadUrl = `https://github.com/chainapsis/keplr-wallet/releases/download/v${process.env.TEST_KEPLR_EXTENSION_VERSION}/${folderName}.zip`
const resp = await fetch(downloadUrl)
if (resp.ok && resp.body) {
await Readable.fromWeb(resp.body as any)
.pipe(unzipper.Extract({ path: folderPath }))
.promise()
2024-08-28 08:07:41 +00:00
}
}
}
export default globalSetup