Perform dirSync inside beforeEach block

This commit is contained in:
Robert
2023-08-03 14:19:12 +01:00
parent 8bce7b531c
commit 2ffbb9c14c

View File

@@ -13,6 +13,7 @@ import {
TWO_HOURS_IN_MS,
} from "../../../../src/common/time";
import { mockedObject } from "../../utils/mocking.helpers";
import { DirResult } from "tmp";
const now = Date.now();
// We don't want our times to align exactly with the hour,
@@ -21,12 +22,13 @@ const LESS_THAN_ONE_DAY = ONE_DAY_IN_MS - 1000;
describe("query history scrubber", () => {
let deregister: vscode.Disposable | undefined;
let tmpDir: DirResult;
const tmpDir = dirSync({
beforeEach(() => {
tmpDir = dirSync({
unsafeCleanup: true,
});
beforeEach(() => {
jest.spyOn(extLogger, "log").mockResolvedValue(undefined);
jest.useFakeTimers({
@@ -40,6 +42,7 @@ describe("query history scrubber", () => {
deregister.dispose();
deregister = undefined;
}
tmpDir.removeCallback();
});
it("should not throw an error when the query directory does not exist", async () => {