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(`
    {
      ".": {
        "BenchmarkRunner": "function",
        "EvaluatedModules": "function",
        "Snapshots": "object",
        "TestRunner": "function",
        "afterAll": "function",
        "afterEach": "function",
        "aroundAll": "function",
        "aroundEach": "function",
        "assert": "function",
        "assertType": "function",
        "beforeAll": "function",
        "beforeEach": "function",
        "bench": "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",
      },
      "./coverage": {
        "BaseCoverageProvider": "function",
      },
      "./environments": {
        "builtinEnvironments": "object",
        "populateGlobal": "function",
      },
      "./internal/browser": {
        "DecodedMap": "function",
        "SpyModule": "object",
        "Traces": "function",
        "__INTERNAL": "object",
        "browserFormat": "function",
        "collectTests": "function",
        "format": "function",
        "getOriginalPosition": "function",
        "getSafeTimers": "function",
        "getType": "function",
        "inspect": "function",
        "loadDiffConfig": "function",
        "loadSnapshotSerializers": "function",
        "processError": "function",
        "setSafeTimers": "function",
        "setupCommonEnv": "function",
        "startCoverageInsideWorker": "function",
        "startTests": "function",
        "stopCoverageInsideWorker": "function",
        "stringify": "function",
        "takeCoverageInsideWorker": "function",
      },
      "./node": {
        "AgentReporter": "function",
        "BaseCoverageProvider": "function",
        "BaseSequencer": "function",
        "BenchmarkReporter": "function",
        "BenchmarkReportsMap": "object",
        "DefaultReporter": "function",
        "DotReporter": "function",
        "ForksPoolWorker": "function",
        "GitNotFoundError": "function",
        "GithubActionsReporter": "function",
        "HangingProcessReporter": "function",
        "JUnitReporter": "function",
        "JsonReporter": "function",
        "ReportersMap": "object",
        "TapFlatReporter": "function",
        "TapReporter": "function",
        "TestsNotFoundError": "function",
        "ThreadsPoolWorker": "function",
        "TypecheckPoolWorker": "function",
        "VerboseBenchmarkReporter": "function",
        "VerboseReporter": "function",
        "VitestPackageInstaller": "function",
        "VitestPlugin": "function",
        "VmForksPoolWorker": "function",
        "VmThreadsPoolWorker": "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",
      },
      "./reporters": {
        "AgentReporter": "function",
        "BenchmarkReporter": "function",
        "BenchmarkReportsMap": "object",
        "DefaultReporter": "function",
        "DotReporter": "function",
        "GithubActionsReporter": "function",
        "HangingProcessReporter": "function",
        "JUnitReporter": "function",
        "JsonReporter": "function",
        "ReportersMap": "object",
        "TapFlatReporter": "function",
        "TapReporter": "function",
        "VerboseBenchmarkReporter": "function",
        "VerboseReporter": "function",
      },
      "./runners": {
        "NodeBenchmarkRunner": "function",
        "VitestTestRunner": "function",
      },
      "./runtime": {
        "VitestSnapshotEnvironment": "function",
        "__INTERNAL": "object",
        "builtinEnvironments": "object",
        "populateGlobal": "function",
      },
      "./snapshot": {
        "VitestSnapshotEnvironment": "function",
      },
      "./suite": {
        "createChainable": "function",
        "createTaskCollector": "function",
        "getBenchFn": "function",
        "getBenchOptions": "function",
        "getCurrentSuite": "function",
        "getCurrentTest": "function",
        "getFn": "function",
        "getHooks": "function",
        "setFn": "function",
        "setHooks": "function",
      },
      "./worker": {
        "init": "function",
        "runBaseTests": "function",
        "setupEnvironment": "function",
      },
    }
  `)
})
