Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- run: npm install
- run: npm install -g npm@latest

- name: Generate TypeScript definitions
run: npm run def

- name: Set package version
run: |
TAG="${{ github.event.release.tag_name }}"
Expand Down
72 changes: 36 additions & 36 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,79 @@ title: Plugins

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

## [pause](/plugins/pause)
## [aiTrace](/plugins/aiTrace)

Pauses test execution interactively. Replaces the legacy `pauseOnFail` plugin. The default `on=fail` matches the old `pauseOnFail` behavior.
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.

## [pageInfo](/plugins/pageInfo)
## [analyze](/plugins/analyze)

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.
Uses AI to analyze test failures and provide insights

## [expose](/plugins/expose)
## [auth](/plugins/auth)

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:
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.

## [junitReporter](/plugins/junitReporter)
## [autoDelay](/plugins/autoDelay)

Generates a JUnit-compatible XML report after a test run.
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.

## [browser](/plugins/browser)

Overrides browser helper config from the command line. Works for all browser helpers (Playwright, Puppeteer, WebDriver, Appium) without touching `codecept.conf`.

## [coverage](/plugins/coverage)

Dumps code coverage from Playwright/Puppeteer after every test.

## [screenshot](/plugins/screenshot)
## [customLocator](/plugins/customLocator)

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

## [screencast](/plugins/screencast)
## [customReporter](/plugins/customReporter)

Records WebM video of tests using Playwright's screencast API.
Sample custom reporter for CodeceptJS.

## [customLocator](/plugins/customLocator)
## [expose](/plugins/expose)

Creates a [custom locator][1] by using special attributes in HTML.
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:

## [aiTrace](/plugins/aiTrace)
## [heal](/plugins/heal)

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.
Self-healing tests with AI.

## [auth](/plugins/auth)
## [junitReporter](/plugins/junitReporter)

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.
Generates a JUnit-compatible XML report after a test run.

## [pauseOnFail](/plugins/pauseOnFail)
## [pageInfo](/plugins/pageInfo)

Starts an interactive pause when a test fails.
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.

## [analyze](/plugins/analyze)
## [pause](/plugins/pause)

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

## [autoDelay](/plugins/autoDelay)
## [pauseOnFail](/plugins/pauseOnFail)

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.
Starts an interactive pause when a test fails.

## [stepTimeout](/plugins/stepTimeout)
## [retryFailedStep](/plugins/retryFailedStep)

Set timeout for test steps globally.
Retries each failed step in a test.

## [heal](/plugins/heal)
## [screencast](/plugins/screencast)

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

## [customReporter](/plugins/customReporter)
## [screenshot](/plugins/screenshot)

Sample custom reporter for CodeceptJS.
Saves screenshots from the browser at points triggered by `on=`.

## [screenshotOnFail](/plugins/screenshotOnFail)

Saves a screenshot when a test fails.

## [retryFailedStep](/plugins/retryFailedStep)

Retries each failed step in a test.

## [browser](/plugins/browser)
## [stepTimeout](/plugins/stepTimeout)

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

2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ My First Test --
Run in headless mode:

```
npx codeceptjs run --headless
npx codeceptjs run --p browser:hide
```

See all available commands in the [CLI reference](https://codecept.io/commands/).
Expand Down
11 changes: 4 additions & 7 deletions lib/command/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,10 @@ function getImportString(testsPath, targetFolderPath, pathsToType, pathsToValue)
for (const name in pathsToType) {
const originalPath = pathsToType[name]
const relativePath = getPath(originalPath, targetFolderPath, testsPath)
// For .js files with plain object exports, access .default to allow TypeScript to extract properties
// For .ts files, the default export is handled differently by TypeScript
if (originalPath.endsWith('.js')) {
importStrings.push(`type ${name} = typeof import('${relativePath}').default;`)
} else {
importStrings.push(`type ${name} = typeof import('${relativePath}');`)
}
// 4.x is ESM-first: step files and page objects use `export default`,
// so the type is reached via `.default` regardless of file extension
// (.js, .ts, or no extension, as set in `include`).
importStrings.push(`type ${name} = typeof import('${relativePath}').default;`)
}

for (const name in pathsToValue) {
Expand Down
2 changes: 1 addition & 1 deletion lib/command/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default {

const poModuleTemplateTS = `const { I } = inject();
export = {
export default {
// insert your locators and methods here
}
Expand Down
2 changes: 1 addition & 1 deletion lib/command/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function() {
const defaultActorTs = `// in this file you can append custom step methods to 'I' object
import { actor } from 'codeceptjs';

export = function() {
export default function() {
return actor({

// Define custom steps here, use 'this' to access default methods of I.
Expand Down
17 changes: 8 additions & 9 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,14 @@ describe('Playwright', function () {
await I.waitToHide('h9')
})

it('should wait for invisible combined with dontseeElement', async function () {
this.timeout(30000) // Increase timeout for external URL test
await I.amOnPage('https://codecept.io/')
await I.waitForVisible('.frameworks', 10)
await I.waitForVisible('[alt="React"]', 10)
await I.waitForVisible('.mountains', 10)
await I._withinBegin('.mountains', async () => {
await I.dontSeeElement('[alt="React"]')
await I.waitForInvisible('[alt="React"]', 2)
it('should wait for invisible combined with dontseeElement', async () => {
await I.amOnPage('/info')
await I.waitForVisible('#grab-multiple', 10)
await I.waitForVisible('a[id="first-link"]', 10)
await I.waitForVisible('#grab-css', 10)
await I._withinBegin('#grab-css', async () => {
await I.dontSeeElement('a[id="first-link"]')
await I.waitForInvisible('a[id="first-link"]', 2)
})
})
})
Expand Down
8 changes: 4 additions & 4 deletions test/helper/WebDriver_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ describe('WebDriver', function () {
})

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

try {
await wd.seeTextEquals('', '.logo')
await wd.seeTextEquals('This is not empty', '.logo')
await wd.seeTextEquals('', '#p-no-text')
await wd.seeTextEquals('This is not empty', '#p-no-text')
} catch (e) {
expect(e).to.be.instanceOf(Error)
expect(e.message).to.equal('expected element .logo "This is not empty" to equal ""')
expect(e.message).to.equal('expected element #p-no-text "This is not empty" to equal ""')
}
})
})
Expand Down