-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from microsoft/octref/vscode-test
Update vscode-test & @types/vscode usage for microsoft/vscode#71048
- Loading branch information
Showing
14 changed files
with
193 additions
and
123 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
24 changes: 0 additions & 24 deletions
24
generators/app/templates/ext-command-js/test/extension.test.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
const path = require('path'); | ||
|
||
const { runTests } = require('vscode-test'); | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionPath = path.resolve(__dirname, '../../'); | ||
|
||
// The path to test runner | ||
// Passed to --extensionTestsPath | ||
const testRunnerPath = path.resolve(__dirname, './suite'); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionPath, testRunnerPath }); | ||
} catch (err) { | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
18 changes: 18 additions & 0 deletions
18
generators/app/templates/ext-command-js/test/suite/extension.test.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const assert = require('assert'); | ||
const { before } = require('mocha'); | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
const vscode = require('vscode'); | ||
// const myExtension = require('../extension'); | ||
|
||
suite('Extension Test Suite', () => { | ||
before(() => { | ||
vscode.window.showInformationMessage('Start all tests.'); | ||
}); | ||
|
||
test('Sample test', () => { | ||
assert.equal(-1, [1, 2, 3].indexOf(5)); | ||
assert.equal(-1, [1, 2, 3].indexOf(0)); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
generators/app/templates/ext-command-js/test/suite/index.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const path = require('path'); | ||
const Mocha = require('mocha'); | ||
const glob = require('glob'); | ||
|
||
function run(testsRoot, cb) { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd' | ||
}); | ||
// Use any mocha API | ||
mocha.useColors(true); | ||
|
||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => cb(null, failures)); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
run | ||
}; |
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
22 changes: 0 additions & 22 deletions
22
generators/app/templates/ext-command-ts/src/test/extension.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
generators/app/templates/ext-command-ts/src/test/runTest.ts
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'; | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionPath = path.resolve(__dirname, '../../'); | ||
|
||
// The path to test runner | ||
// Passed to --extensionTestsPath | ||
const testRunnerPath = path.resolve(__dirname, './suite'); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionPath, testRunnerPath }); | ||
} catch (err) { | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
18 changes: 18 additions & 0 deletions
18
generators/app/templates/ext-command-ts/src/test/suite/extension.test.ts
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,18 @@ | ||
import * as assert from 'assert'; | ||
import { before } from 'mocha'; | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode'; | ||
// import * as myExtension from '../extension'; | ||
|
||
suite('Extension Test Suite', () => { | ||
before(() => { | ||
vscode.window.showInformationMessage('Start all tests.'); | ||
}); | ||
|
||
test('Sample test', () => { | ||
assert.equal(-1, [1, 2, 3].indexOf(5)); | ||
assert.equal(-1, [1, 2, 3].indexOf(0)); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
generators/app/templates/ext-command-ts/src/test/suite/index.ts
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,28 @@ | ||
import * as path from 'path'; | ||
import * as Mocha from 'mocha'; | ||
import * as glob from 'glob'; | ||
|
||
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd' | ||
}); | ||
// Use any mocha API | ||
mocha.useColors(true); | ||
|
||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => cb(null, failures)); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.