Skip to content

Commit 38bb152

Browse files
committed
added test
1 parent 3d0b71b commit 38bb152

File tree

5 files changed

+1136
-19
lines changed

5 files changed

+1136
-19
lines changed

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
"better-phpunit.phpunitBinary": "/usr/src/api/vendor/bin/phpunit",
88
"better-phpunit.xmlConfigFilepath": "/usr/src/api/phpunit.xml",
99
"better-phpunit.docker.paths": {
10-
"/workspace/docker-octane-vue/api": "/usr/src/api"
10+
"/workspace/docker-octane-vue/api": "/usr/src/api",
11+
"${workspaceFolder}": "${workspaceFolder}"
1112
},
1213
"better-phpunit.commandSuffix": "--colors=auto",
1314
"phpunit.phpunit": "/usr/src/api/vendor/bin/phpunit", // Skip to find in common places (vendor, *.phar)
1415
"phpunit.docker.container": "api", // Skip to select from running containers
1516
"phpunit.paths": { // Map paths in remote environments.
16-
"/workspace/docker-octane-vue/api": "/usr/src/api"
17+
"/workspace/docker-octane-vue/api": "/usr/src/api",
18+
"${workspaceFolder}": "${workspaceFolder}"
1719
}
1820
}

client/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"dev": "vite --host",
88
"build": "vue-tsc --noEmit && vite build",
99
"preview": "vite preview",
10-
"test": "echo 0",
10+
"test": "vitest --segfault-retry=3",
11+
"test:clear": "vite test:unit --clearCache",
1112
"pw:test": "npx playwright test"
1213
},
1314
"dependencies": {
@@ -17,8 +18,11 @@
1718
"@playwright/test": "1.31.2",
1819
"@types/node": "18.11.9",
1920
"@vitejs/plugin-vue": "^3.0.0",
21+
"@vue/test-utils": "^2.3.1",
22+
"jsdom": "^21.1.1",
2023
"typescript": "^4.6.4",
2124
"vite": "^3.0.0",
25+
"vitest": "^0.29.2",
2226
"vue-tsc": "^0.38.4"
2327
}
24-
}
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { test, describe, expect } from "vitest";
2+
import { mount } from "@vue/test-utils";
3+
import App from "./../../App.vue";
4+
5+
describe("App", () => {
6+
describe("when mounting", () => {
7+
test("can renderq", () => {
8+
const wrapper = mount(App);
9+
10+
expect(wrapper.html()).toBeTruthy();
11+
expect(wrapper.exists()).toBeTruthy();
12+
});
13+
});
14+
});

client/vite.config.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,42 @@
1-
import { defineConfig } from 'vite'
2-
import vue from '@vitejs/plugin-vue'
1+
import { defineConfig } from "vite";
2+
import vue from "@vitejs/plugin-vue";
3+
import { configDefaults } from "vitest/config";
34

45
// https://vitejs.dev/config/
5-
export default defineConfig(({command, mode}) => {
6-
const processEnvViteValues = Object.keys(process.env).reduce((accum: Record<string, any>, key: string) => {
7-
if (key.startsWith('VITE_APP')) {
8-
accum[key] = `'${process.env[key]}'`;
9-
}
6+
export default defineConfig(({ command, mode }) => {
7+
const processEnvViteValues = Object.keys(process.env).reduce(
8+
(accum: Record<string, any>, key: string) => {
9+
if (key.startsWith("VITE_APP")) {
10+
accum[key] = `'${process.env[key]}'`;
11+
}
1012

11-
return accum;
12-
}, {});
13+
return accum;
14+
},
15+
{}
16+
);
17+
18+
const isCI = process.env.IS_CI === "true";
1319

1420
return {
1521
define: {
16-
...processEnvViteValues
22+
...processEnvViteValues,
23+
},
24+
test: {
25+
deps: {
26+
inline: ["moment"],
27+
},
28+
environment: "jsdom",
29+
exclude: [...configDefaults.exclude, "**/playwright/**"],
30+
mockReset: true,
31+
restoreMocks: true,
32+
testTimeout: isCI ? 30000 : 10000,
33+
hookTimeout: isCI ? 30000 : 10000,
34+
teardownTimeout: isCI ? 30000 : 10000,
35+
reporters: ["verbose"],
1736
},
1837
plugins: [vue()],
1938
server: {
20-
port: 3000
21-
}
22-
}
23-
})
39+
port: 3000,
40+
},
41+
};
42+
});

0 commit comments

Comments
 (0)