Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci_vscode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: ./.github/actions/pnpm

- name: Build
working-directory: editors/vscode
run: pnpm run build

- name: Test VSCode
working-directory: editors/vscode
run: xvfb-run -a pnpm run test
10 changes: 9 additions & 1 deletion editors/vscode/client/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepStrictEqual, strictEqual } from 'assert';
import { workspace } from 'vscode';
import { Uri, workspace, WorkspaceEdit } from 'vscode';
import { Config } from './Config.js';

suite('Config', () => {
Expand All @@ -10,6 +10,14 @@ suite('Config', () => {
await Promise.all(keys.map(key => wsConfig.update(key, undefined)));
});

suiteTeardown(async () => {
const WORKSPACE_DIR = workspace.workspaceFolders![0].uri.toString();
const file = Uri.parse(WORKSPACE_DIR + '/.vscode/settings.json');
const edit = new WorkspaceEdit();
edit.deleteFile(file);
await workspace.applyEdit(edit);
});

test('default values on initialization', () => {
const config = new Config();

Expand Down
56 changes: 56 additions & 0 deletions editors/vscode/client/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { deepStrictEqual } from 'assert';
import { commands, extensions } from 'vscode';

// const WORKSPACE_DIR = workspace.workspaceFolders![0].uri.toString();
// const filePath = WORKSPACE_DIR + '/debugger.js';
// const fileUri = Uri.parse(filePath);

suite('commands', () => {
setup(async () => {
const ext = extensions.getExtension('oxc.oxc-vscode')!;
await ext.activate();
});

// suiteTeardown(async () => {
// const edit = new WorkspaceEdit();
// edit.deleteFile(fileUri);
// await workspace.applyEdit(edit);
// });

test('listed commands', async () => {
const oxcCommands = (await commands.getCommands(true)).filter(x => x.startsWith('oxc.'));

deepStrictEqual([
'oxc.restartServer',
'oxc.showOutputChannel',
'oxc.toggleEnable',
'oxc.applyAllFixesFile',
'oxc.fixAll',
], oxcCommands);
});

// ToDo: check why this is not working,
// even with .gitignore deleted in th test_workspace
//
// test('oxc.fixAll', async () => {
// const edit = new WorkspaceEdit();
// edit.createFile(fileUri, {
// contents: Buffer.from('/* 😊 */debugger;'),
// });
//
// await workspace.applyEdit(edit);
// await window.showTextDocument(fileUri);
// await sleep(500);
// await commands.executeCommand('oxc.fixAll', {
// uri: fileUri.toString(),
// });
// await workspace.saveAll();
// await sleep(1000);
//
// const content = await readFile(fileUri.fsPath, {
// encoding: 'utf8',
// });
//
// strictEqual(content, '/* 😊 */');
// });
});
2 changes: 1 addition & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"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",
"test": "esbuild client/config.spec.ts --bundle --outfile=out/config.spec.js --external:vscode --format=cjs --platform=node --target=node16 --minify --sourcemap && vscode-test",
"test": "esbuild client/*.spec.ts --bundle --outdir=out --external:vscode --format=cjs --platform=node --target=node16 --minify --sourcemap && vscode-test",
"type-check": "tsc --noEmit"
},
"devDependencies": {
Expand Down