import { resolve } from 'node:path'
import { expect, it } from 'vitest'
import { getPackageExportsManifest } from 'vitest-package-exports'

it('exports snapshot', async ({ skip, task }) => {
  skip(task.file.pool !== 'threads', 'run only once inside threads')

  const manifest = await getPackageExportsManifest({
    importMode: 'package', // or 'dist' or 'package'
    cwd: resolve(import.meta.dirname, '../../../packages/vitest'),
    resolveExportEntries(entries) {
      return entries.filter(([key]) => key !== './browser')
    },
  })
  manifest.exports['./node'].rolldownVersion = 'conditional'

  expect(manifest.exports).toMatchInlineSnapshot(`
    {
      ".": {
        "EvaluatedModules": "function",
        "Snapshots": "object",
        "TestRunner": "function",
        "afterAll": "function",
        "afterEach": "function",
        "aroundAll": "function",
        "aroundEach": "function",
        "assert": "function",
        "assertType": "function",
        "beforeAll": "function",
        "beforeEach": "function",
        "chai": "object",
        "createExpect": "function",
        "describe": "function",
        "expect": "function",
        "expectTypeOf": "function",
        "inject": "function",
        "it": "function",
        "onTestFailed": "function",
        "onTestFinished": "function",
        "recordArtifact": "function",
        "should": "function",
        "suite": "function",
        "test": "function",
        "vi": "object",
        "vitest": "object",
      },
      "./config": {
        "configDefaults": "object",
        "coverageConfigDefaults": "object",
        "defaultBrowserPort": "number",
        "defaultExclude": "object",
        "defaultInclude": "object",
        "defineConfig": "function",
        "defineProject": "function",
        "mergeConfig": "function",
      },
      "./internal/browser": {
        "DecodedMap": "function",
        "SpyModule": "object",
        "__INTERNAL": "object",
        "collectTests": "function",
        "format": "function",
        "getOriginalPosition": "function",
        "getSafeTimers": "function",
        "getType": "function",
        "inspect": "function",
        "loadDiffConfig": "function",
        "loadSnapshotSerializers": "function",
        "processError": "function",
        "setSafeTimers": "function",
        "setupCommonEnv": "function",
        "setupEnv": "function",
        "startCoverageInsideWorker": "function",
        "startTests": "function",
        "stopCoverageInsideWorker": "function",
        "stringify": "function",
        "takeCoverageInsideWorker": "function",
      },
      "./internal/traces": {
        "Traces": "function",
      },
      "./node": {
        "AgentReporter": "function",
        "BaseCoverageProvider": "function",
        "BaseSequencer": "function",
        "DefaultReporter": "function",
        "DotReporter": "function",
        "ForksPoolWorker": "function",
        "GitNotFoundError": "function",
        "GithubActionsReporter": "function",
        "HangingProcessReporter": "function",
        "JUnitReporter": "function",
        "JsonReporter": "function",
        "Logger": "function",
        "MinimalReporter": "function",
        "PluginHarness": "function",
        "ReportersMap": "object",
        "TapFlatReporter": "function",
        "TapReporter": "function",
        "TestsNotFoundError": "function",
        "ThreadsPoolWorker": "function",
        "TypecheckPoolWorker": "function",
        "VerboseReporter": "function",
        "VitestPackageInstaller": "function",
        "VmForksPoolWorker": "function",
        "VmThreadsPoolWorker": "function",
        "createCLI": "function",
        "createDebugger": "function",
        "createMethodsRPC": "function",
        "createViteLogger": "function",
        "createViteServer": "function",
        "createVitest": "function",
        "distDir": "string",
        "esbuildVersion": "string",
        "escapeTestName": "function",
        "experimental_getRunnerTask": "function",
        "generateFileHash": "function",
        "getFilePoolName": "function",
        "isCSSRequest": "function",
        "isFileLoadingAllowed": "function",
        "isFileServingAllowed": "function",
        "isValidApiRequest": "function",
        "parseAst": "function",
        "parseAstAsync": "function",
        "parseCLI": "function",
        "registerConsoleShortcuts": "function",
        "resolveApiServerConfig": "function",
        "resolveConfig": "function",
        "resolveFsAllow": "function",
        "rolldownVersion": "conditional",
        "rollupVersion": "string",
        "rootDir": "string",
        "startVitest": "function",
        "version": "string",
        "viteVersion": "string",
      },
      "./runtime": {
        "VitestSnapshotEnvironment": "function",
        "__INTERNAL": "object",
        "builtinEnvironments": "object",
        "populateGlobal": "function",
      },
      "./worker": {
        "init": "function",
        "runBaseTests": "function",
        "setupEnvironment": "function",
      },
    }
  `)
})
