Skip to content

Commit df0d19a

Browse files
authored
feat(nuxt): Add E2E test for Nuxt 4 preview (#13799)
depends on #13798
1 parent 5c06bd2 commit df0d19a

28 files changed

+1825
-1161
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ jobs:
931931
'node-koa',
932932
'node-connect',
933933
'nuxt-3',
934+
'nuxt-4',
934935
'vue-3',
935936
'webpack-4',
936937
'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: 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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script setup lang="ts">
2+
import { useRoute, useFetch } from '#imports'
3+
4+
const route = useRoute();
5+
const param = route.params.param;
6+
7+
const fetchError = async () => {
8+
await useFetch(`/api/param-error/${param}`);
9+
}
10+
11+
const fetchData = async () => {
12+
await useFetch(`/api/test-param/${param}`);
13+
};
14+
</script>
15+
16+
<template>
17+
<p>Param: {{ $route.params.param }}</p>
18+
19+
<ErrorButton id="errorBtn" errorText="Error thrown from Param Route Button" />
20+
<button @click="fetchData">Fetch Server Data</button>
21+
<button @click="fetchError">Fetch Server Error</button>
22+
</template>
23+
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+
});

0 commit comments

Comments
 (0)