From 1bee25522a8339a46ea14c7f01c603fd39e88406 Mon Sep 17 00:00:00 2001
From: VXDguy <74228808+vxdguy@users.noreply.github.com>
Date: Wed, 13 Apr 2022 04:47:34 -0500
Subject: [PATCH 1/9] feat(html): using live preview extension
- removed webview, it wasn't working for css
+ replaced with Live Preview
---
src/extension/gutters.ts | 24 +++++++++++++++++---
src/extension/webview.ts | 48 ----------------------------------------
2 files changed, 21 insertions(+), 51 deletions(-)
delete mode 100644 src/extension/webview.ts
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 52feef4..a73ba11 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -3,7 +3,8 @@ import { Coverage } from "../coverage-system/coverage";
import { CoverageService } from "../coverage-system/coverageservice";
import { Config } from "./config";
import { StatusBarToggler } from "./statusbartoggler";
-import { PreviewPanel } from "./webview";
+import * as vscode from 'vscode';
+import { normalizeFileName } from "../helpers";
export class Gutters {
private coverage: Coverage;
@@ -38,8 +39,25 @@ export class Gutters {
window.showWarningMessage("Could not show Coverage Report file!");
return;
}
- const previewPanel = new PreviewPanel(pickedReport);
- await previewPanel.createWebView();
+
+ // TODO: Figure out how to convert pickedReport to a relative path+filename
+ // My js/ts experience are coming up on 72 hours of coding. I'm not sure how to do this.
+ const livePreview = vscode.extensions.getExtension('ms-vscode.live-server');
+ // is the ext loaded and ready?
+ if (livePreview?.isActive === false) {
+ livePreview.activate().then(
+ function () {
+ console.log("Extension activated");
+ vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ },
+ function () {
+ console.log("Extension activation failed");
+ }
+ );
+ } else {
+ vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ }
+
} catch (error: any) {
this.handleError("previewCoverageReport", error);
}
diff --git a/src/extension/webview.ts b/src/extension/webview.ts
deleted file mode 100644
index 092c62e..0000000
--- a/src/extension/webview.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import {
- Uri,
- ViewColumn,
- WebviewPanel,
- window,
- workspace,
-} from "vscode";
-
-export class PreviewPanel {
- private pickedReport: string;
- private previewPanel: WebviewPanel | undefined;
-
- constructor(pickedReport: string) {
- this.pickedReport = pickedReport;
- }
-
- public async createWebView() {
- // Read in the report html and send it to the webview
- const reportUri = Uri.file(this.pickedReport);
- const reportHtml = await workspace.openTextDocument(reportUri);
- const reportHtmlWithPolicy = this.addContentSecurityPolicy(reportHtml.getText());
-
- // Construct the webview panel for the coverage report to live in
- this.previewPanel = window.createWebviewPanel(
- "coverageReportPreview",
- "Preview Coverage Report",
- ViewColumn.One,
- );
-
- this.previewPanel.webview.html = reportHtmlWithPolicy;
- }
-
- public dispose() {
- if (this.previewPanel) { this.previewPanel.dispose(); }
- }
-
- public addContentSecurityPolicy(text: string): string {
- const securityPolicyHeader = `\n`;
- let tag = text.indexOf("
Date: Wed, 13 Apr 2022 12:33:37 -0500
Subject: [PATCH 2/9] fix(htlmview): replaced webview with Live Preview
Pulled out webview implementation,
Replaced with Microsoft's Live Preview.
Updated README.md with notice of dependency on Live Preview extension.
---
README.md | 3 ++
src/extension/gutters.ts | 10 +++---
test/extension/webview.test.ts | 60 ----------------------------------
3 files changed, 9 insertions(+), 64 deletions(-)
delete mode 100644 test/extension/webview.test.ts
diff --git a/README.md b/README.md
index cdb6f4c..e25aa80 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,9 @@ See [examples directory](example) on how to setup a project.
## Requirements
- vscode 1.27.0 and up
- macos, linux or windows
+- Requires Live Preview extension
+ - vscode extension id: ms-vscode.live-server
+ - v0.2.12 or higher
## Extension Settings
See extension setting options in IDE.
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index a73ba11..61daa64 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -4,7 +4,6 @@ import { CoverageService } from "../coverage-system/coverageservice";
import { Config } from "./config";
import { StatusBarToggler } from "./statusbartoggler";
import * as vscode from 'vscode';
-import { normalizeFileName } from "../helpers";
export class Gutters {
private coverage: Coverage;
@@ -33,15 +32,18 @@ export class Gutters {
const coverageReports = await this.coverage.findReports();
const pickedReport = await this.coverage.pickFile(
coverageReports,
- "Choose a Coverage Report to preview.",
+ "Choose a Coverage Report to pfffreview.",
);
if (!pickedReport) {
window.showWarningMessage("Could not show Coverage Report file!");
return;
}
- // TODO: Figure out how to convert pickedReport to a relative path+filename
- // My js/ts experience are coming up on 72 hours of coding. I'm not sure how to do this.
+ // TODO: Figure out how to convert pickedReport to a workspace relative filename.
+ // Right now the livePreview.start.internalPreview.atFile is called with "false" as
+ // the second parameter. This means that the file specified has an absolute path.
+ // See the Live Preview extension source code:
+ // https://github.com/microsoft/vscode-livepreview/blob/3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
const livePreview = vscode.extensions.getExtension('ms-vscode.live-server');
// is the ext loaded and ready?
if (livePreview?.isActive === false) {
diff --git a/test/extension/webview.test.ts b/test/extension/webview.test.ts
deleted file mode 100644
index 85af858..0000000
--- a/test/extension/webview.test.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import { expect } from "chai";
-import { PreviewPanel } from "../../src/extension/webview";
-
-suite("Preview panel Tests", () => {
- test("Should append content security policy to preview HTML when head tag present @unit", () => {
- const reportWithHeadTag = `
-
-
-
- Code coverage report for node/
-
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithHeadTag);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithHeadTag);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-
- test("Should append content security policy to preview HTML when meta tag present @unit", () => {
- const reportWithMetaTag = `
-
-
-
-
- Code coverage report for node/
-
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithMetaTag);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithMetaTag);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-
- test("Should append content security policy to preview HTML without head nor meta tags @unit", () => {
- const reportWithoutTags = `
-
-
- Code coverage report for node/
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithoutTags);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithoutTags);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-});
From 2db69fd5d1419f3ff3c9f102cd3e74ca29b54d99 Mon Sep 17 00:00:00 2001
From: Dan Melton <74228808+vxdguy@users.noreply.github.com>
Date: Wed, 13 Apr 2022 17:06:07 -0500
Subject: [PATCH 3/9] feat(html): using live preview extension
- removed webview, it wasn't working for css
+ replaced with Live Preview
fix(htlmview): replaced webview with Live Preview
Pulled out webview implementation,
Replaced with Microsoft's Live Preview.
Updated README.md with notice of dependency on Live Preview extension.
---
README.md | 3 ++
src/extension/gutters.ts | 28 +++++++++++++---
src/extension/webview.ts | 48 ---------------------------
test/extension/webview.test.ts | 60 ----------------------------------
4 files changed, 27 insertions(+), 112 deletions(-)
delete mode 100644 src/extension/webview.ts
delete mode 100644 test/extension/webview.test.ts
diff --git a/README.md b/README.md
index cdb6f4c..e25aa80 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,9 @@ See [examples directory](example) on how to setup a project.
## Requirements
- vscode 1.27.0 and up
- macos, linux or windows
+- Requires Live Preview extension
+ - vscode extension id: ms-vscode.live-server
+ - v0.2.12 or higher
## Extension Settings
See extension setting options in IDE.
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 52feef4..61daa64 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -3,7 +3,7 @@ import { Coverage } from "../coverage-system/coverage";
import { CoverageService } from "../coverage-system/coverageservice";
import { Config } from "./config";
import { StatusBarToggler } from "./statusbartoggler";
-import { PreviewPanel } from "./webview";
+import * as vscode from 'vscode';
export class Gutters {
private coverage: Coverage;
@@ -32,14 +32,34 @@ export class Gutters {
const coverageReports = await this.coverage.findReports();
const pickedReport = await this.coverage.pickFile(
coverageReports,
- "Choose a Coverage Report to preview.",
+ "Choose a Coverage Report to pfffreview.",
);
if (!pickedReport) {
window.showWarningMessage("Could not show Coverage Report file!");
return;
}
- const previewPanel = new PreviewPanel(pickedReport);
- await previewPanel.createWebView();
+
+ // TODO: Figure out how to convert pickedReport to a workspace relative filename.
+ // Right now the livePreview.start.internalPreview.atFile is called with "false" as
+ // the second parameter. This means that the file specified has an absolute path.
+ // See the Live Preview extension source code:
+ // https://github.com/microsoft/vscode-livepreview/blob/3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
+ const livePreview = vscode.extensions.getExtension('ms-vscode.live-server');
+ // is the ext loaded and ready?
+ if (livePreview?.isActive === false) {
+ livePreview.activate().then(
+ function () {
+ console.log("Extension activated");
+ vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ },
+ function () {
+ console.log("Extension activation failed");
+ }
+ );
+ } else {
+ vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ }
+
} catch (error: any) {
this.handleError("previewCoverageReport", error);
}
diff --git a/src/extension/webview.ts b/src/extension/webview.ts
deleted file mode 100644
index 092c62e..0000000
--- a/src/extension/webview.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import {
- Uri,
- ViewColumn,
- WebviewPanel,
- window,
- workspace,
-} from "vscode";
-
-export class PreviewPanel {
- private pickedReport: string;
- private previewPanel: WebviewPanel | undefined;
-
- constructor(pickedReport: string) {
- this.pickedReport = pickedReport;
- }
-
- public async createWebView() {
- // Read in the report html and send it to the webview
- const reportUri = Uri.file(this.pickedReport);
- const reportHtml = await workspace.openTextDocument(reportUri);
- const reportHtmlWithPolicy = this.addContentSecurityPolicy(reportHtml.getText());
-
- // Construct the webview panel for the coverage report to live in
- this.previewPanel = window.createWebviewPanel(
- "coverageReportPreview",
- "Preview Coverage Report",
- ViewColumn.One,
- );
-
- this.previewPanel.webview.html = reportHtmlWithPolicy;
- }
-
- public dispose() {
- if (this.previewPanel) { this.previewPanel.dispose(); }
- }
-
- public addContentSecurityPolicy(text: string): string {
- const securityPolicyHeader = `\n`;
- let tag = text.indexOf(" {
- test("Should append content security policy to preview HTML when head tag present @unit", () => {
- const reportWithHeadTag = `
-
-
-
- Code coverage report for node/
-
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithHeadTag);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithHeadTag);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-
- test("Should append content security policy to preview HTML when meta tag present @unit", () => {
- const reportWithMetaTag = `
-
-
-
-
- Code coverage report for node/
-
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithMetaTag);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithMetaTag);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-
- test("Should append content security policy to preview HTML without head nor meta tags @unit", () => {
- const reportWithoutTags = `
-
-
- Code coverage report for node/
-
-
-
- `;
- const previewPanel = new PreviewPanel(reportWithoutTags);
- const securityPolicyHeader = `\n`;
-
- const textIncludesPolicy = previewPanel.addContentSecurityPolicy(reportWithoutTags);
-
- expect(textIncludesPolicy).to.include(securityPolicyHeader);
- });
-});
From 71b04f9e627d97b1d29e9253595522f09f2914e3 Mon Sep 17 00:00:00 2001
From: VXDguy <74228808+vxdguy@users.noreply.github.com>
Date: Wed, 13 Apr 2022 21:56:54 -0500
Subject: [PATCH 4/9] fixed typo
---
src/extension/gutters.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 61daa64..1f62b00 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -32,7 +32,7 @@ export class Gutters {
const coverageReports = await this.coverage.findReports();
const pickedReport = await this.coverage.pickFile(
coverageReports,
- "Choose a Coverage Report to pfffreview.",
+ "Choose a Coverage Report to preview.",
);
if (!pickedReport) {
window.showWarningMessage("Could not show Coverage Report file!");
From a0a34f07e20b2f6b557ee54a50619c0097f0ae3a Mon Sep 17 00:00:00 2001
From: VXDguy <74228808+vxdguy@users.noreply.github.com>
Date: Wed, 13 Apr 2022 23:10:37 -0500
Subject: [PATCH 5/9] fixed typo
---
src/extension/gutters.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 61daa64..1f62b00 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -32,7 +32,7 @@ export class Gutters {
const coverageReports = await this.coverage.findReports();
const pickedReport = await this.coverage.pickFile(
coverageReports,
- "Choose a Coverage Report to pfffreview.",
+ "Choose a Coverage Report to preview.",
);
if (!pickedReport) {
window.showWarningMessage("Could not show Coverage Report file!");
From f58addc4b2298b75f3e47d3bac9c1a5378752896 Mon Sep 17 00:00:00 2001
From: VXDguy <74228808+vxdguy@users.noreply.github.com>
Date: Mon, 18 Apr 2022 05:11:37 -0500
Subject: [PATCH 6/9] fix(fix lint, update deps): Compliance with PR
requirements
vscode depencies updated to 1.66.0
coverage-gutters.coverageFilename includes "coverage.cobertura.xml" for dotnet support
cleaned up tslint complaints within gutters.ts
---
package-lock.json | 16 ++++++++--------
package.json | 14 +++++++++-----
src/extension/gutters.ts | 16 ++++++++--------
3 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 2028710..3fb78c6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -25,7 +25,7 @@
"@types/sinon": "10.0.11",
"@types/sinon-chai": "3.2.8",
"@types/uuid": "8.3.4",
- "@types/vscode": "1.64.0",
+ "@types/vscode": "1.66.0",
"@vscode/test-electron": "2.1.2",
"chai": "4.3.6",
"cross-env": "7.0.3",
@@ -39,7 +39,7 @@
},
"engines": {
"node": "^16.11.0",
- "vscode": "^1.59.0"
+ "vscode": "^1.66.0"
}
},
"node_modules/@babel/code-frame": {
@@ -230,9 +230,9 @@
"dev": true
},
"node_modules/@types/vscode": {
- "version": "1.64.0",
- "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.64.0.tgz",
- "integrity": "sha512-bSlAWz5WtcSL3cO9tAT/KpEH9rv5OBnm93OIIFwdCshaAiqr2bp1AUyEwW9MWeCvZBHEXc3V0fTYVdVyzDNwHA==",
+ "version": "1.66.0",
+ "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.66.0.tgz",
+ "integrity": "sha512-ZfJck4M7nrGasfs4A4YbUoxis3Vu24cETw3DERsNYtDZmYSYtk6ljKexKFKhImO/ZmY6ZMsmegu2FPkXoUFImA==",
"dev": true
},
"node_modules/@ungap/promise-all-settled": {
@@ -3368,9 +3368,9 @@
"dev": true
},
"@types/vscode": {
- "version": "1.64.0",
- "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.64.0.tgz",
- "integrity": "sha512-bSlAWz5WtcSL3cO9tAT/KpEH9rv5OBnm93OIIFwdCshaAiqr2bp1AUyEwW9MWeCvZBHEXc3V0fTYVdVyzDNwHA==",
+ "version": "1.66.0",
+ "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.66.0.tgz",
+ "integrity": "sha512-ZfJck4M7nrGasfs4A4YbUoxis3Vu24cETw3DERsNYtDZmYSYtk6ljKexKFKhImO/ZmY6ZMsmegu2FPkXoUFImA==",
"dev": true
},
"@ungap/promise-all-settled": {
diff --git a/package.json b/package.json
index d736531..86d9524 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"bugs": "https://github.com/ryanluker/vscode-coverage-gutters/issues",
"publisher": "ryanluker",
"engines": {
- "vscode": "^1.59.0",
+ "vscode": "^1.66.0",
"node": "^16.11.0"
},
"categories": [
@@ -130,7 +130,8 @@
"lcov.info",
"cov.xml",
"coverage.xml",
- "jacoco.xml"
+ "jacoco.xml",
+ "coverage.cobertura.xml"
],
"description": "coverage file names for the extension to automatically look for"
},
@@ -264,7 +265,7 @@
"@types/sinon": "10.0.11",
"@types/sinon-chai": "3.2.8",
"@types/uuid": "8.3.4",
- "@types/vscode": "1.64.0",
+ "@types/vscode": "1.66.0",
"@vscode/test-electron": "2.1.2",
"chai": "4.3.6",
"cross-env": "7.0.3",
@@ -273,7 +274,7 @@
"mocha": "9.2.0",
"sinon": "13.0.1",
"sinon-chai": "3.7.0",
- "tslint": "5.16.0",
+ "tslint": "^5.16.0",
"typescript": "4.5.5"
},
"dependencies": {
@@ -283,5 +284,8 @@
"jacoco-parse": "2.0.1",
"lcov-parse": "1.0.0",
"uuid": "8.3.2"
- }
+ },
+ "extensionDependencies": [
+ "ms-vscode.live-server"
+ ]
}
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 1f62b00..59bbfaf 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -1,9 +1,9 @@
+import { commands, extensions } from "vscode";
import { OutputChannel, window } from "vscode";
import { Coverage } from "../coverage-system/coverage";
import { CoverageService } from "../coverage-system/coverageservice";
import { Config } from "./config";
import { StatusBarToggler } from "./statusbartoggler";
-import * as vscode from 'vscode';
export class Gutters {
private coverage: Coverage;
@@ -43,21 +43,21 @@ export class Gutters {
// Right now the livePreview.start.internalPreview.atFile is called with "false" as
// the second parameter. This means that the file specified has an absolute path.
// See the Live Preview extension source code:
- // https://github.com/microsoft/vscode-livepreview/blob/3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
- const livePreview = vscode.extensions.getExtension('ms-vscode.live-server');
+// https://github.com/microsoft/vscode-livepreview/blob/3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
+ const livePreview = extensions.getExtension("ms-vscode.live-server");
// is the ext loaded and ready?
if (livePreview?.isActive === false) {
livePreview.activate().then(
- function () {
+ function() {
console.log("Extension activated");
- vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
},
- function () {
+ function() {
console.log("Extension activation failed");
- }
+ },
);
} else {
- vscode.commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
+ commands.executeCommand("livePreview.start.internalPreview.atFile", pickedReport, false);
}
} catch (error: any) {
From a4736fae52b893e13e06c6f59abb5ce15812ab36 Mon Sep 17 00:00:00 2001
From: Ryan Luker
Date: Sun, 24 Apr 2022 16:52:43 +0000
Subject: [PATCH 7/9] Add live preview for testing suite
---
package.json | 4 ++--
src/extension/gutters.ts | 3 ++-
test/runTest.ts | 21 ++++++++++++++-------
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/package.json b/package.json
index 86d9524..0bf8685 100644
--- a/package.json
+++ b/package.json
@@ -274,7 +274,7 @@
"mocha": "9.2.0",
"sinon": "13.0.1",
"sinon-chai": "3.7.0",
- "tslint": "^5.16.0",
+ "tslint": "5.16.0",
"typescript": "4.5.5"
},
"dependencies": {
@@ -288,4 +288,4 @@
"extensionDependencies": [
"ms-vscode.live-server"
]
-}
+}
\ No newline at end of file
diff --git a/src/extension/gutters.ts b/src/extension/gutters.ts
index 59bbfaf..d5b4f5a 100644
--- a/src/extension/gutters.ts
+++ b/src/extension/gutters.ts
@@ -43,7 +43,8 @@ export class Gutters {
// Right now the livePreview.start.internalPreview.atFile is called with "false" as
// the second parameter. This means that the file specified has an absolute path.
// See the Live Preview extension source code:
-// https://github.com/microsoft/vscode-livepreview/blob/3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
+ // https://github.com/microsoft/vscode-livepreview/blob/
+ // 3be1e2eb5c8a7b51aa4a88275ad73bb4d923432b/src/extension.ts#L169
const livePreview = extensions.getExtension("ms-vscode.live-server");
// is the ext loaded and ready?
if (livePreview?.isActive === false) {
diff --git a/test/runTest.ts b/test/runTest.ts
index 0d26934..184aae1 100644
--- a/test/runTest.ts
+++ b/test/runTest.ts
@@ -1,21 +1,28 @@
+import {
+ downloadAndUnzipVSCode,
+ resolveCliPathFromVSCodeExecutablePath,
+ runTests,
+} from "@vscode/test-electron";
+import * as cp from "child_process";
import * as path from "path";
-import { downloadAndUnzipVSCode, runTests } from "@vscode/test-electron";
-
async function main() {
try {
const extensionDevelopmentPath = path.resolve(__dirname, "..", "..");
const extensionTestsPath = path.resolve(__dirname, "index");
const vscodeExecutablePath = await downloadAndUnzipVSCode("insiders");
+ const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath, "linux-x64");
+
+ // Add the dependent extension for test coverage preview functionality
+ cp.spawnSync(cliPath, ["--install-extension", "ms-vscode.live-server"], {
+ encoding: "utf-8",
+ stdio: "inherit",
+ });
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
- launchArgs: [
- "example/example.code-workspace",
- "--disable-extensions",
- "--disable-telemetry",
- ],
+ launchArgs: ["example/example.code-workspace"],
vscodeExecutablePath,
});
From 46df75d002cb7342423ec3fd5ce545db36ccf39c Mon Sep 17 00:00:00 2001
From: Ryan Luker
Date: Sun, 24 Apr 2022 10:22:02 -0700
Subject: [PATCH 8/9] Fix live preview install for tests
---
test/runTest.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/runTest.ts b/test/runTest.ts
index 184aae1..d1044bc 100644
--- a/test/runTest.ts
+++ b/test/runTest.ts
@@ -1,6 +1,6 @@
import {
downloadAndUnzipVSCode,
- resolveCliPathFromVSCodeExecutablePath,
+ resolveCliArgsFromVSCodeExecutablePath,
runTests,
} from "@vscode/test-electron";
import * as cp from "child_process";
@@ -11,10 +11,10 @@ async function main() {
const extensionDevelopmentPath = path.resolve(__dirname, "..", "..");
const extensionTestsPath = path.resolve(__dirname, "index");
const vscodeExecutablePath = await downloadAndUnzipVSCode("insiders");
- const cliPath = resolveCliPathFromVSCodeExecutablePath(vscodeExecutablePath, "linux-x64");
// Add the dependent extension for test coverage preview functionality
- cp.spawnSync(cliPath, ["--install-extension", "ms-vscode.live-server"], {
+ const [cli, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
+ cp.spawnSync(cli, [...args, "--install-extension", "ms-vscode.live-server"], {
encoding: "utf-8",
stdio: "inherit",
});
From 51fa3e8c46b9a7c89929b1e193e6eb69c7fdebe0 Mon Sep 17 00:00:00 2001
From: Ryan Luker
Date: Sun, 24 Apr 2022 10:51:55 -0700
Subject: [PATCH 9/9] Fix preview tests
---
package.json | 2 +-
test/extension.test.ts | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/package.json b/package.json
index 0bf8685..0832db4 100644
--- a/package.json
+++ b/package.json
@@ -288,4 +288,4 @@
"extensionDependencies": [
"ms-vscode.live-server"
]
-}
\ No newline at end of file
+}
diff --git a/test/extension.test.ts b/test/extension.test.ts
index 882fa8a..446c3df 100644
--- a/test/extension.test.ts
+++ b/test/extension.test.ts
@@ -19,9 +19,10 @@ suite("Extension Tests", function() {
// is in the root of the node folder and not inside the default /coverage
await vscode.commands.executeCommand("coverage-gutters.previewCoverageReport");
// Look to see if the webview is open and showing preview coverage
- await wait(500);
- const reportView = vscode.workspace.textDocuments[0];
- expect(reportView.languageId).to.equal("html");
+ await checkCoverage(() => {
+ const livePreview = vscode.extensions.getExtension("ms-vscode.live-server");
+ expect(livePreview?.isActive).to.equal(true);
+ });
});
test("Run display coverage on a test file that has coverages generated remotely @integration", async () => {