Skip to content

Commit

Permalink
Workaround the web tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Sep 1, 2023
1 parent 1854c75 commit 0d1c07c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export function activate(context: vscode.ExtensionContext): void {

context.subscriptions.push(
vscode.window.onDidChangeActiveTextEditor((editor) => {
// XXX: This is a workaround for the web test.
// `vscode-test-web` activates the extension before running the tests,
// however, with that activation, this event handler is registered and it conflicts with the tests
// because the selections will be unwillingly overridden by `EmacsEmulator.switchTextEditor()` called from this handler
// when the test code sets the selections for its own purpose.
// Ref: https://github.com/microsoft/vscode-test-web/issues/96
if (globalThis.IS_WEB_TEST) {
return;
}

if (editor == null) {
return;
}
Expand Down
6 changes: 6 additions & 0 deletions src/web/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// imports mocha for the browser, defining the `mocha` global.
require("mocha/mocha");

declare global {
var IS_WEB_TEST: boolean | undefined; // eslint-disable-line no-var
}

globalThis.IS_WEB_TEST = true;

export function run(): Promise<void> {
return new Promise((c, e) => {
mocha.setup({
Expand Down

0 comments on commit 0d1c07c

Please sign in to comment.