-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import assert from 'node:assert' | ||
import test from 'node:test' | ||
import { createServer } from 'node:http' | ||
import playwright from 'playwright' | ||
import handler from 'serve-handler' | ||
|
||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) | ||
|
||
async function getText(page, selector, options) { | ||
return page.locator(selector, options).innerText() | ||
} | ||
|
||
test('browser integration test', async () => { | ||
const server = createServer((request, response) => { | ||
return handler(request, response) | ||
}) | ||
server.listen(3000, () => { | ||
console.log('Running at http://localhost:3000') | ||
}) | ||
|
||
const cleanup = () => { | ||
server.close() | ||
} | ||
process.on('SIGINT', cleanup) | ||
process.on('SIGTERM', cleanup) | ||
process.on('SIGQUIT', cleanup) | ||
process.on('uncaughtException', cleanup) | ||
await sleep(2000) | ||
|
||
const browser = await playwright['chromium'].launch({ headless: true }) | ||
const page = await browser.newPage({}) | ||
await page.goto('http://localhost:3000') | ||
const data = await getText(page, '#app') | ||
|
||
assert(data === `isLocale('en-US'): true`) | ||
|
||
browser.close() | ||
server.close() | ||
}) |
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