test: update tests

This commit is contained in:
Daniel Roe 2024-06-18 17:24:17 +01:00
parent 07c9f7a6f8
commit 673b89bfa5
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B
5 changed files with 52 additions and 5 deletions

View File

@ -2595,14 +2595,20 @@ describe('teleports', () => {
})
})
describe('Node.js compatibility for client-side', () => {
it('should work', async () => {
const { page } = await renderPage('/node-compat')
describe.only('experimental', () => {
it('decorators support works', async () => {
const html = await $fetch('/experimental/decorators')
expect(html).toContain('decorated-decorated')
expectNoClientErrors('/experimental/decorators')
})
it('Node.js compatibility for client-side', async () => {
const { page } = await renderPage('/experimental/node-compat')
await page.locator('body').getByText('Nuxt is Awesome!').waitFor()
expect(await page.innerHTML('body')).toContain('CWD: [available]')
await page.close()
})
}, 20_000)
}, 30_000)
})
function normaliseIslandResult (result: NuxtIslandResponse) {
return {

View File

@ -242,6 +242,7 @@ export default defineNuxtConfig({
inlineStyles: id => !!id && !id.includes('assets.vue'),
},
experimental: {
decorators: true,
typedPages: true,
polyfillVueUseHead: true,
respectNoSSRHeader: true,

View File

@ -0,0 +1,26 @@
<script setup lang="ts">
function something(_method: () => unknown) {
return () => 'decorated'
}
class SomeClass {
@something
public someMethod() {
return 'initial'
}
}
const value = new SomeClass().someMethod()
const { data } = await useFetch('/api/experimental/decorators')
</script>
<template>
<div>
{{ value }}-{{ data }}
</div>
</template>
<style scoped>
</style>

View File

@ -0,0 +1,14 @@
export default eventHandler((_event) => {
function something(_method: () => unknown) {
return () => 'decorated'
}
class SomeClass {
@something
public someMethod() {
return 'initial'
}
}
return new SomeClass().someMethod()
})