Files
vscode-codeql/extensions/ql-vscode/test/vscode-tests/cli-integration/helpers.test.ts
Koen Vlaswinkel 5766db9285 Set default higher timeout on CLI integration tests
This sets a default timeout of 3 minutes on CLI integration tests. This
is because these tests call into the CLI and execute queries, so these
are expected to take a lot longer than the default 5 seconds. This
allows us to remove all the individual `jest.setTimeout` calls with
different values from the test files.
2023-04-14 10:46:33 +02:00

39 lines
1.0 KiB
TypeScript

import { join } from "path";
import { CodeQLCliServer } from "../../../src/cli";
import { tryGetQueryMetadata } from "../../../src/helpers";
import { getActivatedExtension } from "../global.helper";
describe("helpers (with CLI)", () => {
const baseDir = __dirname;
let cli: CodeQLCliServer;
beforeEach(async () => {
const extension = await getActivatedExtension();
cli = extension.cliServer;
});
it("should get query metadata when available", async () => {
// Query with metadata
const metadata = await tryGetQueryMetadata(
cli,
join(baseDir, "data", "simple-javascript-query.ql"),
);
expect(metadata!.name).toBe("This is the name");
expect(metadata!.kind).toBe("problem");
expect(metadata!.id).toBe("javascript/example/test-query");
});
it("should handle query with no metadata", async () => {
// Query with empty metadata
const noMetadata = await tryGetQueryMetadata(
cli,
join(baseDir, "data", "simple-query.ql"),
);
expect(noMetadata).toEqual({});
});
});