Skip to content

Commit e60ed32

Browse files
authored
Merge pull request #1795 from github/jest-migration/ts-jest
Use ts-jest for running integration tests
2 parents 003b9dc + a23a8f7 commit e60ed32

11 files changed

Lines changed: 56 additions & 54 deletions

extensions/ql-vscode/jest.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ module.exports = {
88
projects: [
99
"<rootDir>/src/view",
1010
"<rootDir>/test",
11-
"<rootDir>/out/vscode-tests/cli-integration",
12-
"<rootDir>/out/vscode-tests/no-workspace",
13-
"<rootDir>/out/vscode-tests/minimal-workspace",
11+
"<rootDir>/src/vscode-tests/cli-integration",
12+
"<rootDir>/src/vscode-tests/no-workspace",
13+
"<rootDir>/src/vscode-tests/minimal-workspace",
1414
],
1515
};

extensions/ql-vscode/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,9 +1273,9 @@
12731273
"test:unit": "jest --projects test",
12741274
"test:view": "jest --projects src/view",
12751275
"integration": "npm-run-all integration:*",
1276-
"integration:no-workspace": "jest --projects out/vscode-tests/no-workspace",
1277-
"integration:minimal-workspace": "jest --projects out/vscode-tests/minimal-workspace",
1278-
"cli-integration": "jest --projects out/vscode-tests/cli-integration",
1276+
"integration:no-workspace": "jest --projects src/vscode-tests/no-workspace",
1277+
"integration:minimal-workspace": "jest --projects src/vscode-tests/minimal-workspace",
1278+
"cli-integration": "jest --projects src/vscode-tests/cli-integration",
12791279
"update-vscode": "node ./node_modules/vscode/bin/install",
12801280
"format": "prettier --write **/*.{ts,tsx} && eslint . --ext .ts,.tsx --fix",
12811281
"lint": "eslint . --ext .ts,.tsx --max-warnings=0",

extensions/ql-vscode/src/vscode-tests/cli-integration/jest-runner-vscode.config.ts renamed to extensions/ql-vscode/src/vscode-tests/cli-integration/jest-runner-vscode.config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import * as path from "path";
1+
const path = require("path");
22

3-
import { RunnerOptions } from "jest-runner-vscode";
3+
const {
4+
config: baseConfig,
5+
rootDir,
6+
} = require("../jest-runner-vscode.config.base");
47

5-
import baseConfig, { rootDir } from "../jest-runner-vscode.config.base";
6-
7-
const config: RunnerOptions = {
8+
/** @type import("jest-runner-vscode").RunnerOptions */
9+
const config = {
810
...baseConfig,
911
launchArgs: [
1012
...(baseConfig.launchArgs ?? []),
@@ -25,6 +27,4 @@ const config: RunnerOptions = {
2527
},
2628
};
2729

28-
// We are purposefully not using export default here since that would result in an ESModule, which doesn't seem to be
29-
// supported properly by jest-runner-vscode (cosmiconfig doesn't really seem to support it).
3030
module.exports = config;

extensions/ql-vscode/src/vscode-tests/cli-integration/jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import baseConfig from "../jest.config.base";
44

55
const config: Config = {
66
...baseConfig,
7-
runner: "<rootDir>/jest-runner-cli-integration.js",
8-
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
7+
runner: "<rootDir>/jest-runner-cli-integration.ts",
8+
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
99
};
1010

1111
export default config;

extensions/ql-vscode/src/vscode-tests/cli-integration/legacy-query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const queryTestCases: QueryTestCase[] = [
9494
];
9595

9696
const db: messages.Dataset = {
97-
dbDir: path.join(__dirname, "../test-db"),
97+
dbDir: path.join(__dirname, "../../../.vscode-test/test-db"),
9898
workingSet: "default",
9999
};
100100

extensions/ql-vscode/src/vscode-tests/jest-runner-vscode.config.base.ts renamed to extensions/ql-vscode/src/vscode-tests/jest-runner-vscode.config.base.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as path from "path";
2-
import * as tmp from "tmp-promise";
3-
import { RunnerOptions } from "jest-runner-vscode";
1+
const path = require("path");
2+
const tmp = require("tmp-promise");
43

5-
export const tmpDir = tmp.dirSync({ unsafeCleanup: true });
4+
const tmpDir = tmp.dirSync({ unsafeCleanup: true });
65

7-
export const rootDir = path.resolve(__dirname, "../..");
6+
const rootDir = path.resolve(__dirname, "../..");
87

9-
const config: RunnerOptions = {
8+
/** @type import("jest-runner-vscode").RunnerOptions */
9+
const config = {
1010
version: "stable",
1111
launchArgs: [
1212
"--disable-gpu",
@@ -20,4 +20,8 @@ if (process.env.VSCODE_INSPECTOR_OPTIONS) {
2020
config.launchArgs?.push("--inspect-extensions", "9223");
2121
}
2222

23-
export default config;
23+
module.exports = {
24+
config,
25+
tmpDir,
26+
rootDir,
27+
};

extensions/ql-vscode/src/vscode-tests/jest.config.base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const config: Config = {
9393
// notifyMode: "failure-change",
9494

9595
// A preset that is used as a base for Jest's configuration
96-
// preset: 'ts-jest',
96+
preset: "ts-jest",
9797

9898
// Run tests from one or more projects
9999
// projects: undefined,
@@ -128,7 +128,7 @@ const config: Config = {
128128
// setupFiles: [],
129129

130130
// A list of paths to modules that run some code to configure or set up the testing framework before each test
131-
setupFilesAfterEnv: ["<rootDir>/../jest.setup.js"],
131+
setupFilesAfterEnv: ["<rootDir>/../jest.setup.ts"],
132132

133133
// The number of seconds after which a test is considered as slow and reported as such in the results.
134134
// slowTestThreshold: 5,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require("path");
2+
3+
const {
4+
config: baseConfig,
5+
rootDir,
6+
} = require("../jest-runner-vscode.config.base");
7+
8+
/** @type import("jest-runner-vscode").RunnerOptions */
9+
const config = {
10+
...baseConfig,
11+
launchArgs: [
12+
...(baseConfig.launchArgs ?? []),
13+
"--disable-extensions",
14+
path.resolve(rootDir, "test/data"),
15+
],
16+
};
17+
18+
module.exports = config;

extensions/ql-vscode/src/vscode-tests/minimal-workspace/jest-runner-vscode.config.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { config: baseConfig } = require("../jest-runner-vscode.config.base");
2+
3+
/** @type import("jest-runner-vscode").RunnerOptions */
4+
const config = {
5+
...baseConfig,
6+
launchArgs: [...(baseConfig.launchArgs ?? []), "--disable-extensions"],
7+
};
8+
9+
module.exports = config;

0 commit comments

Comments
 (0)