From f3acc91a56615337ae7159229a981c58caf48079 Mon Sep 17 00:00:00 2001 From: Shennie Yao Date: Wed, 23 Jan 2019 16:46:40 -0800 Subject: [PATCH] updating unit test mock, returning promises in integration test teardowns, not waiting to asynchronously kill chrome on windows --- .vscode/launch.json | 1 + src/chromeDebugAdapter.ts | 2 +- test/chromeDebugAdapter.test.ts | 4 ++++ test/int/adapter.test.ts | 2 +- test/int/breakOnLoad.test.ts | 9 +++------ test/int/breakpoints.test.ts | 2 +- test/int/stepping.test.ts | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3abcbdd..c6b4269 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -39,6 +39,7 @@ "--reporter", "node_modules/vscode-chrome-debug-core-testsupport/out/loggingReporter.js", "${workspaceFolder}/out/test/int/*.test.js" ], + "skipFiles": ["/**"], "outFiles": [ "${workspaceFolder}/out/**/*.js" ] diff --git a/src/chromeDebugAdapter.ts b/src/chromeDebugAdapter.ts index 357bd3c..d3bd0eb 100644 --- a/src/chromeDebugAdapter.ts +++ b/src/chromeDebugAdapter.ts @@ -354,7 +354,7 @@ export class ChromeDebugAdapter extends CoreDebugAdapter { // Only kill Chrome if the 'disconnect' originated from vscode. If we previously terminated // due to Chrome shutting down, or devtools taking over, don't kill Chrome. if (coreUtils.getPlatform() === coreUtils.Platform.Windows && this._chromePID) { - await this.killChromeOnWindows(this._chromePID); + this.killChromeOnWindows(this._chromePID); } else if (this._chromeProc) { logger.log('Killing Chrome process'); this._chromeProc.kill('SIGINT'); diff --git a/test/chromeDebugAdapter.test.ts b/test/chromeDebugAdapter.test.ts index 830d7f3..8fe66f5 100644 --- a/test/chromeDebugAdapter.test.ts +++ b/test/chromeDebugAdapter.test.ts @@ -103,6 +103,10 @@ suite('ChromeDebugAdapter', () => { mockChrome.Runtime .setup(x => x.evaluate(It.isAny())) .returns(() => Promise.resolve({ result: { type: 'string', value: '123' }})); + + mockChrome.Network + .setup(x => x.setCacheDisabled(It.isAny())) + .returns(() => Promise.resolve()); }); teardown(() => { diff --git a/test/int/adapter.test.ts b/test/int/adapter.test.ts index 6f2e9b3..5f4bab4 100644 --- a/test/int/adapter.test.ts +++ b/test/int/adapter.test.ts @@ -21,7 +21,7 @@ suite('Chrome Debug Adapter etc', () => { }); teardown(() => { - testSetup.teardown(); + return testSetup.teardown(); }); suite('basic', () => { diff --git a/test/int/breakOnLoad.test.ts b/test/int/breakOnLoad.test.ts index 2a6a3ea..5440a81 100644 --- a/test/int/breakOnLoad.test.ts +++ b/test/int/breakOnLoad.test.ts @@ -25,10 +25,7 @@ function runCommonTests(breakOnLoadStrategy: string) { server.close(); } - return new Promise((resolve, reject) => { - testSetup.teardown(); - resolve(); - }); + return testSetup.teardown(); }); // this function is to help when launching and setting a breakpoint @@ -253,7 +250,7 @@ suite('BreakOnLoad', () => { server.close(); } - testSetup.teardown(); + return testSetup.teardown(); }); test('Hits a single breakpoint in a file on load', async () => { @@ -320,7 +317,7 @@ suite('BreakOnLoad', () => { server.close(); } - testSetup.teardown(); + return testSetup.teardown(); }); test('Does not hit a breakpoint in a file on load', async () => { diff --git a/test/int/breakpoints.test.ts b/test/int/breakpoints.test.ts index 58dae28..820eb72 100644 --- a/test/int/breakpoints.test.ts +++ b/test/int/breakpoints.test.ts @@ -25,7 +25,7 @@ suite('Breakpoints', () => { server.close(); } - testSetup.teardown(); + return testSetup.teardown(); }); suite('Column BPs', () => { diff --git a/test/int/stepping.test.ts b/test/int/stepping.test.ts index d4fdd26..20e3137 100644 --- a/test/int/stepping.test.ts +++ b/test/int/stepping.test.ts @@ -25,7 +25,7 @@ suite('Stepping', () => { server.close(); } - testSetup.teardown(); + return testSetup.teardown(); }); suite('skipFiles', () => {