Skip to content

Commit c07b826

Browse files
DavertMikDavertMikclaude
authored
fixed esm compatible def (#5576)
* fixed esm compatible def * test: stop hitting codecept.io live site for flake-prone selectors The .frameworks/.mountains/[alt="React"] and .logo selectors no longer exist on the new codecept.io homepage, so two specs went red: - Playwright_test.js: 'should wait for invisible combined with dontseeElement' - WebDriver_test.js: 'should check text is not equal to empty string of element text' Point both at the local /info fixture using elements that already exist there (#grab-multiple, a[id="first-link"], #grab-css, #p-no-text). Same assertions, no external network dependency. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: DavertMik <davert@testomat.io> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f677620 commit c07b826

8 files changed

Lines changed: 58 additions & 59 deletions

File tree

.github/workflows/publish-beta.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- run: npm install
2626
- run: npm install -g npm@latest
2727

28+
- name: Generate TypeScript definitions
29+
run: npm run def
30+
2831
- name: Set package version
2932
run: |
3033
TAG="${{ github.event.release.tag_name }}"

docs/plugins.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,79 @@ title: Plugins
99

1010
CodeceptJS bundles the following plugins. Each plugin has its own page with full configuration reference.
1111

12-
## [pause](/plugins/pause)
12+
## [aiTrace](/plugins/aiTrace)
1313

14-
Pauses test execution interactively. Replaces the legacy `pauseOnFail` plugin. The default `on=fail` matches the old `pauseOnFail` behavior.
14+
Generates AI-friendly trace files for debugging with AI agents. This plugin creates a markdown file with test execution logs and links to all artifacts (screenshots, HTML, ARIA snapshots, browser logs, HTTP requests) for each step.
1515

16-
## [pageInfo](/plugins/pageInfo)
16+
## [analyze](/plugins/analyze)
1717

18-
Collects information from web page after each failed test and adds it to the test as an artifact. It is suggested to enable this plugin if you run tests on CI and you need to debug failed tests. This plugin can be paired with `analyze` plugin to provide more context.
18+
Uses AI to analyze test failures and provide insights
1919

20-
## [expose](/plugins/expose)
20+
## [auth](/plugins/auth)
2121

22-
Exposes properties from helper instances as injectable test arguments. Use it to access the underlying Playwright/Puppeteer `page`, the wdio `browser` client, or any other helper internal directly from a Scenario:
22+
Logs user in for the first test and reuses session for next tests. Works by saving cookies into memory or file. If a session expires automatically logs in again.
2323

24-
## [junitReporter](/plugins/junitReporter)
24+
## [autoDelay](/plugins/autoDelay)
2525

26-
Generates a JUnit-compatible XML report after a test run.
26+
Sometimes it takes some time for a page to respond to user's actions. Depending on app's performance this can be either slow or fast.
27+
28+
## [browser](/plugins/browser)
29+
30+
Overrides browser helper config from the command line. Works for all browser helpers (Playwright, Puppeteer, WebDriver, Appium) without touching `codecept.conf`.
2731

2832
## [coverage](/plugins/coverage)
2933

3034
Dumps code coverage from Playwright/Puppeteer after every test.
3135

32-
## [screenshot](/plugins/screenshot)
36+
## [customLocator](/plugins/customLocator)
3337

34-
Saves screenshots from the browser at points triggered by `on=`.
38+
Creates a [custom locator][1] by using special attributes in HTML.
3539

36-
## [screencast](/plugins/screencast)
40+
## [customReporter](/plugins/customReporter)
3741

38-
Records WebM video of tests using Playwright's screencast API.
42+
Sample custom reporter for CodeceptJS.
3943

40-
## [customLocator](/plugins/customLocator)
44+
## [expose](/plugins/expose)
4145

42-
Creates a [custom locator][1] by using special attributes in HTML.
46+
Exposes properties from helper instances as injectable test arguments. Use it to access the underlying Playwright/Puppeteer `page`, the wdio `browser` client, or any other helper internal directly from a Scenario:
4347

44-
## [aiTrace](/plugins/aiTrace)
48+
## [heal](/plugins/heal)
4549

46-
Generates AI-friendly trace files for debugging with AI agents. This plugin creates a markdown file with test execution logs and links to all artifacts (screenshots, HTML, ARIA snapshots, browser logs, HTTP requests) for each step.
50+
Self-healing tests with AI.
4751

48-
## [auth](/plugins/auth)
52+
## [junitReporter](/plugins/junitReporter)
4953

50-
Logs user in for the first test and reuses session for next tests. Works by saving cookies into memory or file. If a session expires automatically logs in again.
54+
Generates a JUnit-compatible XML report after a test run.
5155

52-
## [pauseOnFail](/plugins/pauseOnFail)
56+
## [pageInfo](/plugins/pageInfo)
5357

54-
Starts an interactive pause when a test fails.
58+
Collects information from web page after each failed test and adds it to the test as an artifact. It is suggested to enable this plugin if you run tests on CI and you need to debug failed tests. This plugin can be paired with `analyze` plugin to provide more context.
5559

56-
## [analyze](/plugins/analyze)
60+
## [pause](/plugins/pause)
5761

58-
Uses AI to analyze test failures and provide insights
62+
Pauses test execution interactively. Replaces the legacy `pauseOnFail` plugin. The default `on=fail` matches the old `pauseOnFail` behavior.
5963

60-
## [autoDelay](/plugins/autoDelay)
64+
## [pauseOnFail](/plugins/pauseOnFail)
6165

62-
Sometimes it takes some time for a page to respond to user's actions. Depending on app's performance this can be either slow or fast.
66+
Starts an interactive pause when a test fails.
6367

64-
## [stepTimeout](/plugins/stepTimeout)
68+
## [retryFailedStep](/plugins/retryFailedStep)
6569

66-
Set timeout for test steps globally.
70+
Retries each failed step in a test.
6771

68-
## [heal](/plugins/heal)
72+
## [screencast](/plugins/screencast)
6973

70-
Self-healing tests with AI.
74+
Records WebM video of tests using Playwright's screencast API.
7175

72-
## [customReporter](/plugins/customReporter)
76+
## [screenshot](/plugins/screenshot)
7377

74-
Sample custom reporter for CodeceptJS.
78+
Saves screenshots from the browser at points triggered by `on=`.
7579

7680
## [screenshotOnFail](/plugins/screenshotOnFail)
7781

7882
Saves a screenshot when a test fails.
7983

80-
## [retryFailedStep](/plugins/retryFailedStep)
81-
82-
Retries each failed step in a test.
83-
84-
## [browser](/plugins/browser)
84+
## [stepTimeout](/plugins/stepTimeout)
8585

86-
Overrides browser helper config from the command line. Works for all browser helpers (Playwright, Puppeteer, WebDriver, Appium) without touching `codecept.conf`.
86+
Set timeout for test steps globally.
8787

docs/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ My First Test --
112112
Run in headless mode:
113113

114114
```
115-
npx codeceptjs run --headless
115+
npx codeceptjs run --p browser:hide
116116
```
117117

118118
See all available commands in the [CLI reference](https://codecept.io/commands/).

lib/command/definitions.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,10 @@ function getImportString(testsPath, targetFolderPath, pathsToType, pathsToValue)
231231
for (const name in pathsToType) {
232232
const originalPath = pathsToType[name]
233233
const relativePath = getPath(originalPath, targetFolderPath, testsPath)
234-
// For .js files with plain object exports, access .default to allow TypeScript to extract properties
235-
// For .ts files, the default export is handled differently by TypeScript
236-
if (originalPath.endsWith('.js')) {
237-
importStrings.push(`type ${name} = typeof import('${relativePath}').default;`)
238-
} else {
239-
importStrings.push(`type ${name} = typeof import('${relativePath}');`)
240-
}
234+
// 4.x is ESM-first: step files and page objects use `export default`,
235+
// so the type is reached via `.default` regardless of file extension
236+
// (.js, .ts, or no extension, as set in `include`).
237+
importStrings.push(`type ${name} = typeof import('${relativePath}').default;`)
241238
}
242239

243240
for (const name in pathsToValue) {

lib/command/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default {
8787

8888
const poModuleTemplateTS = `const { I } = inject();
8989
90-
export = {
90+
export default {
9191
9292
// insert your locators and methods here
9393
}

lib/command/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function() {
5858
const defaultActorTs = `// in this file you can append custom step methods to 'I' object
5959
import { actor } from 'codeceptjs';
6060
61-
export = function() {
61+
export default function() {
6262
return actor({
6363
6464
// Define custom steps here, use 'this' to access default methods of I.

test/helper/Playwright_test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,14 @@ describe('Playwright', function () {
200200
await I.waitToHide('h9')
201201
})
202202

203-
it('should wait for invisible combined with dontseeElement', async function () {
204-
this.timeout(30000) // Increase timeout for external URL test
205-
await I.amOnPage('https://codecept.io/')
206-
await I.waitForVisible('.frameworks', 10)
207-
await I.waitForVisible('[alt="React"]', 10)
208-
await I.waitForVisible('.mountains', 10)
209-
await I._withinBegin('.mountains', async () => {
210-
await I.dontSeeElement('[alt="React"]')
211-
await I.waitForInvisible('[alt="React"]', 2)
203+
it('should wait for invisible combined with dontseeElement', async () => {
204+
await I.amOnPage('/info')
205+
await I.waitForVisible('#grab-multiple', 10)
206+
await I.waitForVisible('a[id="first-link"]', 10)
207+
await I.waitForVisible('#grab-css', 10)
208+
await I._withinBegin('#grab-css', async () => {
209+
await I.dontSeeElement('a[id="first-link"]')
210+
await I.waitForInvisible('a[id="first-link"]', 2)
212211
})
213212
})
214213
})

test/helper/WebDriver_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,14 @@ describe('WebDriver', function () {
424424
})
425425

426426
it('should check text is not equal to empty string of element text', async () => {
427-
await wd.amOnPage('https://codecept.io')
427+
await wd.amOnPage('/info')
428428

429429
try {
430-
await wd.seeTextEquals('', '.logo')
431-
await wd.seeTextEquals('This is not empty', '.logo')
430+
await wd.seeTextEquals('', '#p-no-text')
431+
await wd.seeTextEquals('This is not empty', '#p-no-text')
432432
} catch (e) {
433433
expect(e).to.be.instanceOf(Error)
434-
expect(e.message).to.equal('expected element .logo "This is not empty" to equal ""')
434+
expect(e.message).to.equal('expected element #p-no-text "This is not empty" to equal ""')
435435
}
436436
})
437437
})

0 commit comments

Comments
 (0)