Skip to content

Comments

feat(runner): add test.scoped to override test.extend fixtures per-suite#7233

Merged
sheremet-va merged 11 commits intovitest-dev:mainfrom
sheremet-va:suite-extend
Mar 19, 2025
Merged

feat(runner): add test.scoped to override test.extend fixtures per-suite#7233
sheremet-va merged 11 commits intovitest-dev:mainfrom
sheremet-va:suite-extend

Conversation

@sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Jan 13, 2025

Description

Fixes #6226

Related #7188

const test = baseTest.extend({
  name: 'Vladimir',
  action: ({ name }, use) => use(`${name} is typing`)
})

describe('default behaviour', () => {
  test('Vladimir is typing', ({ action }) => {
    expect(action).toBe('Vladimir is typing')
  })
})

describe('custom behaviour', () => {
  test.scoped({ name: 'Hiroshi' }) // all tests in this suite inherit the value

  test('Hiroshi is typing', ({ action }) => {
    expect(action).toBe('Hiroshi is typing')
  })
})

describe('custom behaviour', () => {
  test.scoped({ name: 'Ari' }) // all tests in this suite inherit the value

  test('Ari is typing', ({ action }) => {
    expect(action).toBe('Ari is typing')
  })
})

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@sheremet-va sheremet-va marked this pull request as draft January 13, 2025 13:46
@sheremet-va sheremet-va added this to the 3.1.0 milestone Jan 14, 2025
@sheremet-va sheremet-va added the p2-to-be-discussed Enhancement under consideration (priority) label Feb 7, 2025
@sheremet-va sheremet-va removed the p2-to-be-discussed Enhancement under consideration (priority) label Feb 14, 2025
@netlify
Copy link

netlify bot commented Feb 14, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit a26f4d7
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/67dac963680dd40008451f1b
😎 Deploy Preview https://deploy-preview-7233--vitest-dev.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 site configuration.

@sheremet-va sheremet-va marked this pull request as ready for review February 14, 2025 15:53
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good to me! I'm just wondering if we can improve typing 🤔

@sheremet-va sheremet-va merged commit e5851e4 into vitest-dev:main Mar 19, 2025
13 checks passed
@sheremet-va sheremet-va deleted the suite-extend branch March 19, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Enable configuring fixtures per test

3 participants