Fix test conflict and missing mock

This commit is contained in:
roblou 2016-12-20 14:09:39 -08:00
Родитель d16ed78248
Коммит f136fd495c
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -68,6 +68,15 @@ suite('ChromeDebugAdapter', () => {
});
suite('launch()', () => {
let originalSpawn: any;
let originalStatSync: any;
teardown(() => {
// Hacky mock cleanup
require('child_process').spawn = originalSpawn;
require('fs').statSync = originalStatSync;
})
test('launches with minimal correct args', () => {
let spawnCalled = false;
function spawn(chromePath: string, args: string[]): any {
@ -84,7 +93,9 @@ suite('ChromeDebugAdapter', () => {
// Mock spawn for chrome process, and 'fs' for finding chrome.exe.
// These are mocked as empty above - note that it's too late for mockery here.
originalSpawn = require('child_process').spawn;
require('child_process').spawn = spawn;
originalStatSync = require('fs').statSync;
require('fs').statSync = () => true;
mockChromeConnection

Просмотреть файл

@ -50,7 +50,8 @@ function getRuntimeStubs(mockEventEmitter) {
evaluate() { },
onConsoleAPICalled(handler) { mockEventEmitter.on('Runtime.consoleAPICalled', handler); },
onExecutionContextsCleared(handler) { mockEventEmitter.on('Runtime.executionContextsCleared', handler); }
onExecutionContextsCleared(handler) { mockEventEmitter.on('Runtime.executionContextsCleared', handler); },
onExceptionThrown(handler) { mockEventEmitter.on('Runtime.onExceptionThrown', handler); }
};
}