-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test importing a file generated during test (#6301)
Co-authored-by: Vladimir <[email protected]>
- Loading branch information
1 parent
52917ab
commit 80c553a
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { expect, test } from "vitest" | ||
import fs from "node:fs" | ||
import path from "node:path" | ||
|
||
test("import a generated file", async () => { | ||
const dist = path.join(import.meta.dirname, "dist"); | ||
await fs.promises.mkdir(dist, { recursive: true }); | ||
await fs.promises.writeFile(path.join(dist, "generated.js"), `export default 'ok'`); | ||
|
||
// @ts-ignore generated | ||
const mod = await import("./dist/generated.js") | ||
|
||
expect(mod.default).toBe("ok"); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { expect, test } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
test('import a generated file', async () => { | ||
// ensure removed first | ||
const root = path.resolve('fixtures/fs-cached-check') | ||
await fs.promises.rm(path.join(root, 'dist'), { recursive: true, force: true }) | ||
|
||
const { stderr, exitCode } = await runVitest({ root }) | ||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
}) |