Skip to content

Commit 2c19e8e

Browse files
HusamElbashirclaude
andcommitted
test: add comprehensive test suite with Jest
Introduce Jest testing framework with complete test coverage for all Vue components and utilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent fc70c52 commit 2c19e8e

28 files changed

+6678
-249
lines changed

.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
root: true,
33
env: {
44
node: true,
5+
jest: true,
56
},
67
extends: [
78
"plugin:vue/vue3-essential",
@@ -31,4 +32,16 @@ module.exports = {
3132
},
3233
],
3334
},
35+
overrides: [
36+
{
37+
files: ["**/__tests__/**/*", "**/*.spec.*", "**/*.test.*"],
38+
env: {
39+
jest: true,
40+
},
41+
rules: {
42+
"@typescript-eslint/no-non-null-assertion": "off",
43+
"@typescript-eslint/no-unused-vars": "off",
44+
},
45+
},
46+
],
3447
};

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,23 @@ yarn-error.log*
2424
dist
2525
docs/.vitepress/dist
2626
docs/.vitepress/cache
27+
28+
# Test coverage files
29+
coverage
30+
.nyc_output
31+
*.lcov
32+
.coverage
33+
34+
# Jest cache
35+
.jest-cache
36+
37+
# Test artifacts
38+
test-results
39+
test-report.xml
40+
junit.xml
41+
42+
# Temporary test files
43+
*.tmp
44+
*.temp
45+
.tmp
46+
.temp

jest.config.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module.exports = {
2+
preset: "ts-jest",
3+
testEnvironment: "jsdom",
4+
moduleFileExtensions: ["js", "ts", "vue", "json"],
5+
transform: {
6+
"^.+\\.vue$": "@vue/vue3-jest",
7+
"^.+\\.tsx?$": [
8+
"ts-jest",
9+
{
10+
tsconfig: {
11+
jsx: "preserve",
12+
esModuleInterop: true,
13+
allowJs: true,
14+
lib: ["es2020", "dom"],
15+
},
16+
},
17+
],
18+
},
19+
setupFilesAfterEnv: ["<rootDir>/tests/setup.ts"],
20+
testMatch: ["<rootDir>/src/**/__tests__/**/*.{js,ts}", "<rootDir>/src/**/*.{spec,test}.{js,ts}"],
21+
collectCoverageFrom: [
22+
"src/**/*.{ts,vue}",
23+
"!src/**/*.d.ts",
24+
"!src/index.ts",
25+
"!src/*/index.ts",
26+
"!src/**/__tests__/**",
27+
"!src/shims-*.ts",
28+
"!src/themes/**",
29+
],
30+
coverageThreshold: {
31+
global: {
32+
branches: 80,
33+
functions: 80,
34+
lines: 80,
35+
statements: 80,
36+
},
37+
},
38+
coverageReporters: ["text", "json", "html", "lcov"],
39+
// Handle CSS imports and path aliases
40+
moduleNameMapper: {
41+
"\\.(css|less|scss|sass)$": "<rootDir>/tests/mocks/styleMock.js",
42+
"^@/(.*)$": "<rootDir>/src/$1",
43+
},
44+
// Ignore certain files
45+
transformIgnorePatterns: ["node_modules/(?!@googlemaps/)"],
46+
testEnvironmentOptions: {
47+
customExportConditions: ["node", "node-addons"],
48+
},
49+
};

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,38 @@
4848
"docs:dev": "vitepress dev docs",
4949
"docs:build": "vitepress build docs",
5050
"docs:serve": "vitepress serve docs",
51-
"release": "standard-version"
51+
"release": "standard-version",
52+
"test": "jest",
53+
"test:watch": "jest --watch",
54+
"test:coverage": "jest --coverage"
5255
},
5356
"dependencies": {
5457
"@googlemaps/js-api-loader": "^1.16.2",
5558
"@googlemaps/markerclusterer": "^2.4.0",
5659
"fast-deep-equal": "^3.1.3"
5760
},
5861
"devDependencies": {
59-
"pnpm": "^8.7.6",
62+
"@googlemaps/jest-mocks": "^2.22.6",
6063
"@types/google.maps": "^3.58.1",
64+
"@types/jest": "^30.0.0",
6165
"@typescript-eslint/eslint-plugin": "^4.33.0",
6266
"@typescript-eslint/parser": "^4.33.0",
6367
"@vitejs/plugin-vue": "^4.3.1",
6468
"@vue/eslint-config-prettier": "^6.0.0",
6569
"@vue/eslint-config-typescript": "^7.0.0",
70+
"@vue/test-utils": "^2.4.6",
71+
"@vue/vue3-jest": "^29.2.6",
6672
"eslint": "^7.32.0",
6773
"eslint-config-prettier": "^8.10.0",
6874
"eslint-plugin-prettier": "^3.4.1",
6975
"eslint-plugin-vue": "^7.20.0",
76+
"jest": "^30.0.4",
77+
"jest-environment-jsdom": "^30.0.4",
78+
"pnpm": "^8.7.6",
7079
"prettier": "^2.8.8",
7180
"rimraf": "^5.0.1",
7281
"standard-version": "^9.5.0",
82+
"ts-jest": "^29.4.0",
7383
"typescript": "^5.1.6",
7484
"vite": "^4.5.3",
7585
"vite-plugin-css-injected-by-js": "^3.2.1",

0 commit comments

Comments
 (0)