test(editor): add test setup (#7361)

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
This commit is contained in:
Alexander S. 2024-11-20 05:46:01 +01:00 committed by GitHub
parent d3a0119a42
commit 5190b7fb28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 899 additions and 61 deletions

View file

@ -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
.gitignore vendored
View file

@ -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/

View file

@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';
export default defineConfig({
files: 'out/**/*.spec.js',
});

View file

@ -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, '');
});

View file

@ -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",

File diff suppressed because it is too large Load diff