Skip to content

Commit 490753c

Browse files
committedNov 6, 2023
test: add a few more basic examples for e2e tests
1 parent 0caf44d commit 490753c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
 

‎examples/app/test/browser.e2e.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { fileURLToPath } from 'node:url'
2+
import { createPage, setup } from '@nuxt/test-utils'
3+
import { describe, expect, it } from 'vitest'
4+
5+
await setup({
6+
rootDir: fileURLToPath(new URL('../', import.meta.url)),
7+
browser: true,
8+
})
9+
10+
describe('browser', async () => {
11+
it('runs a test', async () => {
12+
const page = await createPage('/')
13+
expect(page.getByRole('heading').innerText()).toContain('Welcome to Nuxt!')
14+
})
15+
})

‎examples/app/test/dev.e2e.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { fileURLToPath } from 'node:url'
2+
import { $fetch, setup } from '@nuxt/test-utils'
3+
import { describe, expect, it } from 'vitest'
4+
5+
await setup({
6+
rootDir: fileURLToPath(new URL('../', import.meta.url)),
7+
dev: true,
8+
})
9+
10+
describe('server (dev)', async () => {
11+
it('runs a test', async () => {
12+
const html = await $fetch('/')
13+
expect(html.slice(0, 15)).toMatchInlineSnapshot(`
14+
"<!DOCTYPE html>"
15+
`)
16+
})
17+
})

0 commit comments

Comments
 (0)
Please sign in to comment.