Add tests for roadmap pages and homepage
4
.gitignore
vendored
@ -20,3 +20,7 @@ pnpm-debug.log*
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
tests-examples
|
@ -13,7 +13,8 @@
|
||||
"compress:jsons": "node bin/compress-jsons.cjs",
|
||||
"upgrade": "ncu -u",
|
||||
"roadmap-links": "node bin/roadmap-links.cjs",
|
||||
"roadmap-content": "node bin/roadmap-content.cjs"
|
||||
"roadmap-content": "node bin/roadmap-content.cjs",
|
||||
"test:e2e": "playwright test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/sitemap": "^1.0.0",
|
||||
@ -27,6 +28,7 @@
|
||||
"tailwindcss": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.29.2",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"gh-pages": "^4.0.0",
|
||||
"json-to-pretty-yaml": "^1.2.2",
|
||||
|
108
playwright.config.ts
Normal file
@ -0,0 +1,108 @@
|
||||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
import { devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// require('dotenv').config();
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: './tests',
|
||||
/* Maximum time one test can run for. */
|
||||
timeout: 30 * 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',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
},
|
||||
},
|
||||
|
||||
// {
|
||||
// name: 'firefox',
|
||||
// use: {
|
||||
// ...devices['Desktop Firefox'],
|
||||
// },
|
||||
// },
|
||||
|
||||
// {
|
||||
// name: 'webkit',
|
||||
// use: {
|
||||
// ...devices['Desktop Safari'],
|
||||
// },
|
||||
// },
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: {
|
||||
// ...devices['Pixel 5'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: {
|
||||
// ...devices['iPhone 12'],
|
||||
// },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: {
|
||||
// channel: 'msedge',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: {
|
||||
// channel: 'chrome',
|
||||
// },
|
||||
// },
|
||||
],
|
||||
|
||||
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
||||
// outputDir: 'test-results/',
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: {
|
||||
command: 'npm run dev',
|
||||
url: "http://localhost:3000",
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
18
pnpm-lock.yaml
generated
@ -3,6 +3,7 @@ lockfileVersion: 5.4
|
||||
specifiers:
|
||||
'@astrojs/sitemap': ^1.0.0
|
||||
'@astrojs/tailwind': ^2.1.3
|
||||
'@playwright/test': ^1.29.2
|
||||
'@tailwindcss/typography': ^0.5.9
|
||||
astro: ^1.9.2
|
||||
astro-compress: ^1.1.27
|
||||
@ -28,6 +29,7 @@ dependencies:
|
||||
tailwindcss: 3.2.4
|
||||
|
||||
devDependencies:
|
||||
'@playwright/test': 1.29.2
|
||||
'@tailwindcss/typography': 0.5.9_tailwindcss@3.2.4
|
||||
gh-pages: 4.0.0
|
||||
json-to-pretty-yaml: 1.2.2
|
||||
@ -580,6 +582,15 @@ packages:
|
||||
tiny-glob: 0.2.9
|
||||
tslib: 2.4.1
|
||||
|
||||
/@playwright/test/1.29.2:
|
||||
resolution: {integrity: sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@types/node': 17.0.45
|
||||
playwright-core: 1.29.2
|
||||
dev: true
|
||||
|
||||
/@pnpm/network.ca-file/1.0.2:
|
||||
resolution: {integrity: sha512-YcPQ8a0jwYU9bTdJDpXjMi7Brhkr1mXsXrUJvjqM2mQDgkRiz8jFaQGOdaLxgjtUfQgZhKy/O3cG/YwmgKaxLA==}
|
||||
engines: {node: '>=12.22.0'}
|
||||
@ -756,7 +767,6 @@ packages:
|
||||
|
||||
/@types/node/17.0.45:
|
||||
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
|
||||
dev: false
|
||||
|
||||
/@types/parse5/6.0.3:
|
||||
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
|
||||
@ -4228,6 +4238,12 @@ packages:
|
||||
dependencies:
|
||||
find-up: 4.1.0
|
||||
|
||||
/playwright-core/1.29.2:
|
||||
resolution: {integrity: sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA==}
|
||||
engines: {node: '>=14'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/postcss-import/14.1.0_postcss@8.4.20:
|
||||
resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
|
7
tests/index.spec.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('homepage test', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
await expect(page).toHaveScreenshot({ fullPage: true });
|
||||
});
|
After Width: | Height: | Size: 346 KiB |
BIN
tests/index.spec.ts-snapshots/homepage-test-1-firefox-darwin.png
Normal file
After Width: | Height: | Size: 359 KiB |
BIN
tests/index.spec.ts-snapshots/homepage-test-1-webkit-darwin.png
Normal file
After Width: | Height: | Size: 563 KiB |
13
tests/roadmap.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
const roadmapIds = fs.readdirSync(path.join(process.cwd(), 'src/roadmaps'));
|
||||
|
||||
for (const roadmapId of roadmapIds) {
|
||||
test(`roadmap ${roadmapId}`, async ({ page }) => {
|
||||
await page.goto(`/${roadmapId}`);
|
||||
|
||||
await expect(page).toHaveScreenshot({ fullPage: true });
|
||||
});
|
||||
}
|
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 455 KiB |
After Width: | Height: | Size: 690 KiB |
After Width: | Height: | Size: 860 KiB |
After Width: | Height: | Size: 593 KiB |
After Width: | Height: | Size: 685 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 555 KiB |
After Width: | Height: | Size: 745 KiB |
After Width: | Height: | Size: 506 KiB |
After Width: | Height: | Size: 800 KiB |
After Width: | Height: | Size: 379 KiB |
After Width: | Height: | Size: 384 KiB |
After Width: | Height: | Size: 344 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 648 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 311 KiB |
BIN
tests/roadmap.spec.ts-snapshots/roadmap-qa-1-chromium-darwin.png
Normal file
After Width: | Height: | Size: 538 KiB |
After Width: | Height: | Size: 369 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 492 KiB |
After Width: | Height: | Size: 491 KiB |
After Width: | Height: | Size: 330 KiB |
After Width: | Height: | Size: 396 KiB |