Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run unit tests against node.js too #137790

Merged
merged 11 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -72,6 +72,9 @@ jobs:
- name: Run Unit Tests (Electron)
run: .\scripts\test.bat

- name: Run Unit Tests (node.js)
run: yarn test-node

- name: Run Unit Tests (Browser)
run: yarn test-browser --browser chromium

Expand Down Expand Up @@ -147,6 +150,10 @@ jobs:
id: electron-unit-tests
run: DISPLAY=:10 ./scripts/test.sh

- name: Run Unit Tests (node.js)
id: nodejs-unit-tests
run: yarn test-node

- name: Run Unit Tests (Browser)
id: browser-unit-tests
run: DISPLAY=:10 yarn test-browser --browser chromium
Expand Down Expand Up @@ -222,6 +229,9 @@ jobs:
- name: Run Unit Tests (Electron)
run: DISPLAY=:10 ./scripts/test.sh

- name: Run Unit Tests (node.js)
run: yarn test-node

- name: Run Unit Tests (Browser)
run: DISPLAY=:10 yarn test-browser --browser chromium

Expand Down
7 changes: 7 additions & 0 deletions build/azure-pipelines/darwin/product-build-darwin.yml
Expand Up @@ -179,6 +179,13 @@ steps:
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

- script: |
set -e
yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

- script: |
set -e
yarn test-browser --build --browser chromium --browser webkit --browser firefox --tfs "Browser Unit Tests"
Expand Down
7 changes: 7 additions & 0 deletions build/azure-pipelines/linux/product-build-linux.yml
Expand Up @@ -162,6 +162,13 @@ steps:
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

- script: |
set -e
yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

- script: |
set -e
yarn test-browser --build --browser chromium --tfs "Browser Unit Tests"
Expand Down
8 changes: 8 additions & 0 deletions build/azure-pipelines/win32/product-build-win32.yml
Expand Up @@ -150,6 +150,14 @@ steps:
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64'))

- powershell: |
. build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop"
exec { yarn test-node --build }
displayName: Run unit tests (node.js)
timeoutInMinutes: 7
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'), ne(variables['VSCODE_ARCH'], 'arm64'))

- powershell: |
. build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop"
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"test": "mocha",
"test-browser": "node test/unit/browser/index.js",
"test-node": "mocha test/unit/node/index.js --delay --ui=tdd --exit",
"preinstall": "node build/npm/preinstall.js",
"postinstall": "node build/npm/postinstall.js",
"compile": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js compile",
Expand All @@ -27,7 +28,6 @@
"watch-extensions": "node --max_old_space_size=4095 ./node_modules/gulp/bin/gulp.js watch-extensions watch-extension-media",
"watch-extensionsd": "deemon yarn watch-extensions",
"kill-watch-extensionsd": "deemon --kill yarn watch-extensions",
"mocha": "mocha test/unit/node/all.js --delay --ui=tdd",
"precommit": "node build/hygiene.js",
"gulp": "node --max_old_space_size=8192 ./node_modules/gulp/bin/gulp.js",
"electron": "node build/lib/electron",
Expand Down Expand Up @@ -169,7 +169,6 @@
"istanbul-lib-report": "^3.0.0",
"istanbul-lib-source-maps": "^4.0.0",
"istanbul-reports": "^3.0.0",
"jsdom-no-contextify": "^3.1.0",
"lazy.js": "^0.4.2",
"merge-options": "^1.0.1",
"mime": "^1.4.1",
Expand Down
1 change: 0 additions & 1 deletion src/vs/base/test/common/event.test.ts
Expand Up @@ -48,7 +48,6 @@ suite('Event', function () {

let doc = new Samples.Document3();

document.createElement('div').onclick = function () { };
let subscription = doc.onDidChange(counter.onEvent, counter);

doc.setText('far');
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/contrib/debug/test/node/debugger.test.ts
Expand Up @@ -149,7 +149,10 @@ suite('Debug - Debugger', () => {
assert.deepStrictEqual(ae!.args, debuggerContribution.args);
});

test('merge platform specific attributes', () => {
test('merge platform specific attributes', function () {
if (!process.versions.electron) {
this.skip(); //TODO@debug this test fails when run in node.js environments
}
const ae = ExecutableDebugAdapter.platformAdapterExecutable([extensionDescriptor1, extensionDescriptor2], 'mock')!;
assert.strictEqual(ae.command, platform.isLinux ? 'linuxRuntime' : (platform.isMacintosh ? 'osxRuntime' : 'winRuntime'));
const xprogram = platform.isLinux ? 'linuxProgram' : (platform.isMacintosh ? 'osxProgram' : 'winProgram');
Expand Down
Expand Up @@ -322,6 +322,9 @@ suite('Encoding', () => {
});

test('toDecodeStream - decodes buffer entirely', async function () {
if (!process.versions.electron) {
this.skip(); // TODO@bpasero enable once we ship Electron 16
}
const emojis = Buffer.from('🖥️💻💾');
const incompleteEmojis = emojis.slice(0, emojis.length - 1);

Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/test/browser/workbenchTestServices.ts
Expand Up @@ -144,6 +144,7 @@ import { TestLanguageConfigurationService } from 'vs/editor/test/common/modes/te
import { FindReplaceState } from 'vs/editor/contrib/find/findState';
import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput';
import { DeserializedTerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorSerializer';
import { env } from 'vs/base/common/process';

export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined, undefined);
Expand Down Expand Up @@ -1822,7 +1823,7 @@ export class TestTerminalProfileResolverService implements ITerminalProfileResol
async getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { return { path: '/default', profileName: 'Default', isDefault: true }; }
async getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { return '/default'; }
async getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { return []; }
async getEnvironment(): Promise<IProcessEnvironment> { return process.env; }
async getEnvironment(): Promise<IProcessEnvironment> { return env; }
getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { return undefined; }
getSafeConfigValueFullKey(key: string): unknown | undefined { return undefined; }
createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<string | ITerminalProfile> { throw new Error('Method not implemented.'); }
Expand Down
49 changes: 0 additions & 49 deletions test/unit/node/browser.js

This file was deleted.

12 changes: 0 additions & 12 deletions test/unit/node/css.mock.js

This file was deleted.

30 changes: 0 additions & 30 deletions test/unit/node/index.html

This file was deleted.