generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace custom test fixture with global setup
- Loading branch information
1 parent
68d6ba3
commit 1cb1238
Showing
10 changed files
with
68 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { type FullConfig, chromium } from '@playwright/test' | ||
|
||
const waitForServer = async (url: string, retries = 10, delay = 3000) => { | ||
for (let i = 0; i < retries; i++) { | ||
try { | ||
const response = await fetch(url) | ||
if (response.ok) return | ||
} catch { | ||
// Ignore errors and retry | ||
} | ||
console.log(`Waiting for server to be available... (${i + 1}/${retries})`) | ||
await new Promise((res) => setTimeout(res, delay)) | ||
} | ||
throw new Error(`Server at ${url} not reachable after ${retries} attempts`) | ||
} | ||
|
||
const globalSetup = async (config: FullConfig) => { | ||
console.log('Waiting for server to be available...') | ||
|
||
await waitForServer('http://localhost:8892/modules') | ||
|
||
const browser = await chromium.launch() | ||
const context = await browser.newContext() | ||
const page = await context.newPage() | ||
await page.goto('http://localhost:8892/modules') | ||
|
||
console.log('Waiting for modules to load...') | ||
await page.waitForFunction( | ||
() => { | ||
const moduleNames = ['time', 'echo', 'cron', 'fsm', 'http', 'pubsub'] | ||
|
||
return moduleNames.every((module) => document.querySelector(`li#module-tree-module-${module}`) !== null) | ||
}, | ||
{ timeout: 120000 }, | ||
) | ||
console.log('Modules loaded!') | ||
|
||
await browser.close() | ||
} | ||
|
||
export default globalSetup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters