Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jspm_packages

# Cache
.cache
.vitest

# Compiled output
/dist

308 changes: 155 additions & 153 deletions bun.lock

Large diffs are not rendered by default.

768 changes: 354 additions & 414 deletions deno.lock

Large diffs are not rendered by default.

1,959 changes: 987 additions & 972 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@
"posttest": "npm run lint"
},
"dependencies": {
"eventsource-parser": "^4.1.1"
"eventsource-parser": "^4.1.2"
},
"devDependencies": {
"@changesets/changelog-github": "^1.0.1",
"@changesets/cli": "^3.0.3",
"@cloudflare/vitest-pool-workers": "^0.22.0",
"@cloudflare/vitest-plugin": "^1.4.1",
"@tsconfig/strictest": "^2.0.8",
"@types/node": "^22.19.19",
"@vitest/browser": "^4.1.10",
"@vitest/browser-playwright": "^4.1.10",
"@vitest/browser": "^5.0.4",
"@vitest/browser-playwright": "^5.0.4",
"eventsource-encoder": "^1.0.2",
"happy-dom": "^20.14.5",
"oxfmt": "^0.52.0",
"oxlint": "^1.67.0",
"playwright": "^1.63.0",
"happy-dom": "^21.0.1",
"oxfmt": "^0.73.0",
"oxlint": "^1.88.0",
"playwright": "^1.64.0",
"typescript": "^7.0.0",
"vitest": "^4.1.10"
"vitest": "^5.0.4"
},
"browserslist": [
"node >= 22.12.0",
Expand Down
3 changes: 2 additions & 1 deletion test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ test('message event contains correct properties', async () => {
const onMessage = getCallCounter({name: 'onMessage'})
const es = new OurEventSource(`${serverUrl}/counter`, esInit)

es.addEventListener('counter', onMessage.listener)
// A buffered chunk can dispatch multiple events before the waiting promise resumes.
es.addEventListener('counter', onMessage.listener, {once: true})
await onMessage.waitForCallCount(1)

expect(onMessage.lastArg).toMatchObject({
Expand Down
10 changes: 10 additions & 0 deletions test/helpers/iosSimulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import type {BrowserProvider, TestProject} from 'vitest/node'

const exec = promisify(execFile)

declare module 'vitest/browser' {
interface BrowserCommands {
__vitest_viewport: (viewport: {width: number; height: number}) => Promise<void>
}
}

declare module 'vitest/node' {
// `browser.instances[].browser` is typed from the union every installed provider contributes.
// `@vitest/browser-playwright` narrows it to its own three engines, so without this the iOS
Expand Down Expand Up @@ -78,6 +84,10 @@ class IosSimulatorProvider implements BrowserProvider {
constructor(project: TestProject, options: IosSimulatorOptions) {
this.project = project
this.device = options.device ?? process.env['IOS_SIMULATOR_DEVICE']

// Vitest 5 requests a viewport resize before loading the test iframe. It sizes the iframe
// itself; Safari keeps the simulator's screen size, so there is no browser window to resize.
project.browser?.registerCommand('__vitest_viewport', () => Promise.resolve())
}

getCommandsContext(): Record<string, unknown> {
Expand Down
6 changes: 3 additions & 3 deletions vitest.browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default defineConfig({
...sharedConfig,
// No `globalSetup`: the endpoints are served by the plugin above, not a standalone server.
provide: {port: BROWSER_PORT, suite: 'browser'},
// `127.0.0.1` rather than `localhost`, so that `localhost` is left over to serve as the
// second origin the CORS and cross-origin redirect tests need.
api: {host: '127.0.0.1', port: BROWSER_PORT},
browser: {
enabled: true,
provider: playwright(),
// `127.0.0.1` rather than `localhost`, so that `localhost` is left over to serve as the
// second origin the CORS and cross-origin redirect tests need.
api: {host: '127.0.0.1', port: BROWSER_PORT},
instances: [
{browser: 'chromium', headless: true},
{browser: 'firefox', headless: true},
Expand Down
6 changes: 3 additions & 3 deletions vitest.ios.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export default defineConfig({
test: {
...sharedConfig,
provide: {port: BROWSER_PORT, suite: 'browser', isWebKit: true},
// The simulator reaches the host on loopback, so this is the same address (and the same
// `localhost` second origin) the Playwright browsers use.
api: {host: '127.0.0.1', port: BROWSER_PORT},
browser: {
enabled: true,
provider: iosSimulator(),
// The simulator reaches the host on loopback, so this is the same address (and the same
// `localhost` second origin) the Playwright browsers use.
api: {host: '127.0.0.1', port: BROWSER_PORT},
// The default budget is spent well before a cold simulator has booted - the clock starts
// while the provider is still booting, not once the page is open. `npm run test:ios:boot`
// takes the boot out of this window; the headroom is for when it has not been run.
Expand Down
4 changes: 3 additions & 1 deletion vitest.workerd.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {cloudflareTest} from '@cloudflare/vitest-pool-workers'
import {cloudflareTest} from '@cloudflare/vitest-plugin'
import {defineConfig} from 'vitest/config'

import {TEST_PORT} from './test/helpers/routes.ts'
Expand Down Expand Up @@ -27,6 +27,8 @@ export default defineConfig({
],
test: {
...sharedConfig,
// workerd cannot read transformed modules from Vitest's cache on the host filesystem.
fsModuleCache: false,
globalSetup: standaloneServer,
provide: {port: TEST_PORT, suite: 'workerd'},
},
Expand Down
Loading