Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runner): fix and simplify Task.suite initialization #7414

Merged
merged 8 commits into from
Mar 6, 2025

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 4, 2025

Description

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

Copy link

netlify bot commented Feb 4, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

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

Comment on lines 5 to 23
test("test-a", (ctx) => {
expect(ctx.__suiteNames).toEqual([]);
})

describe("suite-x", () => {
test("test-b", (ctx) => {
expect(ctx.__suiteNames).toEqual(
['suite-x']
)
})

describe("suite-y", () => {
test("test-c", (ctx) => {
expect(ctx.__suiteNames).toEqual(
['suite-y', 'suite-x']
)
})
})
})
Copy link
Contributor Author

@hi-ogawa hi-ogawa Mar 3, 2025

Choose a reason for hiding this comment

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

On #7374, some tests fail (and pass) in an odd way:

 DEV  v3.0.7 /home/hiroshi/code/others/vitest/test/cli/fixtures/custom-runner

 ❯ custom-runner.test.ts (3 tests | 2 failed) 6ms
   × test-a 5ms
     → expected [ '' ] to deeply equal []
   ✓ suite-x > test-b
   × suite-x > suite-y > test-c 1ms
     → expected [ 'suite-y' ] to deeply equal [ 'suite-y', 'suite-x' ]

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  custom-runner.test.ts > test-a
AssertionError: expected [ '' ] to deeply equal []

- Expected
+ Received

- []
+ [
+   "",
+ ]

 ❯ custom-runner.test.ts:6:27
      4| 
      5| test("test-a", (ctx) => {
      6|  expect(ctx.__suiteNames).toEqual([]);
       |                           ^
      7| })
      8| 

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL  custom-runner.test.ts > suite-x > suite-y > test-c
AssertionError: expected [ 'suite-y' ] to deeply equal [ 'suite-y', 'suite-x' ]

- Expected
+ Received

  [
    "suite-y",
-   "suite-x",
  ]

 ❯ custom-runner.test.ts:18:29
     16|  describe("suite-y", () => {
     17|   test("test-c", (ctx) => {
     18|    expect(ctx.__suiteNames).toEqual(
       |                             ^
     19|     ['suite-y', 'suite-x']
     20|    )

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯


 Test Files  1 failed (1)
      Tests  2 failed | 1 passed (3)
   Start at  14:56:29
   Duration  147ms (transform 25ms, setup 0ms, collect 8ms, tests 6ms, environment 0ms, prepare 53ms)

Copy link

pkg-pr-new bot commented Mar 3, 2025

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@7414

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@7414

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@7414

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@7414

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@7414

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@7414

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@7414

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@7414

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@7414

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@7414

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@7414

vite-node

npm i https://pkg.pr.new/vite-node@7414

vitest

npm i https://pkg.pr.new/vitest@7414

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@7414

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@7414

commit: 3461652

@hi-ogawa hi-ogawa marked this pull request as ready for review March 3, 2025 06:04
@hi-ogawa hi-ogawa requested a review from sheremet-va March 3, 2025 06:10
@sheremet-va sheremet-va merged commit ca9ffac into vitest-dev:main Mar 6, 2025
14 checks passed
@hi-ogawa hi-ogawa deleted the fix-early-task-suite branch March 6, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants