2023-09-11 20:26:59 +03:00
|
|
|
import { promises as fs } from "fs"
|
|
|
|
import * as path from "path"
|
2022-08-09 21:24:37 +03:00
|
|
|
import { workspaceDir } from "./constants"
|
2022-12-22 20:25:28 +03:00
|
|
|
import { clean, tmpdir } from "./helpers"
|
2021-02-12 22:41:59 +03:00
|
|
|
import * as wtfnode from "./wtfnode"
|
2021-02-02 00:38:53 +03:00
|
|
|
|
2021-06-23 00:34:11 +03:00
|
|
|
/**
|
2021-12-17 22:06:52 +03:00
|
|
|
* Perform workspace cleanup and authenticate. This should be ran before e2e
|
|
|
|
* tests execute.
|
2021-06-23 00:34:11 +03:00
|
|
|
*/
|
2021-06-10 16:09:38 +03:00
|
|
|
export default async function () {
|
|
|
|
console.log("\n🚨 Running Global Setup for Playwright End-to-End Tests")
|
|
|
|
console.log(" Please hang tight...")
|
|
|
|
|
2021-06-23 00:34:11 +03:00
|
|
|
// Cleanup workspaces from previous tests.
|
|
|
|
await clean(workspaceDir)
|
|
|
|
|
2021-02-12 22:43:11 +03:00
|
|
|
if (process.env.WTF_NODE) {
|
|
|
|
wtfnode.setup()
|
|
|
|
}
|
2021-02-12 22:41:59 +03:00
|
|
|
|
2022-12-22 20:25:28 +03:00
|
|
|
// Create dummy code-workspace for routes.test.ts
|
|
|
|
const codeWorkspace = path.join(await tmpdir(workspaceDir), "test.code-workspace")
|
|
|
|
await fs.writeFile(codeWorkspace, "")
|
|
|
|
process.env.CODE_WORKSPACE_DIR = codeWorkspace
|
|
|
|
|
|
|
|
// Create dummy folder for routes.test.ts
|
|
|
|
const folder = await tmpdir(workspaceDir)
|
|
|
|
process.env.CODE_FOLDER_DIR = folder
|
|
|
|
|
2021-06-10 16:09:38 +03:00
|
|
|
console.log("✅ Global Setup for Playwright End-to-End Tests is now complete.")
|
2021-02-02 00:38:53 +03:00
|
|
|
}
|