Skip to content

Commit 05ecade

Browse files
committed
feat(nuxt): Add E2E test for Nuxt 4 preview
1 parent 5e2bc47 commit 05ecade

26 files changed

+1760
-1159
lines changed
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<NuxtLayout>
3+
<header>
4+
<nav>
5+
<ul>
6+
<li><NuxtLink to="/fetch-server-error">Fetch Server Error</NuxtLink></li>
7+
<li><NuxtLink to="/test-param/1234">Fetch Param</NuxtLink></li>
8+
<li><NuxtLink to="/client-error">Client Error</NuxtLink></li>
9+
</ul>
10+
</nav>
11+
</header>
12+
<NuxtPage />
13+
</NuxtLayout>
14+
</template>
15+
16+
<script setup>
17+
</script>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup>
2+
import { defineProps } from 'vue';
3+
4+
const props = defineProps({
5+
errorText: {
6+
type: String,
7+
required: true
8+
},
9+
id: {
10+
type: String,
11+
required: true
12+
}
13+
})
14+
15+
const triggerError = () => {
16+
throw new Error(props.errorText);
17+
};
18+
</script>
19+
20+
<template>
21+
<button :id="props.id" @click="triggerError">Trigger Error</button>
22+
</template>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script setup>
2+
import ErrorButton from '../components/ErrorButton.vue';
3+
</script>
4+
5+
<template>
6+
<ErrorButton id="errorBtn" error-text="Error thrown from nuxt-4 E2E test app"/>
7+
<ErrorButton id="errorBtn2" error-text="Another Error thrown from nuxt-4 E2E test app"/>
8+
</template>
9+
10+
11+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div>
3+
<button @click="fetchData">Fetch Server Data</button>
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import { useFetch} from '#imports'
9+
10+
const fetchData = async () => {
11+
await useFetch('/api/server-error');
12+
}
13+
</script>
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<p>{{ $route.params.param }} - {{ $route.params.param }}</p>
3+
4+
<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
5+
<button @click="fetchData">Fetch Server Data</button>
6+
</template>
7+
8+
<script setup lang="ts">
9+
import { useRoute, useFetch } from '#imports'
10+
11+
const route = useRoute();
12+
const param = route.params.param;
13+
14+
const fetchData = async () => {
15+
await useFetch(`/api/param-error/${param}`);
16+
}
17+
</script>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({
3+
future: { compatibilityVersion: 4 },
4+
compatibilityDate: '2024-04-03',
5+
imports: { autoImport: false },
6+
7+
modules: ['@sentry/nuxt/module'],
8+
9+
runtimeConfig: {
10+
public: {
11+
sentry: {
12+
dsn: 'https://[email protected]/1337',
13+
},
14+
},
15+
},
16+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "nuxt-4",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"build": "nuxt build",
7+
"dev": "nuxt dev",
8+
"generate": "nuxt generate",
9+
"preview": "NODE_OPTIONS='--import ./public/instrument.server.mjs' 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.13.2",
18+
"vue": "latest",
19+
"vue-router": "latest"
20+
},
21+
"devDependencies": {
22+
"@nuxt/test-utils": "^3.14.1",
23+
"@playwright/test": "^1.44.1",
24+
"@sentry-internal/test-utils": "link:../../../test-utils"
25+
}
26+
}

0 commit comments

Comments
 (0)