-
Notifications
You must be signed in to change notification settings - Fork 697
/
Copy pathvsCodeEnvironment.ts
30 lines (25 loc) · 1.07 KB
/
vsCodeEnvironment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { JestEnvironmentConfig, EnvironmentContext } from '@jest/environment';
import { TestEnvironment } from 'jest-environment-node';
/**
* Defines a custom jest environment that allows us to replace vscode module imports with the
* instance from the vscode extension in the test runner.
*/
class VsCodeEnvironment extends TestEnvironment {
constructor(config: JestEnvironmentConfig, context: EnvironmentContext) {
super(config, context);
}
public async setup() {
await super.setup();
this.global.vscode = vscode;
}
public async teardown() {
this.global.vscode = {};
return await super.teardown();
}
}
module.exports = VsCodeEnvironment;