Skip to content

Commit 3af5ccb

Browse files
committed
got jest working on simple test files for extension and parser
1 parent 55d274c commit 3af5ccb

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

jest.config.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
const path = require('path');
22

3+
// module.exports = {
4+
// preset: 'ts-jest',
5+
// testEnvironment: './vscode-environment.js',
6+
// modulePaths: ['<rootDir>'],
7+
// // Add other Jest configurations as needed
8+
// // testMatch: ['**/test/**/*.js', '**/?(*.)+(spec|test).js'], // Match JavaScript files
9+
// moduleNameMapper: {
10+
// // '^@/(.*)$': 'build/src/$1', // Adjust this based on your project structure
11+
// vscode: path.join(__dirname, 'vscode.js') // <----- most important line
12+
// },
13+
// };
14+
315
module.exports = {
4-
preset: 'ts-jest',
5-
testEnvironment: './vscode-environment.js',
6-
modulePaths: ['<rootDir>'],
7-
// Add other Jest configurations as needed
8-
// testMatch: ['**/test/**/*.js', '**/?(*.)+(spec|test).js'], // Match JavaScript files
16+
preset: "ts-jest",
17+
testEnvironment: "node",
18+
preset: "ts-jest/presets/default-esm", // or other ESM presets
19+
globals: {
20+
"ts-jest": {
21+
useESM: true,
22+
},
23+
},
924
moduleNameMapper: {
10-
// '^@/(.*)$': 'build/src/$1', // Adjust this based on your project structure
25+
// '^@/(.*)$': 'build/src/$1',
1126
vscode: path.join(__dirname, 'vscode.js') // <----- most important line
1227
},
13-
};
28+
testMatch: ['**/test/**/*.js', '**/?(*.)+(spec|test).js']
29+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"scripts": {
7171
"lint": "eslint .",
7272
"pretest": "npm run lint",
73-
"test": "node build/src/test/runTest.js",
73+
"test": "node ./build/src/test/runTest.js",
7474
"dev": "webpack --watch",
7575
"webpack": "webpack"
7676
},

src/test/runTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function main() {
1919

2020
// Download VS Code, unzip it and run the integration test
2121
await runTests({
22-
version: '1.85.1',
22+
version: "1.85.1",
2323
extensionDevelopmentPath,
2424
extensionTestsPath
2525
});

src/test/suite/extension.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import * as vscode from 'vscode'
66
// we can either use test() or it() -- matter of style for team/project convention
77

88
describe('Extension Test Suite', () => {
9-
beforeEach(() => {
10-
vscode.window.showInformationMessage('Start all tests.');
11-
});
9+
// beforeEach(() => {
10+
// vscode.window.showInformationMessage('Start all tests.');
11+
// });
1212

1313
it('Sample test', () => {
1414
expect([1, 2, 3].indexOf(5)).toBe(-1);

src/test/suite/parser.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import * as vscode from 'vscode'
99
// const myExtension = require('../extension');
1010

1111
describe('Parser Test Suite', () => {
12-
beforeEach(() => {
13-
vscode.window.showInformationMessage('Start all tests.');
14-
});
12+
// beforeEach(() => {
13+
// vscode.window.showInformationMessage('Start all tests.');
14+
// });
1515

1616
let parser, tree, file;
1717

0 commit comments

Comments
 (0)