-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from davidmyersdev/add-more-tests
Add end-to-end tests
- Loading branch information
Showing
12 changed files
with
193 additions
and
292 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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
*.log | ||
.DS_Store | ||
.cache | ||
/*.tgz | ||
blob-report | ||
dist | ||
node_modules | ||
package.tgz | ||
playwright-report | ||
test-results | ||
tmp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const webServerCommand = process.env.WEB_SERVER_COMMAND || 'pnpm dev' | ||
const webServerUrl = process.env.WEB_SERVER_URL || 'http://localhost:5173' | ||
|
||
// https://playwright.dev/docs/test-configuration | ||
export default defineConfig({ | ||
forbidOnly: !!process.env.CI, | ||
fullyParallel: true, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
reporter: 'html', | ||
retries: process.env.CI ? 2 : 0, | ||
testDir: './test/e2e', | ||
use: { | ||
baseURL: webServerUrl, | ||
trace: 'on-first-retry', | ||
}, | ||
webServer: { | ||
command: webServerCommand, | ||
stdout: 'ignore', | ||
url: webServerUrl, | ||
}, | ||
workers: process.env.CI ? 1 : undefined, | ||
}) |
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,59 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { isBuild, isDev } from '/test/utils' | ||
|
||
test('sets the page title', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
await expect(page).toHaveTitle('Example (Vanilla)') | ||
}) | ||
|
||
test('logs the correct values', async ({ page }) => { | ||
const errors = [] | ||
const logs = [] | ||
|
||
page.on('console', (message) => { | ||
logs.push(message.text()) | ||
}) | ||
|
||
page.on('pageerror', (error) => { | ||
errors.push(error.message) | ||
}) | ||
|
||
await page.goto('/') | ||
|
||
expect(errors).toEqual([]) | ||
|
||
if (isBuild) { | ||
expect(logs).toEqual([ | ||
'{Volume: , vol: Volume, createFsFromVolume: , fs: Object, memfs: }', | ||
'function fetch() { [native code] }', | ||
'/', | ||
'Module', | ||
'{}', | ||
'function Array() { [native code] }', | ||
'4294967295', | ||
'Uint8Array(6)', | ||
'function Array() { [native code] }', | ||
'Hello from fs!', | ||
'{some: true, else: 1, inner: Object}', | ||
]) | ||
} | ||
|
||
if (isDev) { | ||
expect(logs).toEqual([ | ||
'[vite] connecting...', | ||
'[vite] connected.', | ||
'{Volume: , vol: _Volume, createFsFromVolume: , fs: Object, memfs: }', | ||
'function fetch() { [native code] }', | ||
'/', | ||
'{nextTick: , title: browser, browser: true, env: Object, argv: Array(0)}', | ||
'{}', | ||
'function Array() { [native code] }', | ||
'4294967295', | ||
'Uint8Array(6)', | ||
'function Array() { [native code] }', | ||
'Hello from fs!', | ||
'{some: true, else: 1, inner: Object}', | ||
]) | ||
} | ||
}) |
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,2 @@ | ||
export const isBuild = process.env.VITE_COMMAND === 'build' | ||
export const isDev = process.env.VITE_COMMAND === 'dev' |
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"noEmit": true, | ||
"paths": { | ||
"/*": ["./*"] | ||
}, | ||
"skipLibCheck": true | ||
} | ||
} |
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 |
---|---|---|
|
@@ -88,6 +88,7 @@ | |
"node-stdlib-browser": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.40.1", | ||
"@types/node": "^18.18.8", | ||
"buffer": "6.0.3", | ||
"esbuild": "^0.19.8", | ||
|
@@ -108,7 +109,8 @@ | |
}, | ||
"pnpm": { | ||
"overrides": { | ||
"buffer": "6.0.3" | ||
"buffer": "6.0.3", | ||
"vite": "^5.0.2" | ||
}, | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]" | ||
|
Oops, something went wrong.