-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up test framework & add basic test (#57)
- Loading branch information
1 parent
4e3815d
commit a62bf39
Showing
9 changed files
with
868 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { describe, expect, it } from 'vitest' | ||
import { $fetch, setup, startServer } from '@nuxt/test-utils/e2e' | ||
|
||
describe('ssr', async () => { | ||
await setup({ | ||
rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)), | ||
}) | ||
|
||
it('renders the index page', async () => { | ||
// Get response to a server-rendered page with `$fetch`. | ||
const html = await $fetch('/') | ||
expect(html).toContain('<div>basic <span>original value</span></div>') | ||
}) | ||
|
||
it('changes runtime config and restarts', async () => { | ||
await startServer({ env: { NUXT_PUBLIC_MY_VALUE: 'overwritten by test!' } }) | ||
|
||
const html = await $fetch('/') | ||
expect(html).toContain('<div>basic <span>overwritten by test!</span></div>') | ||
|
||
await startServer() | ||
const htmlRestored = await $fetch('/') | ||
expect(htmlRestored).toContain('<div>basic <span>original value</span></div>') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import WPNuxtModule from '../../../src/module' | ||
|
||
export default defineNuxtConfig({ | ||
runtimeConfig: { | ||
public: { | ||
myValue: 'original value', | ||
}, | ||
}, | ||
modules: [ | ||
WPNuxtModule | ||
] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"private": true, | ||
"name": "basic", | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"> | ||
import { useRuntimeConfig } from 'nuxt/app'; | ||
const config = useRuntimeConfig(); | ||
</script> | ||
|
||
<template> | ||
<div>basic <span>{{ config.public.myValue }}</span></div> | ||
</template> |
This file was deleted.
Oops, something went wrong.