mirror of https://github.com/boa-dev/boa.git
scc
1 year ago
committed by
GitHub
10 changed files with 194 additions and 12 deletions
@ -0,0 +1,25 @@
|
||||
import { expect, test } from "@playwright/test"; |
||||
|
||||
test.beforeEach(async ({ page }) => { |
||||
page.on("console", (msg) => { |
||||
let msgText = ""; |
||||
for (let i = 0; i < msg.args().length; ++i) { |
||||
msgText += `${msg.args()[i]}`; |
||||
} |
||||
// eslint-disable-next-line no-console
|
||||
console.log(msgText); |
||||
}); |
||||
}); |
||||
|
||||
test("boa demo", async ({ page }) => { |
||||
await page.goto("/", { |
||||
// wait until all content is loaded
|
||||
waitUntil: "networkidle", |
||||
}); |
||||
// wait for the code evaluate
|
||||
await page.waitForTimeout(2000); |
||||
const output = page.getByTestId("output"); |
||||
const result = await output.innerHTML(); |
||||
console.log("eval result: ", result); |
||||
await expect(result.match("Hello, World")?.length).toEqual(1); |
||||
}); |
@ -0,0 +1,71 @@
|
||||
import { defineConfig, devices } from "@playwright/test"; |
||||
|
||||
/** |
||||
* Read environment variables from file. |
||||
* https://github.com/motdotla/dotenv
|
||||
*/ |
||||
// require('dotenv').config();
|
||||
|
||||
/** |
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/ |
||||
export default defineConfig({ |
||||
testDir: "./", |
||||
/* Maximum time one test can run for. */ |
||||
timeout: 300 * 1000, |
||||
expect: { |
||||
/** |
||||
* Maximum time expect() should wait for the condition to be met. |
||||
* For example in `await expect(locator).toHaveText();` |
||||
*/ |
||||
timeout: 5000, |
||||
}, |
||||
/* Run tests in files in parallel */ |
||||
fullyParallel: true, |
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */ |
||||
forbidOnly: !!process.env.CI, |
||||
/* Retry on CI only */ |
||||
retries: process.env.CI ? 2 : 0, |
||||
/* Opt out of parallel tests on CI. */ |
||||
workers: process.env.CI ? 1 : undefined, |
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
||||
reporter: "html", |
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
||||
use: { |
||||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ |
||||
actionTimeout: 0, |
||||
/* Base URL to use in actions like `await page.goto('/')`. */ |
||||
// baseURL: 'http://localhost:3000',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
||||
trace: "on-first-retry", |
||||
baseURL: "http://localhost:8081/", |
||||
}, |
||||
webServer: { |
||||
command: "node ./server.mjs", |
||||
cwd: "./", |
||||
url: "http://localhost:8081", |
||||
timeout: 60 * 1000, |
||||
reuseExistingServer: !process.env.CI, |
||||
stdout: "pipe", |
||||
stderr: "pipe", |
||||
}, |
||||
|
||||
/* Configure projects for major browsers */ |
||||
projects: [ |
||||
{ |
||||
name: "chromium", |
||||
use: { ...devices["Desktop Chrome"] }, |
||||
}, |
||||
|
||||
{ |
||||
name: "firefox", |
||||
use: { ...devices["Desktop Firefox"] }, |
||||
}, |
||||
|
||||
{ |
||||
name: "webkit", |
||||
use: { ...devices["Desktop Safari"] }, |
||||
}, |
||||
], |
||||
}); |
@ -0,0 +1,23 @@
|
||||
import { createServer } from "http"; |
||||
import { readFile, readFileSync } from "fs"; |
||||
import { dirname, join } from "path"; |
||||
import { fileURLToPath, parse } from "url"; |
||||
import { lookup } from "mime-types"; |
||||
|
||||
const __filename = fileURLToPath(import.meta.url); |
||||
|
||||
createServer((req, res) => { |
||||
const __dirname = dirname(__filename); |
||||
const path = join(__dirname, "../../dist", parse(req.url, true).path); |
||||
readFile(path, (err, data) => { |
||||
if (err) { |
||||
res.writeHead(200, { "Content-Type": "text/html" }); |
||||
res.end(readFileSync(join(__dirname, "../../dist/index.html"))); |
||||
} else { |
||||
res.writeHead(200, { "Content-Type": lookup(path) }); |
||||
res.end(data); |
||||
} |
||||
}); |
||||
}).listen(8081, () => { |
||||
console.log("Server running at http://localhost:8081/"); |
||||
}); |
Loading…
Reference in new issue