Skip to content

Commit 3a27304

Browse files
committed
test: base for nuxt
1 parent 6e1181e commit 3a27304

File tree

8 files changed

+198
-145
lines changed

8 files changed

+198
-145
lines changed

Diff for: packages/nuxt/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"build": "nuxt-module-build build",
3333
"lint": "eslint src",
3434
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l nuxt-vuefire -r 1",
35+
"test": "vitest",
3536
"dev": "nuxi dev playground",
3637
"dev:build": "nuxi build playground",
3738
"dev:prepare": "nuxt-module-build --stub"
@@ -64,6 +65,7 @@
6465
"@nuxt/eslint-config": "^0.2.0",
6566
"@nuxt/module-builder": "^0.5.4",
6667
"@nuxt/schema": "^3.8.2",
68+
"@nuxt/test-utils": "^3.8.1",
6769
"eslint": "^8.55.0",
6870
"firebase": "^10.7.0",
6971
"firebase-admin": "^11.11.1",

Diff for: packages/nuxt/tests/basic.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
import { describe, it, expect } from 'vitest'
4+
import { setup, $fetch } from '@nuxt/test-utils'
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
8+
describe.skip('ssr', async () => {
9+
await setup({
10+
rootDir: path.join(__dirname, './fixtures/basic'),
11+
})
12+
13+
it('renders the index page', async () => {
14+
// Get response to a server-rendered page with `$fetch`.
15+
const html = await $fetch('/')
16+
expect(html).toContain('<div>basic</div>')
17+
})
18+
})

Diff for: packages/nuxt/tests/fixtures/basic/app.vue

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<div>basic</div>
3+
</template>
4+
5+
<script setup>
6+
</script>

Diff for: packages/nuxt/tests/fixtures/basic/nuxt.config.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import MyModule from '../../../src/module'
2+
3+
export default defineNuxtConfig({
4+
modules: [MyModule],
5+
6+
vuefire: {
7+
auth: {
8+
enabled: true,
9+
sessionCookie: true,
10+
// popupRedirectResolver: false,
11+
// persistence: ['indexedDBLocal']
12+
},
13+
appCheck: {
14+
// TODO: could automatically pick up a debug token defined as an env variable
15+
debug: process.env.NODE_ENV !== 'production',
16+
isTokenAutoRefreshEnabled: true,
17+
provider: 'ReCaptchaV3',
18+
key: '6LfJ0vgiAAAAAHheQE7GQVdG_c9m8xipBESx_SKI',
19+
},
20+
21+
emulators: {
22+
enabled: true,
23+
24+
auth: {
25+
options: {
26+
// removes the HTML footer and console warning
27+
disableWarnings: process.env.NODE_ENV === 'development',
28+
},
29+
},
30+
},
31+
32+
config: {
33+
apiKey: 'AIzaSyAkUKe36TPWL2eZTshgk-Xl4bY_R5SB97U',
34+
authDomain: 'vue-fire-store.firebaseapp.com',
35+
databaseURL: 'https://vue-fire-store.firebaseio.com',
36+
projectId: 'vue-fire-store',
37+
storageBucket: 'vue-fire-store.appspot.com',
38+
messagingSenderId: '998674887640',
39+
appId: '1:998674887640:web:1e2bb2cc3e5eb2fc3478ad',
40+
measurementId: 'G-RL4BTWXKJ7',
41+
},
42+
43+
// admin: {},
44+
},
45+
})

Diff for: packages/nuxt/tests/fixtures/basic/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"private": true,
3+
"name": "basic",
4+
"type": "module"
5+
}

Diff for: packages/nuxt/vitest.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
import { defineConfig } from 'vitest/config'
4+
5+
export default defineConfig({
6+
test: {
7+
include: ['tests/**/*.spec.ts'],
8+
coverage: {
9+
include: ['src/**/*.ts'],
10+
reporter: ['text', 'json', 'html'],
11+
// exclude: ['src/**/*.spec.ts', 'src/index.ts'],
12+
},
13+
},
14+
})

0 commit comments

Comments
 (0)