-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b94f978
commit e0144bc
Showing
11 changed files
with
129 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
node_modules | ||
*.vsix | ||
out/ | ||
.vscode-test |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as path from "path"; | ||
|
||
import { runTests } from "@vscode/test-electron"; | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, "../../"); | ||
|
||
// The path to test runner | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, "./suite/index"); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionDevelopmentPath, extensionTestsPath }); | ||
} catch (err) { | ||
console.error("Failed to run tests"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as vscode from "vscode"; | ||
|
||
test("Sample test", () => { | ||
vscode.window.showInformationMessage("Start all tests."); | ||
|
||
expect([1, 2, 3].indexOf(5)).toEqual(-1); | ||
expect([1, 2, 3].indexOf(0)).toEqual(-1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { runCLI } from "jest"; | ||
|
||
interface ITestRunner { | ||
run(testsRoot: string, clb: (error?: Error, failures?: number) => void): void; | ||
} | ||
const path = require("path"); | ||
|
||
const jestTestRunnerForVSCodeE2E: ITestRunner = { | ||
run( | ||
testsRoot: string, | ||
reportTestResults: (error?: Error, failures?: number) => void | ||
): void { | ||
const projectRootPath = process.cwd(); | ||
const config = path.join(projectRootPath, "jest.e2e.config.js"); | ||
|
||
runCLI({ config } as any, [projectRootPath]) | ||
.then((jestCliCallResult) => { | ||
jestCliCallResult.results.testResults.forEach((testResult) => { | ||
testResult.testResults | ||
.filter((assertionResult) => assertionResult.status === "passed") | ||
.forEach(({ ancestorTitles, title, status }) => { | ||
console.info(` ● ${ancestorTitles} > ${title} (${status})`); | ||
}); | ||
}); | ||
|
||
jestCliCallResult.results.testResults.forEach((testResult) => { | ||
if (testResult.failureMessage) { | ||
console.error(testResult.failureMessage); | ||
} | ||
}); | ||
|
||
reportTestResults(undefined, jestCliCallResult.results.numFailedTests); | ||
}) | ||
.catch((errorCaughtByJestRunner) => { | ||
reportTestResults(errorCaughtByJestRunner, 0); | ||
}); | ||
}, | ||
}; | ||
|
||
module.exports = jestTestRunnerForVSCodeE2E; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820 | ||
const NodeEnvironment = require("jest-environment-node"); | ||
const vscode = require("vscode"); | ||
|
||
class VsCodeEnvironment extends NodeEnvironment { | ||
async setup() { | ||
await super.setup(); | ||
this.global.vscode = vscode; | ||
} | ||
|
||
async teardown() { | ||
this.global.vscode = {}; | ||
await super.teardown(); | ||
} | ||
|
||
runScript(script) { | ||
return super.runScript(script); | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// see https://github.com/microsoft/vscode-test/issues/37#issuecomment-700167820 | ||
module.exports = global.vscode; |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
moduleFileExtensions: ["js"], | ||
testMatch: ["<rootDir>/out/it/suite/**.test.js"], | ||
testEnvironment: "./it/vscode-environment.js", | ||
verbose: true, | ||
moduleNameMapper: { | ||
vscode: path.join(__dirname, "it", "vscode.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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.