Skip to content

Commit

Permalink
Switch option observer tests to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Aug 19, 2023
1 parent 4737540 commit 70b7a37
Show file tree
Hide file tree
Showing 21 changed files with 20,852 additions and 13,583 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"orta.vscode-jest"
]
}
15 changes: 15 additions & 0 deletions __mocks__/vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { getFakeVsCode } from '../test/unitTests/testAssets/fakes';
import * as vscodeAdapter from '../src/vscodeAdapter';

// This module creates a manual mock for the vscode module for running in unit tests.
// Jest will automatically pick this up as it is in the __mocks__ directory next to node_modules.

// We can consider switching to an actual jest mock (instead of this manual fake) once we entirely
// remove the old test framework (mocha/chai).
const vscode: vscodeAdapter.vscode = getFakeVsCode();
module.exports = vscode;
20 changes: 20 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { Config } from 'jest';

const config: Config = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
transformIgnorePatterns: ['/dist/.+\\.js'],
modulePathIgnorePatterns: ['out'],
/* Specify jest to only run tests in jestUnitTests.
* We also have to include the __mocks__ folder. That folder must be next to node_modules so we can't move it,
* but if we specify roots, jest won't automatically pick it up. So we have to specify it here.
*/
roots: ['<rootDir>/test/jestUnitTests', '<rootDir>/__mocks__'],
};

export default config;
6 changes: 5 additions & 1 deletion l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@
"View Debug Docs": "View Debug Docs",
"Ignore": "Ignore",
"Run and Debug: A valid browser is not installed": "Run and Debug: A valid browser is not installed",
"dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change": "dotnet.server.useOmnisharp option has changed. Please reload the window to apply the change",
"Reload Window": "Reload Window",
"C# configuration has changed. Would you like to relaunch the Language Server with your changes?": "C# configuration has changed. Would you like to relaunch the Language Server with your changes?",
"Restart Language Server": "Restart Language Server",
"Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.": "Your workspace has multiple Visual Studio Solution files; please select one to get full IntelliSense.",
"Choose": "Choose",
"Choose and set default": "Choose and set default",
"Do not load any": "Do not load any",
"Restart Language Server": "Restart Language Server",
"C# configuration has changed. Would you like to reload the window to apply your changes?": "C# configuration has changed. Would you like to reload the window to apply your changes?",
"pipeArgs must be a string or a string array type": "pipeArgs must be a string or a string array type",
"Name not defined in current configuration.": "Name not defined in current configuration.",
"Configuration \"{0}\" in launch.json does not have a {1} argument with {2} for remote process listing.": "Configuration \"{0}\" in launch.json does not have a {1} argument with {2} for remote process listing.",
Expand Down
Loading

0 comments on commit 70b7a37

Please sign in to comment.