Skip to content

Commit 3530382

Browse files
authored
Merge branch '4.x' into use-native-fetch
2 parents b608750 + eb1bcdc commit 3530382

70 files changed

Lines changed: 1899 additions & 547 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/appium_Android.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- 4.x
7-
- appium-esm-migration
87
pull_request:
98
branches:
109
- 4.x
@@ -22,6 +21,8 @@ env:
2221

2322
jobs:
2423
appium:
24+
# Run ONLY on the main repo AND (if it's a push OR a PR from the same repo)
25+
if: github.repository == 'codeceptjs/CodeceptJS' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
2526
runs-on: ubuntu-22.04
2627
timeout-minutes: 30
2728

.github/workflows/docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
echo "VERSION=$VERSION" >> $GITHUB_ENV
3030
echo "version=$VERSION" >> $GITHUB_OUTPUT
3131
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
3235
- name: Set up Docker Buildx
3336
uses: docker/setup-buildx-action@v4
3437

@@ -51,6 +54,7 @@ jobs:
5154
with:
5255
context: .
5356
push: true
57+
platforms: linux/amd64,linux/arm64
5458
tags: |
5559
${{ env.DOCKER_REPO }}:latest
5660
${{ env.DOCKER_REPO }}:${{ env.VERSION }}

.github/workflows/test.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
strategy:
2222
matrix:
23-
node-version: [20.x]
23+
node-version: [26.x]
2424

2525
steps:
2626
- uses: actions/checkout@v6
@@ -53,6 +53,27 @@ jobs:
5353
- name: Stop mock server
5454
run: npm run mock-server:stop
5555

56+
unit-tests-windows:
57+
name: Unit tests
58+
runs-on: windows-latest
59+
timeout-minutes: 15
60+
61+
strategy:
62+
matrix:
63+
node-version: [ 20.x ]
64+
65+
steps:
66+
- uses: actions/checkout@v6
67+
- name: Use Node.js ${{ matrix.node-version }}
68+
uses: actions/setup-node@v6
69+
with:
70+
node-version: ${{ matrix.node-version }}
71+
- run: npm i
72+
env:
73+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
74+
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
75+
- run: npm run test:unit:windows
76+
5677
runner-tests:
5778
name: Runner tests
5879
runs-on: ubuntu-22.04

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Vendored third-party bundles used by rich-text editor test fixtures
2+
test/data/app/js/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Download Playwright and its dependencies
2-
FROM mcr.microsoft.com/playwright:v1.55.0-noble
2+
FROM mcr.microsoft.com/playwright:v1.61.0-noble
33

44
# Set non-interactive mode for apt operations
55
ENV DEBIAN_FRONTEND=noninteractive

bin/codecept.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Codecept from '../lib/codecept.js'
55
import output from '../lib/output.js'
66
const { print, error } = output
77
import { printError } from '../lib/command/utils.js'
8+
import { resolveImportModulePath } from '../lib/utils.js'
89

910
const commandFlags = {
1011
ai: {
@@ -45,7 +46,8 @@ const errorHandler =
4546
}
4647

4748
const dynamicImport = async modulePath => {
48-
const module = await import(modulePath)
49+
const resolvedPath = resolveImportModulePath(modulePath)
50+
const module = await import(resolvedPath)
4951
return module.default || module
5052
}
5153

docs/agents.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ Agents get full control over test and browser execution:
2323

2424
CodeceptJS is token-efficient: it stores HTML, ARIA, logs, and HTTP request data as files instead of streaming them through MCP. Agents read these files with their native shell tools—no extra API calls, no redundant context.
2525

26+
## Essential Setup
27+
28+
Two things make agent testing work: the **skills** that teach the agent CodeceptJS, and the **MCP server** that lets it drive the browser. Set both up once, from your project directory.
29+
30+
Install the skills:
31+
32+
```bash
33+
npx skills add codeceptjs/skills
34+
```
35+
36+
Connect the MCP server (`npx codeceptjs-mcp`).
37+
38+
**Claude Code:**
39+
40+
```bash
41+
claude mcp add codeceptjs -- npx codeceptjs-mcp
42+
```
43+
44+
**Codex:**
45+
46+
```bash
47+
codex mcp add codeceptjs -- npx codeceptjs-mcp
48+
```
49+
50+
**Cursor** — add to `.cursor/mcp.json`:
51+
52+
```json
53+
{ "mcpServers": { "codeceptjs": { "command": "npx", "args": ["codeceptjs-mcp"] } } }
54+
```
55+
56+
See [/mcp](/mcp) for full client setup. Now the agent is ready to run the loop.
57+
2658
## The loop
2759

2860
Whether the agent is writing a new test or fixing an old one, it follows the same cycle.
@@ -96,31 +128,6 @@ Only `url` is inline. The rest are paths the agent opens with the right tool:
96128

97129
Saved HTML is formatted, with non-semantic elements stripped out: `<style>`, `<script>`, Tailwind-style trash classes, and inline `style=""` attributes. `grep` can then effectively find the correct tree branch in raw page source. ARIA snapshots are smaller and more structured than HTML, which is why the agent prefers them when picking locators.
98130

99-
## Setup
100-
101-
When CodeceptJS is installed, the MCP server can be launched with this command:
102-
103-
```bash
104-
npx codeceptjs-mcp
105-
```
106-
107-
> See [/mcp](/mcp) for detailed client setup.
108-
109-
We recommend pairing CodeceptJS MCP with the skills bundle.
110-
111-
Install for any agent:
112-
113-
```bash
114-
npx skills add codeceptjs/skills
115-
```
116-
117-
Or, in Claude Code:
118-
119-
```text
120-
/plugin marketplace add codeceptjs/skills
121-
/plugin install codeceptjs@codeceptjs-skills
122-
```
123-
124131
## Usage Examples
125132

126133
When MCP and skills are connected, the agent receives predefined workflows and can act effectively for testing purposes. Common scenarios it handles:

docs/configuration.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export const config = {
4444

4545
- `timeout` — default per-test timeout in seconds; a test is killed if it stops responding.
4646
- `mocha`[Mocha options](https://mochajs.org/#configuring-mocha-nodejs), including extra reporters. See [Reporters](/reports).
47+
- `workerInitializationDelay` — delay in milliseconds between spinning up parallel workers to prevent CPU spikes and stagger browser startup. Defaults to `200`. Set to `0` to disable.
48+
- `workerInitializationMaxDelay` — maximum total delay (in milliseconds) for worker initialization staggering. Defaults to `10000` (10 s). Set to `0` to disable capping.
4749

4850
**BDD**
4951

@@ -71,16 +73,18 @@ For TypeScript test files in CodeceptJS 4.x, use the [`tsx`](https://tsx.is) loa
7173
// codecept.conf.ts
7274
export const config = {
7375
tests: './**/*_test.ts',
74-
require: ['tsx/cjs'],
76+
require: ['tsx/esm'],
7577
helpers: {},
7678
include: {},
7779
}
7880
```
7981

82+
This requires `"type": "module"` in `package.json` so `.ts` test files are compiled as ES Modules.
83+
8084
Combine several modules:
8185

8286
```ts
83-
require: ['tsx/cjs', 'should', './lib/testSetup']
87+
require: ['tsx/esm', 'should', './lib/testSetup']
8488
```
8589

8690
The config file itself (`codecept.conf.ts`) and helpers are transpiled automatically — only test files need the loader. See [TypeScript](/typescript) for the full setup.

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ npm i tsx --save-dev
111111
// codecept.conf.ts
112112
export const config = {
113113
tests: './**/*_test.ts',
114-
require: ['tsx/cjs'], // loads the *_test.ts files
114+
require: ['tsx/esm'], // loads the *_test.ts files as ES Modules (needs "type": "module")
115115
helpers: {
116116
Playwright: { url: 'http://localhost', browser: 'chromium' },
117117
},

docs/migration-4.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,31 @@ title: Migrating from 3.x to 4.x
77

88
CodeceptJS 4.x is a major release. It moves the codebase from CommonJS to native ESM, drops several long-deprecated helpers and plugins, replaces legacy plugins with first-class APIs, and bumps most third-party dependencies.
99

10-
> Migrate automatically! Install CodeceptJS skills `npx skills add codeceptjs/skills` and run `/codeceptjs-3-to-4-migration` in your coding agent
10+
## Migrate Automatically with an Agent
1111

12-
This guide tells you exactly what to change in your project to upgrade.
12+
The fastest way to upgrade is to let an AI agent do it. This release is mechanical enough that an agent handles most of it end-to-end.
13+
14+
Install CodeceptJS 4:
15+
16+
```bash
17+
npm install codeceptjs@4
18+
```
19+
20+
Then install the skills bundle. It works the same in Claude Code or any other agent:
21+
22+
```bash
23+
npx skills add codeceptjs/skills
24+
```
25+
26+
The bundle ships a `migrate-codeceptjs-4` skill. Point an agent at the project and run it:
27+
28+
```bash
29+
claude "/migrate-codeceptjs-4"
30+
```
31+
32+
It reads your config and tests, applies the mechanical changes, runs the suite, and fixes what breaks.
33+
34+
The rest of this guide documents every change the skill makes — read it if you prefer to migrate by hand, or to review what the agent did.
1335

1436
## 1. Update Node and Package
1537

0 commit comments

Comments
 (0)