feat(config): discover e2e.config.js and document a JavaScript setup
Merged
KA
7d ago+195+195+012345678901234567890123456789-49-49-01234567890123456789
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.jsande2e.config.mjsas well as.tsand.mts(packages/e2e/src/config/names.ts). - A TypeScript config wins in its directory, so the
e2e.config.jsthattscemits besidee2e.config.tsdoesn't start failing existing projects withCONFIG_AMBIGUOUS. Both TypeScript names, or both JavaScript names, together are still ambiguous. e2e inittreats an existing JavaScript config as existing, writes its example astests/example.e2e.js, and skips the "No tsconfig.json" hint.NO_TESTSnames 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_CONFIGhint for a missing default export dropssatisfies E2EConfigin a JavaScript config. - The default
testsglob staystests/**/*.e2e.ts. A JavaScript project setstestsitself, 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 newJavaScriptsection under Loading (JSDoc@type, ES modules, thetestsglob,// @ts-checkandjsconfig.json, importing a.tshelper), plus discovery rules under "Finding the config file".- The section's example is
docs/examples/javascript/e2e.config.js.docs/examplesnow typechecks.jswithcheckJs, so the JSDoc type is checked (a misspelled key failspnpm --filter @e2e-dev/docs typecheck). - The config names are updated wherever docs, skills, the
--confighelp, and the MCPopen_sessiondescription listed only.ts/.mts: errors, CLI, runner, the migration guides, andskills/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.jsandtests/hello.e2e.js, notsconfig.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.mjstests, and without"type": "module"(Node.js warns that it reparsed the file as ESM, which the docs mention). - A
.jstest importing a.tshelper ran.tsc -p jsconfig.jsonwith the documented options caught a misspelled config key. - Docs previewed with
mint dev:
| Quickstart | Config reference |
|---|---|