Move tmpdir test helper to test helpers file
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
import * as fs from "fs"
|
||||
import { tmpdir } from "../../test/utils/constants"
|
||||
import { loggerModule } from "../utils/helpers"
|
||||
|
||||
// jest.mock is hoisted above the imports so we must use `require` here.
|
||||
@ -89,16 +87,3 @@ describe("constants", () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("test constants", () => {
|
||||
describe("tmpdir", () => {
|
||||
it("should return a temp directory", async () => {
|
||||
const testName = "temp-dir"
|
||||
const pathToTempDir = await tmpdir(testName)
|
||||
|
||||
expect(pathToTempDir).toContain(testName)
|
||||
|
||||
await fs.promises.rmdir(pathToTempDir)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
14
test/unit/helpers.test.ts
Normal file
14
test/unit/helpers.test.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { promises as fs } from "fs"
|
||||
import { tmpdir } from "../../test/utils/helpers"
|
||||
|
||||
/**
|
||||
* This file is for testing test helpers (not core code).
|
||||
*/
|
||||
describe("test helpers", () => {
|
||||
it("should return a temp directory", async () => {
|
||||
const testName = "temp-dir"
|
||||
const pathToTempDir = await tmpdir(testName)
|
||||
expect(pathToTempDir).toContain(testName)
|
||||
expect(fs.access(pathToTempDir)).resolves.toStrictEqual(undefined)
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user