Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test importing a file generated during test #6301

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/config/fixtures/fs-cached-check/basic.test.ts
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");
})
14 changes: 14 additions & 0 deletions test/config/test/fs-cached-check.test.ts
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)
})
Loading