Skip to content

Commit 4323894

Browse files
feat(test): add end-to-end tests and harness
- Add @vscode/test-electron + Mocha/Chai under test/ with fixtures - Scenarios: diagnostics, language filter, only-on-save, debounce - Scripts: test, test:gui, test:ci ci: verify VSIX packaging and run headless tests - Use vsce ls and vsce package in GitHub Actions - Run npm run test:ci for headless mode docs: add AGENTS.md and CONTRIBUTING.md; update README Testing; add CHANGELOG.md chore(packaging): tighten .vscodeignore; ignore .vscode-test; exclude dependency tests chore(deps): update ESLint/TypeScript toolchain, @types/vscode, Mocha/Chai; refresh lockfile chore(version): bump extension to 0.1.7
1 parent 5d59657 commit 4323894

16 files changed

Lines changed: 1867 additions & 216 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ jobs:
2929
- run: npm ci
3030
- run: npm run compile
3131
- run: npm run lint
32+
- name: Run tests (headless)
33+
shell: bash
34+
run: |
35+
if [ "$RUNNER_OS" = "Linux" ]; then
36+
xvfb-run -a npm run test:ci
37+
else
38+
npm run test:ci
39+
fi
40+
- name: Verify VSIX file list
41+
run: npx --yes vsce ls
42+
- name: Package extension (verification only)
43+
run: npx --yes vsce package --out write-good-linter.vsix

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ out
22
node_modules
33
write-good-linter-*.vsix
44
.DS_Store
5-
test.md
5+
test.md
6+
.vscode-test

.vscodeignore

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
typings/**
33
out/test/**
44
test/**
5-
src/**
6-
**/*.map
7-
.gitignore
8-
tsconfig.json
9-
vsc-extension-quickstart.md
10-
write-good-linter-*.vsix
5+
src/**
6+
**/*.map
7+
.gitignore
8+
tsconfig.json
9+
vsc-extension-quickstart.md
10+
write-good-linter-*.vsix
11+
.vscode-test/**
12+
node_modules/**/test/**
13+
node_modules/**/spec/**
14+
node_modules/**/.travis.yml
15+
node_modules/**/.github/**

AGENTS.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `src/`: TypeScript sources. `extension.ts` wires activation, diagnostics, and settings; `linter.ts` wraps the `write-good` engine.
5+
- `out/`: Compiled JavaScript. Generated by `tsc`; do not edit.
6+
- Config: `package.json` (VS Code contributions, scripts), `tsconfig.json`, `eslint.config.mjs`.
7+
- CI: `.github/workflows/node.js.yml` runs install, compile, and lint on pushes/PRs.
8+
- Workspace: `.vscode/` contains local launch/debug config for Extension Development Host.
9+
10+
## Build, Test, and Development Commands
11+
- `npm ci`: Clean install dependencies (used in CI).
12+
- `npm run compile`: Build TypeScript to `out/`.
13+
- `npm run watch`: Incremental rebuild during development.
14+
- `npm run lint`: Lint `src/**/*.ts` via ESLint.
15+
- Run locally: Open in VS Code and press F5 to launch the Extension Development Host; open a Markdown file to see diagnostics.
16+
- Publish (maintainers): `vsce publish` after `npm run compile` and `npm run lint`.
17+
18+
## Coding Style & Naming Conventions
19+
- Language: TypeScript. Indent 4 spaces; end statements with semicolons.
20+
- Names: `camelCase` for variables/functions, `PascalCase` for types/interfaces, short lowercase filenames (e.g., `extension.ts`).
21+
- Linting: ESLint with `@typescript-eslint`. Enforced rules include `semi: always`; some strict TS rules are relaxed. Run `npm run lint` and fix warnings.
22+
23+
## Testing Guidelines
24+
- End-to-end tests: `@vscode/test-electron` + Mocha/Chai.
25+
- Structure: `test/runTest.ts` (boot), `test/suite/*.test.ts` (specs), fixtures under `test/fixtures/ws/`.
26+
- Commands: `npm test` (headless by default), `npm run test:gui` (shows Dev Host), `npm run test:ci` (forces headless; used in CI).
27+
- Scenarios: diagnostics for Markdown, language filtering, "only lint on save", and debounce behavior.
28+
- Tips: set `write-good.debounce-time-in-ms` to `0` for deterministic checks unless testing debounce; create temp files in tests to avoid cross-test state.
29+
30+
## Commit & Pull Request Guidelines
31+
- Commits: Imperative, concise subject (≤72 chars). Example: `lint: fix debounce handling in onDidChange`.
32+
- Reference issues/PRs when relevant (e.g., `Fixes #123`).
33+
- PRs must: describe intent and approach, list user-facing changes (settings/diagnostics), include before/after screenshots or GIFs when behavior changes, and pass CI (install, compile, lint).
34+
35+
## Configuration Tips
36+
- Key settings forwarded to `write-good`:
37+
- Example `settings.json` snippet:
38+
```json
39+
{
40+
"write-good.languages": ["markdown", "plaintext"],
41+
"write-good.only-lint-on-save": false,
42+
"write-good.debounce-time-in-ms": 200,
43+
"write-good.write-good-config": { "eprime": true }
44+
}
45+
```
46+
- Avoid editing `out/`; make changes in `src/` and rebuild.

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## 0.1.7 — 2025-08-24
6+
- Added end-to-end behavioral tests using `@vscode/test-electron` + Mocha/Chai under `test/`.
7+
- New npm scripts: `test`, `test:gui`, and `test:ci`; CI runs headless tests.
8+
- CI now verifies VSIX contents (`vsce ls`) and builds the package (`vsce package`).
9+
- Documentation: added `AGENTS.md` and `CONTRIBUTING.md`; updated `README.md` with Testing section.
10+
- Packaging: updated `.vscodeignore` to exclude `test/**`, `out/test/**`, `.vscode-test/**`, and dependency `test/spec` files.
11+
- Repo hygiene: added `.vscode-test` to `.gitignore`; removed unused `value-check.js`.
12+
- Dependency updates: bumped ESLint/TypeScript toolchain, `@types/vscode`, Mocha/Chai, etc.
13+

CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing
2+
3+
Thanks for helping improve Write Good Linter! This guide is a quick start. For full contributor guidelines, see Repository Guidelines.
4+
5+
- Read: [Repository Guidelines](./AGENTS.md)
6+
- Publishing steps: [README – Publishing](./README.md#publishing)
7+
8+
## Quick Setup
9+
1. Fork and clone your fork.
10+
2. Install Node.js (LTS or 22.x) and run:
11+
```bash
12+
npm ci
13+
npm run compile # or: npm run watch
14+
```
15+
3. Open the folder in VS Code and press F5 to launch the Extension Development Host. Open a Markdown file to see diagnostics.
16+
17+
## Before You Open a PR
18+
- Ensure code is in `src/` only; do not edit `out/`.
19+
- Run formatting/linting and build:
20+
```bash
21+
npm run lint
22+
npm run compile
23+
```
24+
- Run tests and ensure all specs pass:
25+
```bash
26+
npm test # headless
27+
# or for visual debugging
28+
npm run test:gui
29+
```
30+
- Manually verify behavior in the Dev Host (F5), including settings like `write-good.only-lint-on-save` and `write-good.debounce-time-in-ms`.
31+
32+
## Pull Requests
33+
- Use concise, imperative commit messages (e.g., "fix: debounce scheduling").
34+
- PR description should include: purpose, approach, user-facing changes (settings/diagnostics), and screenshots/GIFs if behavior changes.
35+
- Link related issues (e.g., "Fixes #123").
36+
- CI must pass (install, compile, lint).
37+
38+
## Issues
39+
- When filing a bug, include VS Code version, OS, sample text that reproduces the warning, relevant settings, and logs from the Extension Host if applicable.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ Open up the project in Visual Studio Code and hit F5 to open up a *developement
3030

3131
Check out the [Extending Visual Studio Code](https://code.visualstudio.com/Docs/extensions/overview) documentation for more information.
3232

33+
## Testing
34+
35+
- Install and run: `npm ci` then `npm test`. The first run downloads a VS Code build for testing.
36+
- GUI vs headless:
37+
- Local GUI: `npm run test:gui` opens an Extension Development Host for visual debugging.
38+
- Headless CI: `npm run test:ci` forces headless mode (used in GitHub Actions).
39+
- Layout: tests live in `test/suite/*.test.ts`; fixtures in `test/fixtures/ws`. The runner is `test/runTest.ts` (uses `@vscode/test-electron`).
40+
- Covered scenarios: diagnostics on bad Markdown, language filtering, only‑lint‑on‑save, and debounce behavior.
41+
- Tips: if timing is flaky locally, re‑run `npm test` or use GUI mode to observe behavior. Tests should not modify `out/`.
42+
3343
## Publishing
3444

3545
1. `npm install -g vsce`

0 commit comments

Comments
 (0)