feat(config): discover e2e.config.js and document a JavaScript setup

Merged
KA
7d ago
+195-49

A project written in plain JavaScript can now use e2e without --config on every command, and the docs show how to set it up.

  • Discovery reads e2e.config.js and e2e.config.mjs as well as .ts and .mts (packages/e2e/src/config/names.ts).
  • A TypeScript config wins in its directory, so the e2e.config.js that tsc emits beside e2e.config.ts doesn't start failing existing projects with CONFIG_AMBIGUOUS. Both TypeScript names, or both JavaScript names, together are still ambiguous.
  • e2e init treats an existing JavaScript config as existing, writes its example as tests/example.e2e.js, and skips the "No tsconfig.json" hint.
  • NO_TESTS names the glob to set when every near miss is *.e2e.js (or every one is *.e2e.mjs), instead of saying "rename to *.e2e.ts".
  • The INVALID_CONFIG hint for a missing default export drops satisfies E2EConfig in a JavaScript config.
  • The default tests glob stays tests/**/*.e2e.ts. A JavaScript project sets tests itself, which the docs say.

Docs:

  • Quickstart: a folded "Use JavaScript instead of TypeScript" section in "Create the test project". It shows only the lines that change, so it works for the web and mobile configs.
  • reference/config: a new JavaScript section under Loading (JSDoc @type, ES modules, the tests glob, // @ts-check and jsconfig.json, importing a .ts helper), plus discovery rules under "Finding the config file".
  • The section's example is docs/examples/javascript/e2e.config.js. docs/examples now typechecks .js with checkJs, so the JSDoc type is checked (a misspelled key fails pnpm --filter @e2e-dev/docs typecheck).
  • The config names are updated wherever docs, skills, the --config help, and the MCP open_session description listed only .ts/.mts: errors, CLI, runner, the migration guides, and skills/e2e.
/** @type {import('e2e').E2EConfig} */
export default {
  tests: 'tests/**/*.e2e.js',
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
};

Verified

Ran it locally: yes

  • Scratch project with the built CLI and @e2e-dev/web, a static page, e2e.config.js and tests/hello.e2e.js, no tsconfig.json:
### 1. JS config, tests glob not set
 ERROR  configuration error NO_TESTS (collection)
no test file matched "tests/**/*.e2e.ts" under …/jsproj; found tests/hello.e2e.js, which the pattern does not match: set tests in the config to a glob such as "tests/**/*.e2e.js"; pass --pass-with-no-tests to allow this
### 2. tests set
 ✓ target "web" command ready 192ms
 ✓ |web| tests/hello.e2e.js (1 test) 433ms
   ✓ greets 433ms
 Test Files  1 passed (1)
### 3. e2e init with JS config
▲  Exists, not touching: e2e.config.js
◆  Created tests/example.e2e.js
### 4. TS config beside emitted JS
NO_TESTS: no test file matched "tests/**/*.e2e.ts" …   (the .ts config was picked, with its default glob)
  • Also passed with e2e.config.mjs + *.e2e.mjs tests, and without "type": "module" (Node.js warns that it reparsed the file as ESM, which the docs mention).
  • A .js test importing a .ts helper ran. tsc -p jsconfig.json with the documented options caught a misspelled config key.
  • Docs previewed with mint dev:
QuickstartConfig reference
quickstartconfig reference