feat(config): bring back defineConfig (ENG-819)

Merged
SA
5d ago
+78-11

First of four stacked PRs. The others build on this one: #2191 (services), then the app.command.env function, then services in e2e mcp and openHost.

What

defineConfig is back in e2e:

import { defineConfig } from 'e2e';
import { web } from '@e2e-dev/web';

export default defineConfig({
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
});

It returns the config as it is and keeps its inferred type, so typeof config still types the fixtures of test.extend. An unknown top-level key is a type error, as with satisfies E2EConfig. satisfies E2EConfig keeps working.

Why

#2191 needs a function that can read the config's services type and pass it to an env function in the same config, and satisfies E2EConfig can't do that. That PR adds the services generics. This one brings the function back on its own, so it can be reviewed apart from services.

How it works

  1. defineConfig<const Config extends E2EConfig> returns config unchanged (packages/e2e/src/config/define.ts:10). The const type parameter keeps literal types, and the Exclude<keyof Config, keyof E2EConfig> mapped to never makes an unknown top-level key a type error.
  2. e2e exports it (packages/e2e/src/index.ts:4). diagnose.ts drops its "defineConfig was removed in e2e 0.5" message and lists defineConfig with the other exports (packages/e2e/src/config/diagnose.ts:24).
  3. tests/types/sdk-types.ts checks that the inferred type stays narrow, that test.extend<{}, {}, typeof config> types the fixtures, and that an unknown key is an error.
  4. Docs: a defineConfig entry in docs/reference/config.mdx, and defineConfig beside satisfies E2EConfig in docs/reference/test.mdx and the debugging and writing-tests skill pages.

Verified

Ran it locally: yes

  • pnpm check and pnpm test on this branch, including the sdk-types.ts assertions under typecheck.
  • The built CLI at the top of the stack ran the services docs example, whose config uses defineConfig (output in the last PR of the stack).

No terminal output or on-screen behavior changes. Docs screenshots: not captured, the change is one new reference entry.