Skip to content

Commit

Permalink
test: use import.meta.glob
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 4, 2024
1 parent eae4ed7 commit 63d9817
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/snapshots/test/test-update.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import fs from 'node:fs/promises'
import { join } from 'node:path'
import { expect, test } from 'vitest'

const dir = join(import.meta.dirname, '../test-update')
const dirents = await fs.readdir(dir, { withFileTypes: true })
const files = dirents.filter(f => f.isFile() && f.name.includes('inline')).map(f => f.name)
test.for(files)('%s', async (file) => {
const content = await fs.readFile(join(dir, file), 'utf8')
expect(content).toMatchSnapshot()
})
const entries = import.meta.glob('../test-update/*inline*', { eager: true, query: 'raw' })
for (const [file, mod] of Object.entries(entries)) {
test(file.split('/').at(-1)!, () => {
expect((mod as any).default).toMatchSnapshot()
})
}

0 comments on commit 63d9817

Please sign in to comment.