Skip to content

Commit

Permalink
test(editor): add test setup (#7361)
Browse files Browse the repository at this point in the history
Tried it with `vitest`, but there was too many problems with `vscode`
integration.
That why I followed the official guide:
-
https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode
-
https://code.visualstudio.com/api/working-with-extensions/continuous-integration
  • Loading branch information
Sysix authored Nov 20, 2024
1 parent d3a0119 commit 5190b7f
Show file tree
Hide file tree
Showing 6 changed files with 899 additions and 61 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci_vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ jobs:
- name: Lint VSCode
working-directory: editors/vscode
run: pnpm run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@v1
- uses: ./.github/actions/pnpm

- name: Test VSCode
working-directory: editors/vscode
run: xvfb-run -a pnpm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target/
/tasks/compat_data/node_modules/

# vscode
/editors/vscode/.vscode-test/
/editors/vscode/node_modules/
/editors/vscode/icon.png
/editors/vscode/out/
Expand Down
5 changes: 5 additions & 0 deletions editors/vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/**/*.spec.js',
});
12 changes: 12 additions & 0 deletions editors/vscode/client/config.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { strictEqual } from 'assert';
import { ConfigService } from './config.js';

suite('default values on initialization', () => {
const service = new ConfigService();

strictEqual(service.runTrigger, 'onType');
strictEqual(service.enable, true);
strictEqual(service.trace, 'off');
strictEqual(service.configPath, '.eslintrc');
strictEqual(service.binPath, '');
});
6 changes: 5 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@
"install-extension": "code --install-extension oxc_language_server.vsix --force",
"server:build:debug": "cargo build -p oxc_language_server",
"server:build:release": "cross-env CARGO_TARGET_DIR=./target cargo build -p oxc_language_server --release",
"lint": "npx oxlint --config=oxlint.json --tsconfig=tsconfig.json"
"lint": "npx oxlint --config=oxlint.json --tsconfig=tsconfig.json",
"test": "esbuild client/config.spec.ts --bundle --outfile=out/config.spec.js --external:vscode --format=cjs --platform=node --target=node16 --minify --sourcemap && vscode-test"
},
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "^22.0.0",
"@types/vscode": "1.95.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.0.0",
"cross-env": "^7.0.3",
"esbuild": "^0.24.0",
Expand Down
Loading

0 comments on commit 5190b7f

Please sign in to comment.