@@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The isolation suite reads the fixtures of registered modules only (template lesson core-2): a module folder
|
||||
// kept in the repository but not registered must not fail it.
|
||||
|
||||
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { afterEach, expect, it } from "vitest"
|
||||
import { isolationFilesOf } from "./support/module-isolations.js"
|
||||
|
||||
const made: string[] = []
|
||||
afterEach(() => {
|
||||
for (const dir of made.splice(0)) rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
function modulesWith(layout: Record<string, boolean>): string {
|
||||
const dir = mkdtempSync(join(tmpdir(), "isolation-modules-"))
|
||||
made.push(dir)
|
||||
for (const [id, hasFixtures] of Object.entries(layout)) {
|
||||
mkdirSync(join(dir, id, "__tests__"), { recursive: true })
|
||||
if (hasFixtures) writeFileSync(join(dir, id, "__tests__", "isolation.ts"), "export const isolation = {}\n")
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
it("reads the fixtures of the registered modules and skips a held module's", () => {
|
||||
const dir = modulesWith({ widgets: true, held: true, plain: false })
|
||||
expect(isolationFilesOf(dir, ["widgets", "plain"])).toEqual([join(dir, "widgets", "__tests__", "isolation.ts")])
|
||||
})
|
||||
Reference in New Issue
Block a user