Skip to content

Commit ff86a4d

Browse files
committed
test: add ssr tests
1 parent 4fd07b6 commit ff86a4d

5 files changed

Lines changed: 64 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ jobs:
4646
- name: 🛠 Build project
4747
run: pnpm build
4848

49-
#- name: 🧪 Test project
50-
#run: pnpm test --coverage
49+
- name: 🧪 Test project
50+
run: pnpm test -- --coverage
5151

52-
#- name: 🟩 Coverage
53-
# uses: codecov/codecov-action@v3
52+
- name: 🟩 Coverage
53+
uses: codecov/codecov-action@v3

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"prepare": "husky install",
4848
"prepublishOnly": "pnpm lint && pnpm test && pinst --disable",
4949
"release": "release-it",
50-
"test": "echo 'create tests'",
50+
"test": "vitest run",
5151
"postinstall": "husky install",
5252
"postpublish": "pinst --enable"
5353
},
@@ -64,6 +64,7 @@
6464
"devDependencies": {
6565
"@nuxt/module-builder": "^0.1.7",
6666
"@nuxt/schema": "3.0.0-rc.4",
67+
"@nuxt/test-utils": "3.0.0-rc.4",
6768
"@nuxtjs/eslint-config-typescript": "^10.0.0",
6869
"@release-it/conventional-changelog": "^5.0.0",
6970
"@types/node": "^18.0.0",

‎pnpm-lock.yaml‎

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/e2e/ssr.spec.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* @vitest-environment node */
2+
import{fileURLToPath}from'node:url'
3+
import{setup}from'@nuxt/test-utils'
4+
import{describe,expect,it}from'vitest'
5+
6+
describe('nuxt ionic',async()=>{
7+
awaitsetup({
8+
server: true,
9+
rootDir: fileURLToPath(newURL('../../playground',import.meta.url)),
10+
})
11+
12+
it('renders web components',async()=>{
13+
consthtml=await$fetch('/')
14+
expect(html).toContain(
15+
'<ion-app><!--[--><ion-router-outlet></ion-router-outlet><!--]--></ion-app>'
16+
)
17+
})
18+
19+
it('renders correct viewport tags',async()=>{
20+
consthtml=await$fetch('/')
21+
expect(html).toContain(
22+
'<meta name="viewport" content="viewport-fit: cover, width: device-width, initial-scale: 1.0, minimum-scale: 1.0, maximum-scale: 1.0, user-scalable: no">'
23+
)
24+
})
25+
})

‎vite.config.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import{defineConfig}from'vitest/config'
2+
3+
exportdefaultdefineConfig({
4+
test: {
5+
coverage: {
6+
include: ['src/**/*.ts'],
7+
reporter: ['text','json','html'],
8+
},
9+
},
10+
})

0 commit comments

Comments
 (0)