Skip to content
This repository was archived by the owner on Jul 4, 2021. It is now read-only.

Commit feda963

Browse files
committed
add e2e test
1 parent dfdfa5a commit feda963

File tree

8 files changed

+95
-374
lines changed

8 files changed

+95
-374
lines changed

e2e/composition.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('composition', () => {
2+
beforeAll(async () => {
3+
await page.goto(`http://localhost:8080/composition/`)
4+
})
5+
6+
test('initial rendering', async () => {
7+
await expect(page).toMatch('言語')
8+
await expect(page).toMatch('こんにちは、世界!')
9+
await expect(page).toMatch('バナナが欲しい?')
10+
await expect(page).toMatch('バナナ 0 個')
11+
})
12+
13+
test('change locale', async () => {
14+
await page.select('#app select', 'en')
15+
await expect(page).toMatch('Language')
16+
await expect(page).toMatch('hello, world!')
17+
})
18+
19+
test('change banana select', async () => {
20+
await page.select('#fruits select', '3')
21+
await expect(page).toMatch('バナナ 3 個')
22+
})
23+
})

e2e/example.test.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

e2e/global.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe(`global`, () => {
2+
beforeAll(async () => {
3+
await page.goto(`http://localhost:8080/global/`)
4+
})
5+
6+
test('initial rendering', async () => {
7+
await expect(page).toMatch('言語')
8+
await expect(page).toMatch('こんにちは、世界!')
9+
})
10+
11+
test('change locale', async () => {
12+
await page.select('#app select', 'en')
13+
await expect(page).toMatch('Language')
14+
await expect(page).toMatch('hello, world!')
15+
})
16+
})

e2e/legacy.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
describe('legacy', () => {
2+
beforeAll(async () => {
3+
await page.goto(`http://localhost:8080/legacy/`)
4+
})
5+
6+
test('initial rendering', async () => {
7+
await expect(page).toMatch('言語')
8+
await expect(page).toMatch('こんにちは、世界!')
9+
await expect(page).toMatch('バナナが欲しい?')
10+
await expect(page).toMatch('バナナ 0 個')
11+
})
12+
13+
test('change locale', async () => {
14+
await page.select('#app select', 'en')
15+
await expect(page).toMatch('Language')
16+
await expect(page).toMatch('hello, world!')
17+
await expect(page).toMatch('no bananas')
18+
})
19+
20+
test('change banana select', async () => {
21+
await page.select('#fruits select', '3')
22+
await expect(page).toMatch('3 bananas')
23+
await page.select('#app select', 'ja')
24+
await expect(page).toMatch('バナナ 3 個')
25+
})
26+
})

examples/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>vite-plugin-vue-i18n example top</title>
6+
</head>
7+
<body></body>
8+
</html>

jest-puppeteer.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module.exports = {
22
server: {
3-
port: 3000,
3+
port: 8080,
44
launchTimeout: 10000,
5-
command: 'serve ./examples -p 8080'
6-
// command: `vite --port 8080`
5+
command: 'npx vite examples --port 8080 -c examples/vite.config.ts'
76
},
87
launch: {
98
dumpio: false,

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"npm-run-all": "^4.1.5",
5252
"opener": "^1.5.2",
5353
"puppeteer": "^3.3.0",
54-
"serve": "^11.3.2",
5554
"shipjs": "^0.23.0",
5655
"ts-jest": "^26.4.0",
5756
"typescript": "^4.1.3",
@@ -81,6 +80,7 @@
8180
"scripts": {
8281
"build": "tsc -p .",
8382
"build:example": "vite build --config ./examples/vite.config.ts --outDir ./examples/dist",
83+
"dev": "vite examples --config ./examples/vite.config.ts",
8484
"dev:legacy": "vite examples/legacy --config ./examples/vite.config.ts",
8585
"dev:global": "vite examples/global --config ./examples/vite.config.ts",
8686
"dev:composition": "vite examples/composition --config ./examples/vite.config.ts",
@@ -96,9 +96,9 @@
9696
"lint:fix": "yarn lint --fix",
9797
"release:prepare": "shipjs prepare",
9898
"release:trigger": "shipjs trigger",
99-
"test": "yarn lint && yarn test:cover",
99+
"test": "yarn lint && yarn test:cover && yarn test:e2e",
100100
"test:cover": "yarn test:unit --coverage",
101-
"test:e2e": "yarn build:example && jest --runInBand --config ./jest.e2e.config.js",
101+
"test:e2e": "jest --runInBand --config ./jest.e2e.config.js",
102102
"test:unit": "jest --env node",
103103
"test:watch": "jest --env node --watch",
104104
"watch": "tsc -p . --watch"

0 commit comments

Comments
 (0)