Skip to content

Commit 1d403e0

Browse files
committed
Add error repro for missing zlib imports
1 parent b981b7a commit 1d403e0

File tree

8 files changed

+129
-1
lines changed

8 files changed

+129
-1
lines changed

pnpm-lock.yaml

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>missing-zlib-imports</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/index.ts"></script>
11+
</body>
12+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "missing-zlib-imports",
3+
"type": "module",
4+
"version": "0.0.0",
5+
"private": true,
6+
"scripts": {
7+
"build": "vite build",
8+
"dev": "vite",
9+
"test:e2e": "CI=true run-p test:e2e:*",
10+
"test:e2e:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15176' WEB_SERVER_URL='http://localhost:15176' playwright test",
11+
"test:e2e:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15175' WEB_SERVER_URL='http://localhost:15175' playwright test"
12+
},
13+
"dependencies": {
14+
"fast-zlib": "^2.0.1",
15+
"vite-plugin-node-polyfills": "workspace:*"
16+
},
17+
"devDependencies": {
18+
"vite": "^5.1.1"
19+
}
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
const webServerCommand = process.env.WEB_SERVER_COMMAND || 'pnpm dev'
4+
const webServerUrl = process.env.WEB_SERVER_URL || 'http://localhost:5173'
5+
6+
// https://playwright.dev/docs/test-configuration
7+
export default defineConfig({
8+
forbidOnly: !!process.env.CI,
9+
fullyParallel: true,
10+
projects: [
11+
{
12+
name: 'chromium',
13+
use: { ...devices['Desktop Chrome'] },
14+
},
15+
],
16+
reporter: 'html',
17+
retries: process.env.CI ? 2 : 0,
18+
testDir: './test/e2e',
19+
use: {
20+
baseURL: webServerUrl,
21+
trace: 'on-first-retry',
22+
},
23+
webServer: {
24+
command: webServerCommand,
25+
stdout: 'ignore',
26+
url: webServerUrl,
27+
},
28+
workers: process.env.CI ? 1 : undefined,
29+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import zlib from 'fast-zlib'
2+
3+
// eslint-disable-next-line no-console
4+
console.log(Object.keys(zlib))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test('sets the page title', async ({ page }) => {
4+
await page.goto('/')
5+
6+
await expect(page).toHaveTitle('missing-zlib-imports')
7+
})
8+
9+
test('logs the correct values', async ({ page }) => {
10+
const errors = []
11+
const logs = []
12+
13+
page.on('console', (message) => {
14+
logs.push(message.text())
15+
})
16+
17+
page.on('pageerror', (error) => {
18+
errors.push(error.message)
19+
})
20+
21+
await page.goto('/')
22+
23+
expect(errors).toEqual([])
24+
expect(logs).toContainEqual(
25+
'[Inflate, Deflate, InflateRaw, DeflateRaw, Gzip, Gunzip, Unzip, BrotliCompress, BrotliDecompress, constants, default]',
26+
)
27+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vite'
2+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
optimizeDeps: {
7+
force: true,
8+
},
9+
plugins: [
10+
nodePolyfills(),
11+
],
12+
})

vitest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['**/*.test.ts'],
6+
},
7+
})

0 commit comments

Comments
 (0)