mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50:02 -04:00
add basic testing setup using playwright in tests folder
This commit is contained in:
parent
ca79fdc13b
commit
259160d06a
8 changed files with 90 additions and 8 deletions
|
@ -11,4 +11,4 @@ cp -r assets/ $DST/assets
|
||||||
cp -r dist/ $DST/scram
|
cp -r dist/ $DST/scram
|
||||||
cp -r static/* $DST
|
cp -r static/* $DST
|
||||||
|
|
||||||
echo 'let _CONFIG = { wispurl: "wss://puter.cafe/", bareurl: "https://aluu.xyz/bare/" }' > $DST/config.js
|
echo 'let _CONFIG = { wispurl: "wss://puter.cafe/", bareurl: "https://aluu.xyz/bare/" }' >> $DST/config.js
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
let _CONFIG = { wispurl: "wss://puter.cafe/", bareurl: "https://aluu.xyz/bare/" }
|
5
tests/.gitignore
vendored
Normal file
5
tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
node_modules/
|
||||||
|
/test-results/
|
||||||
|
/playwright-report/
|
||||||
|
/blob-report/
|
||||||
|
/playwright/.cache/
|
3
tests/.gitmodules
vendored
Normal file
3
tests/.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "scramjet"]
|
||||||
|
path = scramjet
|
||||||
|
url = git@github.com:MercuryWorkshop/scramjet.git
|
|
@ -1,7 +0,0 @@
|
||||||
<head></head>
|
|
||||||
<script>
|
|
||||||
function f() {
|
|
||||||
s = [window]
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<button onclick="console.log(document.querySelector('script').innerHTML)">Google</button>
|
|
14
tests/package.json
Normal file
14
tests/package.json
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "scramjet-tests",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"@playwright/test": "^1.48.0",
|
||||||
|
"@types/node": "^22.7.5"
|
||||||
|
}
|
||||||
|
}
|
54
tests/playwright.config.ts
Normal file
54
tests/playwright.config.ts
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read environment variables from file.
|
||||||
|
* https://github.com/motdotla/dotenv
|
||||||
|
*/
|
||||||
|
// import dotenv from 'dotenv';
|
||||||
|
// import path from 'path';
|
||||||
|
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './tests',
|
||||||
|
/* 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: {
|
||||||
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
|
// baseURL: 'http://127.0.0.1:3000',
|
||||||
|
|
||||||
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configure projects for major browsers */
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
// {
|
||||||
|
// name: 'firefox',
|
||||||
|
// use: { ...devices['Desktop Firefox'] },
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
|
||||||
|
/* Run your local dev server before starting the tests */
|
||||||
|
webServer: {
|
||||||
|
command: 'cd .. && pnpm run dev',
|
||||||
|
url: 'http://127.0.0.1:1337',
|
||||||
|
reuseExistingServer: !process.env.CI,
|
||||||
|
},
|
||||||
|
});
|
12
tests/tests/scramjet.spec.ts
Normal file
12
tests/tests/scramjet.spec.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { test, expect, type Page } from '@playwright/test';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:1337');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe("Page loaded", () => {
|
||||||
|
test("should display the title", async ({ page }) => {
|
||||||
|
const title = await page.locator('h1').textContent();
|
||||||
|
expect(title).toBe('Percury Unblocker');
|
||||||
|
});
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue