2022-08-10 02:24:37 +08:00
|
|
|
import { workspaceDir } from "./constants"
|
2022-12-23 01:25:28 +08:00
|
|
|
import { clean, tmpdir } from "./helpers"
|
2021-02-13 03:41:59 +08:00
|
|
|
import * as wtfnode from "./wtfnode"
|
2022-12-23 01:25:28 +08:00
|
|
|
import * as path from "path"
|
|
|
|
import { promises as fs } from "fs"
|
2021-02-02 05:38:53 +08:00
|
|
|
|
2021-06-23 05:34:11 +08:00
|
|
|
/**
|
2021-12-18 03:06:52 +08:00
|
|
|
* Perform workspace cleanup and authenticate. This should be ran before e2e
|
|
|
|
* tests execute.
|
2021-06-23 05:34:11 +08:00
|
|
|
*/
|
2021-06-10 21:09:38 +08: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 05:34:11 +08:00
|
|
|
// Cleanup workspaces from previous tests.
|
|
|
|
await clean(workspaceDir)
|
|
|
|
|
2021-02-13 03:43:11 +08:00
|
|
|
if (process.env.WTF_NODE) {
|
|
|
|
wtfnode.setup()
|
|
|
|
}
|
2021-02-13 03:41:59 +08:00
|
|
|
|
2022-12-23 01:25:28 +08: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 21:09:38 +08:00
|
|
|
console.log("✅ Global Setup for Playwright End-to-End Tests is now complete.")
|
2021-02-02 05:38:53 +08:00
|
|
|
}
|