mirror of
https://github.com/coder/code-server.git
synced 2024-12-24 18:23:01 +03:00
47a05c998a
After thinking about it some more it's probably mostly only useful to see the output when the tests are hanging. Otherwise there's a lot of noise about Jest child processes and pipes.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
// This setup runs before our e2e tests
|
|
// so that it authenticates us into code-server
|
|
// ensuring that we're logged in before we run any tests
|
|
import { chromium } from "playwright"
|
|
import { CODE_SERVER_ADDRESS, PASSWORD } from "./constants"
|
|
import * as wtfnode from "./wtfnode"
|
|
|
|
module.exports = async () => {
|
|
console.log("\n🚨 Running Global Setup for Jest Tests")
|
|
console.log(" Please hang tight...")
|
|
const browser = await chromium.launch()
|
|
const context = await browser.newContext()
|
|
const page = await context.newPage()
|
|
|
|
if (process.env.WTF_NODE) {
|
|
wtfnode.setup()
|
|
}
|
|
|
|
await page.goto(CODE_SERVER_ADDRESS, { waitUntil: "domcontentloaded" })
|
|
// Type in password
|
|
await page.fill(".password", PASSWORD)
|
|
// Click the submit button and login
|
|
await page.click(".submit")
|
|
|
|
// Save storage state and store as an env variable
|
|
// More info: https://playwright.dev/docs/auth?_highlight=authe#reuse-authentication-state
|
|
const storage = await context.storageState()
|
|
process.env.STORAGE = JSON.stringify(storage)
|
|
|
|
await page.close()
|
|
await browser.close()
|
|
await context.close()
|
|
console.log("✅ Global Setup for Jest Tests is now complete.")
|
|
}
|