feat: add vitest-package-exports tests

This commit is contained in:
Anthony Fu committed 2025-03-05 12:43:25 +08:00
1 parent 11e95cd5da
commit 49248f74e2
6 files changed
+1076 -1349

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import yaml from 'js-yaml'
import { x } from 'tinyexec'
import { describe, expect, it } from 'vitest'
import { getPackageExportsManifest } from 'vitest-package-exports'
// TODO: remove this when you are ready for the first release
const IS_READY = false
describe.runIf(IS_READY)('exports-snapshot', async () => {
const packages: { name: string, path: string, private?: boolean }[] = JSON.parse(
await x('pnpm', ['ls', '--only-projects', '-r', '--json']).then(r => r.stdout),
)
for (const pkg of packages) {
if (pkg.private)
continue
it(`${pkg.name}`, async () => {
const manifest = await getPackageExportsManifest({
importMode: 'src',
cwd: pkg.path,
})
await expect(yaml.dump(manifest.exports, { sortKeys: (a, b) => a.localeCompare(b) }))
.toMatchFileSnapshot(`./exports/${pkg.name}.yaml`)
})
}
})