-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathlazy.test.ts
56 lines (46 loc) · 1.7 KB
/
lazy.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { fileURLToPath } from 'url'
import { dirname } from 'path'
import { describe, afterAll, beforeAll, test, expect } from 'vitest'
import type { Browser } from 'playwright-chromium'
import sentryTestkit from 'sentry-testkit'
import { setup, url } from '@nuxtjs/module-test-utils'
import type { Nuxt } from '../src/kit-shim'
import { $$, createBrowser, loadConfig } from './utils'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const { localServer } = sentryTestkit.default()
const TEST_DSN = 'http://[email protected]/000001'
describe('Smoke test (lazy)', () => {
let nuxt: Nuxt
let browser: Browser
beforeAll(async () => {
await localServer.start(TEST_DSN)
const dsn = localServer.getDsn() ?? undefined
nuxt = (await setup(loadConfig(__dirname, 'lazy', { sentry: { dsn } }, { merge: true }))).nuxt
browser = await createBrowser()
})
afterAll(async () => {
if (browser) {
await browser.close()
}
await nuxt.close()
await localServer.stop()
})
test('builds, runs and there are no errors', async () => {
const page = await browser.newPage()
const errors: string[] = []
page.on('pageerror', (error) => {
errors.push(error.message)
})
const consoleMessages: string[] = []
page.on('console', (message) => {
consoleMessages.push(message.text())
})
await page.goto(url('/'))
// process.sentry is not initialized in webpack context in tests.
// expect(await $$('#server-side', page)).toBe('Works!')
expect(await $$('#client-side', page)).toBe('Works and is ready!')
expect(errors).toEqual([])
expect(consoleMessages).toEqual(['Sentry is ready'])
})
})