|
| 1 | +import { expect, test } from '@playwright/test' |
| 2 | +import { isBuild, isDev } from '/test/utils' |
| 3 | + |
| 4 | +test('sets the page title', async ({ page }) => { |
| 5 | + await page.goto('/') |
| 6 | + |
| 7 | + await expect(page).toHaveTitle('Example (Vanilla)') |
| 8 | +}) |
| 9 | + |
| 10 | +test('logs the correct values', async ({ page }) => { |
| 11 | + const errors = [] |
| 12 | + const logs = [] |
| 13 | + |
| 14 | + page.on('console', (message) => { |
| 15 | + logs.push(message.text()) |
| 16 | + }) |
| 17 | + |
| 18 | + page.on('pageerror', (error) => { |
| 19 | + errors.push(error.message) |
| 20 | + }) |
| 21 | + |
| 22 | + await page.goto('/') |
| 23 | + |
| 24 | + expect(errors).toEqual([]) |
| 25 | + |
| 26 | + if (isBuild) { |
| 27 | + expect(logs).toEqual([ |
| 28 | + '{Volume: , vol: Volume, createFsFromVolume: , fs: Object, memfs: }', |
| 29 | + 'function fetch() { [native code] }', |
| 30 | + '/', |
| 31 | + 'Module', |
| 32 | + '{}', |
| 33 | + 'function Array() { [native code] }', |
| 34 | + '4294967295', |
| 35 | + 'Uint8Array(6)', |
| 36 | + 'function Array() { [native code] }', |
| 37 | + 'Hello from fs!', |
| 38 | + '{some: true, else: 1, inner: Object}', |
| 39 | + ]) |
| 40 | + } |
| 41 | + |
| 42 | + if (isDev) { |
| 43 | + expect(logs).toEqual([ |
| 44 | + '[vite] connecting...', |
| 45 | + '[vite] connected.', |
| 46 | + '{Volume: , vol: _Volume, createFsFromVolume: , fs: Object, memfs: }', |
| 47 | + 'function fetch() { [native code] }', |
| 48 | + '/', |
| 49 | + '{nextTick: , title: browser, browser: true, env: Object, argv: Array(0)}', |
| 50 | + '{}', |
| 51 | + 'function Array() { [native code] }', |
| 52 | + '4294967295', |
| 53 | + 'Uint8Array(6)', |
| 54 | + 'function Array() { [native code] }', |
| 55 | + 'Hello from fs!', |
| 56 | + '{some: true, else: 1, inner: Object}', |
| 57 | + ]) |
| 58 | + } |
| 59 | +}) |
0 commit comments