-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable intellisense and improve web smoke tests (#9623)
* Enable intellisense and improve web smoke tests * Misc
- Loading branch information
1 parent
42e3f38
commit cd787d2
Showing
15 changed files
with
141 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
const path = require('path'); | ||
const test_web = require('@vscode/test-web'); | ||
async function go() { | ||
try { | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../'); | ||
await test_web.runTests({ | ||
browserType: 'chromium', | ||
extensionDevelopmentPath, | ||
extensionTestsPath: path.join(extensionDevelopmentPath, 'out', 'extension.web.bundle') | ||
}); | ||
} catch (err) { | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
void go(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,64 @@ | ||
// imports mocha for the browser, defining the `mocha` global. | ||
require('mocha/mocha'); | ||
// Re-export extension entry point, so that the output from this file | ||
// when bundled can be used as entry point for extension as well as tests. | ||
// The same objects/types will be used as the module is only ever loaded once by nodejs. | ||
import * as extension from '../../../extension.web'; | ||
import * as vscode from 'vscode'; | ||
import type { IExtensionApi } from '../../../platform/api'; | ||
import type { IExtensionContext } from '../../../platform/common/types'; | ||
import { IExtensionTestApi } from '../../common'; | ||
import { JVSC_EXTENSION_ID } from '../../../platform/common/constants'; | ||
|
||
export function run(): Promise<void> { | ||
return new Promise((c, e) => { | ||
mocha.setup({ | ||
ui: 'tdd', | ||
reporter: undefined | ||
}); | ||
let activatedResponse: undefined | IExtensionApi; | ||
|
||
// bundles all files in the current directory matching `*.test` | ||
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r); | ||
importAll(require.context('.', true, /\.web.test$/)); | ||
// Basically this is the entry point for the extension. | ||
export async function activate(context: IExtensionContext): Promise<IExtensionApi> { | ||
if (activatedResponse) { | ||
return activatedResponse; | ||
} | ||
vscode.commands.registerCommand('jupyter.web.runTests', async () => { | ||
// imports mocha for the browser, defining the `mocha` global. | ||
require('mocha/mocha'); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run((failures) => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
return new Promise<void>((resolve, reject) => { | ||
mocha.setup({ | ||
ui: 'tdd', | ||
reporter: undefined | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
e(err); | ||
} | ||
|
||
// bundles all files in the current directory matching `*.test` | ||
const importAll = (r: __WebpackModuleApi.RequireContext) => r.keys().forEach(r); | ||
importAll(require.context('.', true, /\.web.test$/)); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run((failures) => { | ||
if (failures > 0) { | ||
reject(new Error(`${failures} tests failed.`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
activatedResponse = await extension.activate(context); | ||
return activatedResponse; | ||
} | ||
|
||
export async function deactivate(): Promise<void> { | ||
return extension.deactivate(); | ||
} | ||
|
||
export async function run(): Promise<void> { | ||
// Activate the extension so that the commands are registered. | ||
// Also this will not slow down the suite-setups. | ||
const extension = vscode.extensions.getExtension<IExtensionTestApi>(JVSC_EXTENSION_ID)!; | ||
const api = await extension.activate(); | ||
await api.ready; | ||
// Run the tests from within the context of the extension bundle. | ||
// We achieve this by getting the extension to run the tests (then its guaranteed to use the same context as the extension). | ||
await vscode.commands.executeCommand('jupyter.web.runTests'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters