diff --git a/.vscode/launch.json b/.vscode/launch.json index ae2fc84b..57d98886 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -29,20 +29,6 @@ "outFiles": [ "${workspaceFolder}/dist/**/*.js" ] - }, - { - "name": "Extension Tests", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}", - "--extensionTestsPath=${workspaceFolder}/out/test" - ], - "outFiles": [ - "${workspaceFolder}/out/test/**/*.js" - ], - "preLaunchTask": "npm: test-compile" } ] } diff --git a/e2e/src/command.test.ts b/e2e/src/command.test.ts index cb8958f2..482c37b2 100644 --- a/e2e/src/command.test.ts +++ b/e2e/src/command.test.ts @@ -1,4 +1,4 @@ -import { By, VSBrowser, EditorView, WebView, Workbench, Notification } from "vscode-extension-tester"; +import { By, VSBrowser, EditorView, WebView, Workbench, Notification, StatusBar, NotificationType } from "vscode-extension-tester"; import { expect } from "chai"; import { sleep } from "./utils"; import { join } from "path"; @@ -12,7 +12,7 @@ describe("Initialization testing", function() { let workbench: Workbench; let view: WebView; - this.beforeAll(async function() { + before(async function() { await VSBrowser.instance.openResources(join(__dirname, '../sample')); await sleep(3000); workbench = new Workbench(); @@ -42,18 +42,39 @@ describe("Initialization testing", function() { await sleep(1000); + await VSBrowser.instance.driver.wait(() => { + return notificationExists(workbench, 'Front Matter:'); + }, 2000) as Notification; + const notifications = await workbench.getNotifications(); let notification!: Notification; for (const not of notifications) { - const message = await not.getMessage(); - if (message.includes('Front Matter:')) { - notification = not; - } + console.log(not); + + // const message = await not.get; + // console.log(message); + // if (message.includes('Front Matter:')) { + // notification = not; + // } } expect(await notification.getMessage()).has.string(`Project initialized successfully.`); }); it("3. Check if project file is created", async function() {}); -}); \ No newline at end of file +}); + + +async function notificationExists(workbench: Workbench, text: string): Promise { + const notifications = await (await (new StatusBar()).openNotificationsCenter()).getNotifications(NotificationType.Info); + console.log(`Notifications:`, notifications.length); + + for (const notification of notifications) { + const message = await notification.getMessage(); + console.log(message) + if (message.indexOf(text) >= 0) { + return notification; + } + } +} \ No newline at end of file diff --git a/e2e/src/runTests.ts b/e2e/src/runTests.ts index 4006aff2..923a1ba0 100644 --- a/e2e/src/runTests.ts +++ b/e2e/src/runTests.ts @@ -4,7 +4,7 @@ import { ExTester, ReleaseQuality } from "vscode-extension-tester"; async function main(): Promise { - const vsCodeVersion: semver.SemVer = new semver.SemVer(`1.65.0`); + const vsCodeVersion: semver.SemVer = new semver.SemVer(`1.66.0`); const version = vsCodeVersion.version; const storageFolder = path.join(__dirname, "..", "storage"); diff --git a/package.json b/package.json index 172bbdf5..d5eb730c 100644 --- a/package.json +++ b/package.json @@ -1927,7 +1927,8 @@ "test-compile": "tsc -p ./", "clean": "rimraf dist", "start:site": "cd ./docs && npm run dev", - "test": "tsc -p tsconfig.e2e.json && node ./e2e/out/runTests.js" + "clean:test": "rm ./e2e/sample/frontmatter.json || exit 0 && rm -rf ./e2e/sample/.frontmatter || exit 0", + "test": "tsc -p tsconfig.e2e.json && npm run clean:test && node ./e2e/out/runTests.js" }, "devDependencies": { "@actions/core": "^1.8.2",