Skip to content

Comments

test: fix snapshot on vite 8#9686

Merged
sheremet-va merged 2 commits intovitest-dev:mainfrom
hi-ogawa:02-18-test_fix_snapshot_on_vite_8
Feb 19, 2026
Merged

test: fix snapshot on vite 8#9686
sheremet-va merged 2 commits intovitest-dev:mainfrom
hi-ogawa:02-18-test_fix_snapshot_on_vite_8

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 18, 2026

Description

Fixes #9679 (comment)

I tested a following Node only demo and it matches with Vite 8 stack trace. So, I guess we do nothing about Vite 7 difference.

function expect(actual) {
  return {
    get resolves() {
      const stackTraceError = new Error("STACK_TRACE_ERROR");
      return {
        toBe: async (expected) => {
          const resolved = await actual;
          if (resolved !== expected) {
            const error = new Error("Expected " + resolved + " to be " + expected);
            error.stack = stackTraceError.stack.replace(stackTraceError.message, error.message);
            throw error;
          }
        },
      };
    },
  };
}

async function main() {
  await expect(Promise.resolve(1)).resolves.toBe(2);
  //                              ^
  // at main (file:///home/hiroshi/code/others/vitest-wt1/repro.js:20:35)
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
~/code/others/vitest-wt1 $ node --version
v24.13.1
~/code/others/vitest-wt1 $ node repro.js 
Error: Expected 1 to be 2
    at get resolves (file:///home/hiroshi/code/others/vitest-wt1/repro.js:4:31)
    at main (file:///home/hiroshi/code/others/vitest-wt1/repro.js:20:35)
    at file:///home/hiroshi/code/others/vitest-wt1/repro.js:25:1
    at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:661:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

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.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

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

@hi-ogawa hi-ogawa marked this pull request as ready for review February 18, 2026 00:59
@sheremet-va sheremet-va merged commit 75a557e into vitest-dev:main Feb 19, 2026
23 of 28 checks passed
@hi-ogawa hi-ogawa deleted the 02-18-test_fix_snapshot_on_vite_8 branch February 20, 2026 00:04
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.

2 participants