Skip to content

Commit 9eec469

Browse files
author
Rachel Macfarlane
committed
Migrate to 'vscode-test', fixes #1430
1 parent ea819cd commit 9eec469

18 files changed

Lines changed: 91 additions & 1128 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ media
338338
.DS_Store
339339
*.vsix
340340
package-lock.json
341+
src/typings/vscode.d.ts
342+
src/typings/vscode.proposed.d.ts
341343

342344
# CI
343345
package.insiders.json

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"request": "launch",
2424
"runtimeExecutable": "${execPath}",
2525
"args": [
26-
"${workspaceFolder}/out/test",
2726
"--extensionDevelopmentPath=${workspaceFolder}",
2827
"--extensionTestsPath=${workspaceFolder}/out/test"
2928
],
29+
"preLaunchTask": "npm: preprocess",
3030
"outFiles": [
3131
"${workspaceFolder}/out/test/**/*.js"
3232
]

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,11 +1175,14 @@
11751175
},
11761176
"scripts": {
11771177
"vscode:prepublish": "webpack --env.production",
1178-
"postinstall": "node ./node_modules/vscode/bin/install",
1178+
"postinstall": "cd src/typings && npx vscode-dts master && npx vscode-dts dev master",
11791179
"compile": "tsc -p ./",
11801180
"clean": "rm -r out/ media/ preview-src/dist/",
11811181
"watch": "webpack --watch --env.development",
1182-
"test": "./test.sh"
1182+
"test": "yarn run preprocess && node ./out/test/runTests.js",
1183+
"preprocess": "yarn run compile && yarn run preprocess-gql && yarn run preprocess-svg",
1184+
"preprocess-gql": "scripts/preprocess-gql --in src/github/queries.gql --out out/github/queries.gql",
1185+
"preprocess-svg": "scripts/preprocess-svg --in resources/ --out preview-src/dist/resources"
11831186
},
11841187
"devDependencies": {
11851188
"@types/chai": "^4.1.4",
@@ -1190,7 +1193,7 @@
11901193
"@types/lru-cache": "^5.1.0",
11911194
"@types/marked": "^0.7.2",
11921195
"@types/mocha": "^5.2.2",
1193-
"@types/node": "*",
1196+
"@types/node": "^12.0.0",
11941197
"@types/node-fetch": "^2.1.4",
11951198
"@types/query-string": "^6.1.1",
11961199
"@types/react": "^16.8.4",
@@ -1220,8 +1223,8 @@
12201223
"tslint": "^6.0.0",
12211224
"tslint-webpack-plugin": "^2.1.0",
12221225
"tty": "1.0.1",
1223-
"typescript": "^3.8.2",
1224-
"vscode": "^1.1.36",
1226+
"typescript": "^3.8.3",
1227+
"vscode-test": "^1.3.0",
12251228
"webpack": "^4.41.6",
12261229
"webpack-cli": "^3.3.11"
12271230
},
@@ -1254,4 +1257,4 @@
12541257
"webpack/**/tar": "^4.4.2"
12551258
},
12561259
"license": "MIT"
1257-
}
1260+
}

preview-src/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
],
2020
},
2121
"include": [
22-
"./**/*"
22+
"./**/*",
23+
"../src/typings/*"
2324
]
2425
}

src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { TreeNode } from './view/treeNodes/treeNode';
3131
import { CredentialStore, GitHub } from './github/credentials';
3232
import { GitAPI } from './typings/git';
3333

34-
const _onDidUpdatePR = new vscode.EventEmitter<PullRequest | undefined>();
35-
export const onDidUpdatePR: vscode.Event<PullRequest | undefined> = _onDidUpdatePR.event;
34+
const _onDidUpdatePR = new vscode.EventEmitter<PullRequest | void>();
35+
export const onDidUpdatePR: vscode.Event<PullRequest | void> = _onDidUpdatePR.event;
3636

3737
function ensurePR(prManager: PullRequestManager, pr?: PRNode | PullRequestModel): PullRequestModel {
3838
// If the command is called from the command palette, no arguments are passed.

src/github/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function createVSCodeCommentThread(thread: ThreadData, commentController:
2727
[]
2828
);
2929

30-
vscodeThread.threadId = thread.threadId;
30+
(vscodeThread as GHPRCommentThread).threadId = thread.threadId;
3131

3232
vscodeThread.comments = thread.comments.map(comment => new GHPRComment(comment, vscodeThread as GHPRCommentThread));
3333

src/issues/issuesView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { StateManager } from './stateManager';
1010
import { Resource } from '../common/resources';
1111

1212
export class IssuesTreeData implements vscode.TreeDataProvider<IssueModel | MilestoneModel | vscode.TreeItem> {
13-
private _onDidChangeTreeData: vscode.EventEmitter<IssueModel | MilestoneModel | null | undefined> = new vscode.EventEmitter();
14-
public onDidChangeTreeData: vscode.Event<IssueModel | MilestoneModel | null | undefined> = this._onDidChangeTreeData.event;
13+
private _onDidChangeTreeData: vscode.EventEmitter<IssueModel | MilestoneModel | null | undefined | void> = new vscode.EventEmitter();
14+
public onDidChangeTreeData: vscode.Event<IssueModel | MilestoneModel | null | undefined | void> = this._onDidChangeTreeData.event;
1515
private firstLabel: string | undefined;
1616

1717
constructor(private stateManager: StateManager, context: vscode.ExtensionContext) {

src/test/mocks/mockExtensionContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import * as temp from 'temp';
3-
import { ExtensionContext } from 'vscode';
3+
import { ExtensionContext, Uri } from 'vscode';
44

55
import { InMemoryMemento } from './inMemoryMemento';
66

@@ -14,6 +14,9 @@ export class MockExtensionContext implements ExtensionContext {
1414
storagePath: string;
1515
globalStoragePath: string;
1616
logPath: string;
17+
extensionUri: Uri;
18+
environmentVariableCollection: any;
19+
extensionMode: any;
1720

1821
constructor() {
1922
this.storagePath = temp.mkdirSync('storage-path');

src/test/runTests.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as path from 'path';
2+
import { runTests } from 'vscode-test';
3+
4+
async function go() {
5+
try {
6+
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
7+
const extensionTestsPath = path.resolve(__dirname, './');
8+
9+
/**
10+
* Basic usage
11+
*/
12+
await runTests({
13+
version: 'insiders',
14+
extensionDevelopmentPath,
15+
extensionTestsPath,
16+
launchArgs: [
17+
'--disable-extensions'
18+
]
19+
});
20+
} catch (e) {
21+
console.log(e);
22+
}
23+
}
24+
25+
go();

src/typings/ref.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
/// <reference path='./vscode.d.ts'/>
67
/// <reference path='./vscode.proposed.d.ts'/>
78
/// <reference path='./git-credential-node.d.ts'/>
89
/// <reference path='./graphql.d.ts'/>

0 commit comments

Comments
 (0)