feat(config): bring back defineConfig (ENG-819)
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
defineConfig<const Config extends E2EConfig>returnsconfigunchanged (packages/e2e/src/config/define.ts:10). Theconsttype parameter keeps literal types, and theExclude<keyof Config, keyof E2EConfig>mapped tonevermakes an unknown top-level key a type error.e2eexports it (packages/e2e/src/index.ts:4).diagnose.tsdrops its "defineConfig was removed in e2e 0.5" message and listsdefineConfigwith the other exports (packages/e2e/src/config/diagnose.ts:24).tests/types/sdk-types.tschecks that the inferred type stays narrow, thattest.extend<{}, {}, typeof config>types the fixtures, and that an unknown key is an error.- Docs: a
defineConfigentry indocs/reference/config.mdx, anddefineConfigbesidesatisfies E2EConfigindocs/reference/test.mdxand thedebuggingandwriting-testsskill pages.
Verified
Ran it locally: yes
pnpm checkandpnpm teston this branch, including thesdk-types.tsassertions undertypecheck.- 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.