Skip to content

Commit c48d87c

Browse files
authored
test(nuxt): Add Nuxt 3 E2E test for client-side (#13002)
Adding E2E test app with `@nuxt/test-utils` based on the [Nuxt docs](https://nuxt.com/docs/getting-started/testing#testing-in-a-browser).
1 parent 849d1cf commit c48d87c

File tree

15 files changed

+155
-0
lines changed

15 files changed

+155
-0
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ jobs:
10161016
'node-exports-test-app',
10171017
'node-koa',
10181018
'node-connect',
1019+
'nuxt-3',
10191020
'vue-3',
10201021
'webpack-4',
10211022
'webpack-5'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<NuxtLayout>
3+
<header>
4+
<nav>
5+
<ul>
6+
<li><NuxtLink to="/client-error">Client Error</NuxtLink></li>
7+
</ul>
8+
</nav>
9+
</header>
10+
<NuxtPage />
11+
</NuxtLayout>
12+
</template>
13+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script setup>
2+
const triggerError = () => {
3+
throw new Error('Error thrown from Nuxt-3 E2E test app');
4+
};
5+
</script>
6+
7+
<template>
8+
<button id="errorBtn" @click="triggerError">Trigger Error</button>
9+
</template>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
modules: ['@sentry/nuxt/module'],
4+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "nuxt-3",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "nuxt preview",
10+
"clean": "npx nuxi cleanup",
11+
"test": "playwright test",
12+
"test:build": "pnpm install && npx playwright install && pnpm build",
13+
"test:assert": "pnpm test"
14+
},
15+
"dependencies": {
16+
"@sentry/nuxt": "latest || *",
17+
"nuxt": "3.11.2"
18+
},
19+
"devDependencies": {
20+
"@nuxt/test-utils": "^3.13.1",
21+
"@playwright/test": "^1.44.1",
22+
"@sentry-internal/test-utils": "link:../../../test-utils"
23+
}
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script setup>
2+
import ErrorButton from '../components/ErrorButton.vue';
3+
</script>
4+
5+
<template>
6+
<ErrorButton />
7+
</template>
8+
9+
10+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<h1>Hello!</h1>
3+
</template>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { fileURLToPath } from 'node:url';
2+
import type { ConfigOptions } from '@nuxt/test-utils/playwright';
3+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
4+
5+
const nuxtConfigOptions: ConfigOptions = {
6+
nuxt: {
7+
rootDir: fileURLToPath(new URL('.', import.meta.url)),
8+
},
9+
};
10+
11+
const config = getPlaywrightConfig({
12+
startCommand: `pnpm preview`,
13+
use: { ...nuxtConfigOptions },
14+
});
15+
16+
export default config;

0 commit comments

Comments
 (0)