Skip to content

Commit 66e5e7d

Browse files
committed
test: Introduces Vitest for unit tests
Signed-off-by: Tyler Smalley <[email protected]>
1 parent 5310782 commit 66e5e7d

File tree

6 files changed

+474
-3
lines changed

6 files changed

+474
-3
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
key: yarn-cache
2727
- name: Install dependencies
2828
run: tool/yarn install --frozen-lockfile --prefer-offline
29+
- name: Unit tests
30+
run: tool/yarn test
2931
- name: Lint
3032
run: tool/yarn lint
3133
- name: Typescript

.vscode/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
},
1616
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
1717
"preLaunchTask": "${defaultBuildTask}"
18+
},
19+
{
20+
"type": "node",
21+
"request": "launch",
22+
"name": "Debug Current Test File",
23+
"autoAttachChildProcesses": true,
24+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
25+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
26+
"args": ["run", "${relativeFile}"],
27+
"smartStep": true,
28+
"console": "integratedTerminal"
1829
}
1930
]
2031
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
"package": "vsce package --allow-star-activation",
315315
"precommit": "lint-staged",
316316
"prepare": "husky install",
317+
"test": "vitest --passWithNoTests",
317318
"vscode:prepublish": "(yarn run bundle-js & pid1=$!; yarn run bundle-go & pid2=$!; wait $pid1 || exit 1; wait $pid2 || exit 1)",
318319
"watch": "webpack serve"
319320
},
@@ -351,6 +352,7 @@
351352
"ts-loader": "^9.4.4",
352353
"typescript": "^5.1.6",
353354
"utf-8-validate": "^6.0.3",
355+
"vitest": "^.33.0",
354356
"vscode-jsonrpc": "^8.1.0",
355357
"webpack": "^5.88.2",
356358
"webpack-cli": "^5.1.4",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
"noFallthroughCasesInSwitch": true,
1313
"noUnusedParameters": true
1414
},
15-
"exclude": ["node_modules", ".vscode-test", "src/webviews"]
15+
"exclude": ["node_modules", ".vscode-test", "src/webviews", "vitest.config.ts"]
1616
}

vitest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { configDefaults, defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
exclude: [...configDefaults.exclude, '**/out/**'],
6+
},
7+
});

0 commit comments

Comments
 (0)