mirror of
https://github.com/pnpm/pnpm.git
synced 2026-06-28 09:55:39 -04:00
Replace the external `@pnpm/registry-mock` (Verdaccio) test dependency with an in-repo, in-process registry that serves package fixtures to **both** the pacquet Rust tests and the pnpm CLI (Jest) tests. No separately managed registry process is needed. ### How it works - **Fixtures** live at `registry/.fixtures/packages/<name>/<version>/…`, moved verbatim from [`pnpm/registry-mock`](https://github.com/pnpm/registry-mock) (keyed by each `package.json`'s `name`+`version`). - **`pnpm-registry-fixtures`** builds verdaccio-shaped storage from those fixtures; the in-tree **`pnpm-registry`** crate serves it. - Files whose names differ only by case (`@pnpm.e2e/with-same-file-in-different-cases`) and `bundleDependencies` trees are composed **in memory** by the builder, since neither can be committed to the working tree. - **pacquet**: `pacquet-testing-utils`' `TestRegistry` starts the server lazily (once per process) in proxy mode, serving `@pnpm.e2e` fixtures locally and falling through to the npm uplink for real packages (`is-positive`, `is-negative`, …) — matching how registry-mock behaved. - **pnpm CLI**: the `with-registry` Jest `globalSetup` builds storage from the fixtures via the new `pnpm-registry-prepare` binary (built from source in the Test CI job) and serves it with `pnpm-registry`. `REGISTRY_MOCK_PORT` / `REGISTRY_MOCK_CREDENTIALS` / `getIntegrity` now come from `@pnpm/testing.registry-mock`. ### Result `@pnpm/registry-mock` is removed from every manifest, the catalog, and `packageExtensions`; `cargo test` / `cargo nextest run` / `just test` and the pnpm CLI Jest suites all run registry-backed tests without launching Verdaccio.
75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import type { CustomResolver } from '@pnpm/hooks.types'
|
|
import type { InstallOptions } from '@pnpm/installing.deps-installer'
|
|
import type { ResolutionVerifier } from '@pnpm/resolving.resolver-base'
|
|
import type { StoreController } from '@pnpm/store.controller-types'
|
|
import { REGISTRY_MOCK_PORT } from '@pnpm/testing.registry-mock'
|
|
import { createTempStore } from '@pnpm/testing.temp-store'
|
|
import type { Registries } from '@pnpm/types'
|
|
|
|
const registry = `http://localhost:${REGISTRY_MOCK_PORT}/`
|
|
|
|
export function testDefaults<T> (
|
|
opts?: T & {
|
|
fastUnpack?: boolean
|
|
storeDir?: string
|
|
prefix?: string
|
|
registries?: Registries
|
|
customResolvers?: CustomResolver[]
|
|
minimumReleaseAge?: number
|
|
minimumReleaseAgeStrict?: boolean
|
|
minimumReleaseAgeExclude?: string[]
|
|
},
|
|
resolveOpts?: any, // eslint-disable-line
|
|
fetchOpts?: any, // eslint-disable-line
|
|
storeOpts?: any // eslint-disable-line
|
|
): InstallOptions &
|
|
{
|
|
cacheDir: string
|
|
registries: Registries
|
|
storeController: StoreController
|
|
storeDir: string
|
|
resolutionVerifiers: ResolutionVerifier[]
|
|
} &
|
|
T {
|
|
// Forward minimumReleaseAge policy into the Client so it builds the
|
|
// matching ResolutionVerifier; tests that set these options exercise the
|
|
// same code path the CLI command would.
|
|
const policyClientOptions = {
|
|
...(opts?.minimumReleaseAge != null ? { minimumReleaseAge: opts.minimumReleaseAge } : {}),
|
|
...(opts?.minimumReleaseAgeStrict != null ? { minimumReleaseAgeStrict: opts.minimumReleaseAgeStrict } : {}),
|
|
...(opts?.minimumReleaseAgeExclude != null ? { minimumReleaseAgeExclude: opts.minimumReleaseAgeExclude } : {}),
|
|
}
|
|
const { storeController, storeDir, cacheDir, resolutionVerifiers } = createTempStore({
|
|
...opts,
|
|
clientOptions: {
|
|
...(opts?.registries != null ? { registries: opts.registries } : {}),
|
|
customResolvers: opts?.customResolvers,
|
|
...policyClientOptions,
|
|
...resolveOpts,
|
|
...fetchOpts,
|
|
},
|
|
storeOptions: storeOpts,
|
|
})
|
|
const result = {
|
|
cacheDir,
|
|
registries: {
|
|
default: registry,
|
|
},
|
|
storeController,
|
|
storeDir,
|
|
resolutionVerifiers,
|
|
...opts,
|
|
} as (
|
|
InstallOptions &
|
|
{
|
|
cacheDir: string
|
|
registries: Registries
|
|
storeController: StoreController
|
|
storeDir: string
|
|
resolutionVerifiers: ResolutionVerifier[]
|
|
} &
|
|
T
|
|
)
|
|
return result
|
|
}
|