Skip to content

feat(jest-circus): add test.step() method for test step reporting#16157

Open
quick123-666 wants to merge 1 commit into
jestjs:mainfrom
quick123-666:feat/test-step
Open

feat(jest-circus): add test.step() method for test step reporting#16157
quick123-666 wants to merge 1 commit into
jestjs:mainfrom
quick123-666:feat/test-step

Conversation

@quick123-666
Copy link
Copy Markdown

Summary

Adds test.step() / it.step() method to Jest's circus test runner, similar to Playwright's test.step. This allows users to add named steps within a test body for better error reporting.

Features

  • test.step(title, body) - wraps a test step with a descriptive name
  • Nested steps are supported (displayed as parent > child in error messages)
  • Errors thrown inside a step include the step path in the error message
  • Works with both sync and async callbacks
  • Compatible with concurrent tests via AsyncLocalStorage
  • TypeScript types included

Usage

it('should log in successfully', async () => {
  await it.step('Navigate to login page', async () => {
    await page.goto('https://example.com/login');
  });

  await it.step('Fill credentials', async () => {
    await page.fill('#username', 'user');
    await page.fill('#password', 'pass');
  });

  await it.step('Submit form', async () => {
    await page.click('#submit');
    await expect(page.locator('.welcome')).toBeVisible();
  });
});

If a step fails, the error message includes the step path:

step "Fill credentials": expect(received).toBe(expected) // Object.is equality

Closes #16027

@netlify
Copy link
Copy Markdown

netlify Bot commented May 10, 2026

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4a16532
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6a0044fc70f75300083fc29b
😎 Deploy Preview https://deploy-preview-16157--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: test.step/it.step (like in playwright) for the integrated tests (with @testing-library/react, for example)

1 participant