Skip to content

Commit ba76e74

Browse files
committed
Add comprehensive test coverage and refactor extension into modular structure.
1 parent 3644522 commit ba76e74

22 files changed

+3587
-666
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
test:
1111
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
12-
name: Linter
12+
name: Test
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 10
1515
steps:
@@ -30,3 +30,6 @@ jobs:
3030

3131
- name: Run the build
3232
run: npm run build
33+
34+
- name: Run tests
35+
run: xvfb-run -a npm test

.vscode-test.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'out/test/suite/**/*.test.js',
5+
version: 'stable',
6+
launchArgs: ['--disable-extensions'],
7+
mocha: {
8+
ui: 'tdd',
9+
timeout: 20000
10+
}
11+
});

.vscode/launch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"request": "launch",
99
"runtimeExecutable": "${execPath}",
1010
"args": [
11-
"--extensionDevelopmentPath=${workspaceFolder}"
11+
"--extensionDevelopmentPath=${workspaceFolder}",
12+
"${workspaceFolder}/.vscode/sample.php"
1213
],
1314
"outFiles": [
14-
"${workspaceFolder}/dist/**/*.js"
15+
"${workspaceFolder}/out/**/*.js"
1516
],
1617
"preLaunchTask": "npm: build"
1718
}

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
**/*.ts
77
images/screenshot*
88
src/**
9+
out/test/**
910
test/**
11+
.vscode-test.mjs
1012
tsconfig.json

CONTRIBUTING.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,26 @@ You can clone this repo and then run the extension in development mode in VS Cod
2222

2323
2. Open the directory in VS Code and launch the extension from the `Run` panel.
2424

25-
The extension source code can be found in `src/extension.ts`.
25+
The extension source code is in the `src/` directory with the following structure:
26+
- `src/extension.ts` - Entry point
27+
- `src/providers/` - Completion and hover providers
28+
- `src/utils/` - Helper functions for hooks, types, and matchers
29+
- `src/generators/` - Code generation for docblocks and snippets
30+
- `src/types/` - TypeScript interfaces
31+
32+
### Running Tests
33+
34+
Run the test suite:
35+
36+
```bash
37+
npm test
38+
```
39+
40+
This runs all tests in a headless VS Code instance. Tests are located in `src/test/suite/` and cover:
41+
- Hook completion (actions and filters)
42+
- Callback completion (closures, arrow functions, utility functions)
43+
- Hover provider functionality
44+
- Edge cases and various hook functions
2645

2746
## Releasing a New Version
2847

@@ -31,6 +50,7 @@ These are the steps to take to release a new version of the extension (for contr
3150
### Prior to Release
3251

3352
1. Check [the milestone on GitHub](https://github.com/wp-hooks/vscode-wordpress-hooks/milestones) for open issues or PRs. Fix or reassign as necessary.
53+
1. Run `npm test` to ensure all tests pass.
3454
1. Ensure `readme.md` contains an up to date description, FAQs, screenshots, etc.
3555
1. Ensure `.vscodeignore` is up to date with all files that shouldn't be part of the build.
3656
1. Prepare a changelog for [the Releases page on GitHub](https://github.com/wp-hooks/vscode-wordpress-hooks/releases).

0 commit comments

Comments
 (0)