-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Upgrade jest and fix environment
- Loading branch information
Showing
4 changed files
with
432 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 16 additions & 3 deletions
19
src/test/env/ExtendedVscodeEnvironment.js → src/test/env/VsCodeEnvironment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
const VscodeEnvironment = require('jest-environment-vscode'); | ||
const { TestEnvironment } = require('jest-environment-node'); | ||
const vscode = require('vscode'); | ||
|
||
class ExtendedVscodeEnvironment extends VscodeEnvironment { | ||
class VsCodeEnvironment extends TestEnvironment { | ||
async setup() { | ||
await super.setup(); | ||
|
||
this.global.vscode = vscode; | ||
|
||
// Expose RegExp otherwise document.getWordRangeAtPosition won't work as supposed. | ||
// Implementation of getWordRangeAtPosition uses "instanceof RegExp" which returns false | ||
// due to Jest running tests in the different vm context. | ||
// See https://github.com/nodejs/node-v0.x-archive/issues/1277. | ||
this.global.RegExp = RegExp; | ||
} | ||
|
||
async teardown() { | ||
this.global.vscode = {}; | ||
await super.teardown(); | ||
} | ||
|
||
runScript(script) { | ||
return super.runScript(script); | ||
} | ||
} | ||
|
||
module.exports = ExtendedVscodeEnvironment; | ||
module.exports = VsCodeEnvironment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.