Skip to content

test: Migrate to Vitest#882

Closed
timfish wants to merge 13 commits intogetsentry:mainfrom
timfish:timfish/test/vitest
Closed

test: Migrate to Vitest#882
timfish wants to merge 13 commits intogetsentry:mainfrom
timfish:timfish/test/vitest

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Feb 19, 2026

This PR:

  • Migrates all tests to Vitest
  • I had to change the CI cache keys because changing a package.json resulted in no lock change and a build failure
  • Test usages of the Vite plugin had to add as unknown as vite.Plugin because the Vite versions varied between the plugin and integration tests. This does not impact end users because it will use their Vite version.

@github-actions
Copy link

github-actions bot commented Feb 19, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • test: Migrate to Vitest by timfish in #882

🤖 This preview updates automatically when you update the PR.

@timfish timfish force-pushed the timfish/test/vitest branch 3 times, most recently from 951a498 to abbdcc7 Compare February 19, 2026 14:33
@timfish timfish force-pushed the timfish/test/vitest branch from b215b75 to 844a6b8 Compare February 19, 2026 15:09
@timfish timfish marked this pull request as ready for review February 19, 2026 16:41
@timfish timfish force-pushed the timfish/test/vitest branch from 55800f6 to 00a9df5 Compare February 24, 2026 02:24
@timfish timfish force-pushed the timfish/test/vitest branch from 00a9df5 to 644e5e2 Compare February 24, 2026 02:27
fail-fast: false
matrix:
node-version: ["18", "20", "22"]
node-version: [18, 20, 22, 24]
Copy link

Choose a reason for hiding this comment

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

CI runs integration tests on unsupported Node 18

High Severity

The test-integration CI matrix includes Node 18 ([18, 20, 22, 24]), but packages/integration-tests/package.json now depends on "vitest": "^4.0.0", which requires Node ^20.0.0 || ^22.0.0 || >=24.0.0. Integration tests running on Node 18 in CI will fail. The PR description explicitly says integration tests are excluded from the Vitest migration to retain Node 18 support, but the migration was applied to them as well.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tests seem to be passing fine!

@timfish timfish requested a review from chargome February 24, 2026 23:30
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Looks good! Just double checking: in the descr you mentioned migrating to vitest apart from the integration tests but this pr does migrate them right?

@timfish
Copy link
Collaborator Author

timfish commented Feb 25, 2026

Ah yes, I'll update that!

Just realised this PR doesn't update the e2e snapshots and these didn't run and fail in CI because it's from a fork.

@timfish
Copy link
Collaborator Author

timfish commented Feb 26, 2026

I've fixed the e2e snapshots so this should be ready to merge!

@timfish timfish force-pushed the timfish/test/vitest branch from ca3ff03 to a9fd966 Compare February 26, 2026 02:15
@timfish
Copy link
Collaborator Author

timfish commented Feb 26, 2026

Closing in favour of #894 since the e2e tests are not run from my fork

@timfish timfish closed this Feb 26, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: E2E snapshot contains stale webpack5 release name
    • Updated the snapshot to use 'basic-upload-webpack' instead of the stale 'basic-upload-webpack5' to match the actual release name generated by the test.

Create PR

Or push these changes by commenting:

@cursor push d1b3fb88dd
Preview (d1b3fb88dd)
diff --git a/packages/e2e-tests/scenarios/basic-upload/__snapshots__/basic-upload.test.ts.snap b/packages/e2e-tests/scenarios/basic-upload/__snapshots__/basic-upload.test.ts.snap
--- a/packages/e2e-tests/scenarios/basic-upload/__snapshots__/basic-upload.test.ts.snap
+++ b/packages/e2e-tests/scenarios/basic-upload/__snapshots__/basic-upload.test.ts.snap
@@ -80,12 +80,12 @@
 exports[`Simple Sourcemaps Upload (one string include + default options) > uploads the correct files using webpack 1`] = `
 Array [
   Object {
-    "content": "(()=>{var e={677:(e,o,r)=>{(\\"undefined\\"!=typeof window?window:void 0!==r.g?r.g:\\"undefined\\"!=typeof self?self:{}).SENTRY_RELEASE={id:\\"basic-upload-webpack5\\"}}},o={};function r(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),r.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})};var t={};(()=>{\\"use strict\\";r.r(t),r(677);const e=o=>{if(3===o)throw new Error(\\"I'm an uncaught error\\");return o<=1?o:e(o-1)+e(o-2)};console.log(\\"Hi, I'm a very simple app\\"),e(10),console.log(\\"I'm done\\")})();var n=exports;for(var i in t)n[i]=t[i];t.__esModule&&Object.defineProperty(n,\\"__esModule\\",{value:!0})})();
+    "content": "(()=>{var e={677:(e,o,r)=>{(\\"undefined\\"!=typeof window?window:void 0!==r.g?r.g:\\"undefined\\"!=typeof self?self:{}).SENTRY_RELEASE={id:\\"basic-upload-webpack\\"}}},o={};function r(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.g=function(){if(\\"object\\"==typeof globalThis)return globalThis;try{return this||new Function(\\"return this\\")()}catch(e){if(\\"object\\"==typeof window)return window}}(),r.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})};var t={};(()=>{\\"use strict\\";r.r(t),r(677);const e=o=>{if(3===o)throw new Error(\\"I'm an uncaught error\\");return o<=1?o:e(o-1)+e(o-2)};console.log(\\"Hi, I'm a very simple app\\"),e(10),console.log(\\"I'm done\\")})();var n=exports;for(var i in t)n[i]=t[i];t.__esModule&&Object.defineProperty(n,\\"__esModule\\",{value:!0})})();
 //# sourceMappingURL=index.js.map",
     "name": "~/index.js",
   },
   Object {
-    "content": "{\\"version\\":3,\\"file\\":\\"index.js\\",\\"sources\\":[\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/../bundler-plugin-core/sentry-release-injection-file.js\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/bootstrap\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/runtime/global\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/runtime/make namespace object\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/./scenarios/basic-upload/input/fib.js\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/./scenarios/basic-upload/input/index.js\\"],\\"sourcesContent\\":[\\"// This const is used for nothing except to make this file identifiable via its content.\\\\n// We search for \\\\\\"_sentry_release_injection_file\\\\\\" in the plugin to determine for sure that the file we look at is the release injection file.\\\\n\\\\n// _sentry_release_injection_file\\\\n\\\\n    var _global =\\\\n      typeof window !== 'undefined' ?\\\\n        window :\\\\n        typeof global !== 'undefined' ?\\\\n          global :\\\\n          typeof self !== 'undefined' ?\\\\n            self :\\\\n            {};\\\\n\\\\n    _global.SENTRY_RELEASE={id:\\\\\\"basic-upload-webpack5\\\\\\"};\\",\\"// The module cache\\\\nvar __webpack_module_cache__ = {};\\\\n\\\\n// The require function\\\\nfunction __webpack_require__(moduleId) {\\\\n\\\\t// Check if module is in cache\\\\n\\\\tvar cachedModule = __webpack_module_cache__[moduleId];\\\\n\\\\tif (cachedModule !== undefined) {\\\\n\\\\t\\\\treturn cachedModule.exports;\\\\n\\\\t}\\\\n\\\\t// Create a new module (and put it into the cache)\\\\n\\\\tvar module = __webpack_module_cache__[moduleId] = {\\\\n\\\\t\\\\t// no module.id needed\\\\n\\\\t\\\\t// no module.loaded needed\\\\n\\\\t\\\\texports: {}\\\\n\\\\t};\\\\n\\\\n\\\\t// Execute the module function\\\\n\\\\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\\\\n\\\\n\\\\t// Return the exports of the module\\\\n\\\\treturn module.exports;\\\\n}\\\\n\\\\n\\",\\"__webpack_require__.g = (function() {\\\\n\\\\tif (typeof globalThis === 'object') return globalThis;\\\\n\\\\ttry {\\\\n\\\\t\\\\treturn this || new Function('return this')();\\\\n\\\\t} catch (e) {\\\\n\\\\t\\\\tif (typeof window === 'object') return window;\\\\n\\\\t}\\\\n})();\\",\\"// define __esModule on exports\\\\n__webpack_require__.r = (exports) => {\\\\n\\\\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\\\\n\\\\t\\\\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\\\\n\\\\t}\\\\n\\\\tObject.defineProperty(exports, '__esModule', { value: true });\\\\n};\\",\\"export const fibonacci = (n) => {\\\\n  if (n === 3) {\\\\n    throw new Error(\\\\\\"I'm an uncaught error\\\\\\");\\\\n  }\\\\n  if (n <= 1) {\\\\n    return n;\\\\n  }\\\\n  return fibonacci(n - 1) + fibonacci(n - 2);\\\\n};\\\\n;\\\\nimport \\\\\\"/home/runner/work/sentry-javascript-bundler-plugins/sentry-javascript-bundler-plugins/packages/bundler-plugin-core/sentry-release-injection-file.js\\\\\\";\\",\\"import { fibonacci } from \\\\\\"./fib\\\\\\";\\\\nconsole.log(\\\\\\"Hi, I'm a very simple app\\\\\\");\\\\n\\\\nfibonacci(10);\\\\n\\\\nconsole.log(\\\\\\"I'm done\\\\\\");\\\\n;\\\\nimport \\\\\\"/home/runner/work/sentry-javascript-bundler-plugins/sentry-javascript-bundler-plugins/packages/bundler-plugin-core/sentry-release-injection-file.js\\\\\\";\\"],\\"names\\":[\\"window\\",\\"g\\",\\"self\\",\\"SENTRY_RELEASE\\",\\"id\\",\\"__webpack_module_cache__\\",\\"__webpack_require__\\",\\"moduleId\\",\\"cachedModule\\",\\"undefined\\",\\"exports\\",\\"module\\",\\"__webpack_modules__\\",\\"globalThis\\",\\"this\\",\\"Function\\",\\"e\\",\\"r\\",\\"Symbol\\",\\"toStringTag\\",\\"Object\\",\\"defineProperty\\",\\"value\\",\\"fibonacci\\",\\"n\\",\\"Error\\",\\"console\\",\\"log\\"],\\"mappings\\":\\"4BAMwB,oBAAXA,OACLA,YACkB,IAAX,EAAAC,EACL,EAAAA,EACgB,oBAATC,KACLA,KACA,CAAC,GAEDC,eAAe,CAACC,GAAG,wB,GCb3BC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaE,QAGrB,IAAIC,EAASN,EAAyBE,GAAY,CAGjDG,QAAS,CAAC,GAOX,OAHAE,EAAoBL,GAAUI,EAAQA,EAAOD,QAASJ,GAG/CK,EAAOD,OACf,CCtBAJ,EAAoBL,EAAI,WACvB,GAA0B,iBAAfY,WAAyB,OAAOA,WAC3C,IACC,OAAOC,MAAQ,IAAIC,SAAS,cAAb,EAGhB,CAFE,MAAOC,GACR,GAAsB,iBAAXhB,OAAqB,OAAOA,MACxC,CACA,CAPuB,GCCxBM,EAAoBW,EAAKP,IACH,oBAAXQ,QAA0BA,OAAOC,aAC1CC,OAAOC,eAAeX,EAASQ,OAAOC,YAAa,CAAEG,MAAO,WAE7DF,OAAOC,eAAeX,EAAS,aAAc,CAAEY,OAAO,GAAO,E,0CCLvD,MAAMC,EAAaC,IACxB,GAAU,IAANA,EACF,MAAM,IAAIC,MAAM,yBAElB,OAAID,GAAK,EACAA,EAEFD,EAAUC,EAAI,GAAKD,EAAUC,EAAI,EAAE,ECN5CE,QAAQC,IAAI,6BAEZJ,EAAU,IAEVG,QAAQC,IAAI,W\\"}",
+    "content": "{\\"version\\":3,\\"file\\":\\"index.js\\",\\"sources\\":[\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/../bundler-plugin-core/sentry-release-injection-file.js\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/bootstrap\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/runtime/global\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/webpack/runtime/make namespace object\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/./scenarios/basic-upload/input/fib.js\\",\\"webpack://@sentry-internal/bundler-plugin-e2e-tests/./scenarios/basic-upload/input/index.js\\"],\\"sourcesContent\\":[\\"// This const is used for nothing except to make this file identifiable via its content.\\\\n// We search for \\\\\\"_sentry_release_injection_file\\\\\\" in the plugin to determine for sure that the file we look at is the release injection file.\\\\n\\\\n// _sentry_release_injection_file\\\\n\\\\n    var _global =\\\\n      typeof window !== 'undefined' ?\\\\n        window :\\\\n        typeof global !== 'undefined' ?\\\\n          global :\\\\n          typeof self !== 'undefined' ?\\\\n            self :\\\\n            {};\\\\n\\\\n    _global.SENTRY_RELEASE={id:\\\\\\"basic-upload-webpack\\\\\\"};\\",\\"// The module cache\\\\nvar __webpack_module_cache__ = {};\\\\n\\\\n// The require function\\\\nfunction __webpack_require__(moduleId) {\\\\n\\\\t// Check if module is in cache\\\\n\\\\tvar cachedModule = __webpack_module_cache__[moduleId];\\\\n\\\\tif (cachedModule !== undefined) {\\\\n\\\\t\\\\treturn cachedModule.exports;\\\\n\\\\t}\\\\n\\\\t// Create a new module (and put it into the cache)\\\\n\\\\tvar module = __webpack_module_cache__[moduleId] = {\\\\n\\\\t\\\\t// no module.id needed\\\\n\\\\t\\\\t// no module.loaded needed\\\\n\\\\t\\\\texports: {}\\\\n\\\\t};\\\\n\\\\n\\\\t// Execute the module function\\\\n\\\\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\\\\n\\\\n\\\\t// Return the exports of the module\\\\n\\\\treturn module.exports;\\\\n}\\\\n\\\\n\\",\\"__webpack_require__.g = (function() {\\\\n\\\\tif (typeof globalThis === 'object') return globalThis;\\\\n\\\\ttry {\\\\n\\\\t\\\\treturn this || new Function('return this')();\\\\n\\\\t} catch (e) {\\\\n\\\\t\\\\tif (typeof window === 'object') return window;\\\\n\\\\t}\\\\n})();\\",\\"// define __esModule on exports\\\\n__webpack_require__.r = (exports) => {\\\\n\\\\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\\\\n\\\\t\\\\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\\\\n\\\\t}\\\\n\\\\tObject.defineProperty(exports, '__esModule', { value: true });\\\\n};\\",\\"export const fibonacci = (n) => {\\\\n  if (n === 3) {\\\\n    throw new Error(\\\\\\"I'm an uncaught error\\\\\\");\\\\n  }\\\\n  if (n <= 1) {\\\\n    return n;\\\\n  }\\\\n  return fibonacci(n - 1) + fibonacci(n - 2);\\\\n};\\\\n;\\\\nimport \\\\\\"/home/runner/work/sentry-javascript-bundler-plugins/sentry-javascript-bundler-plugins/packages/bundler-plugin-core/sentry-release-injection-file.js\\\\\\";\\",\\"import { fibonacci } from \\\\\\"./fib\\\\\\";\\\\nconsole.log(\\\\\\"Hi, I'm a very simple app\\\\\\");\\\\n\\\\nfibonacci(10);\\\\n\\\\nconsole.log(\\\\\\"I'm done\\\\\\");\\\\n;\\\\nimport \\\\\\"/home/runner/work/sentry-javascript-bundler-plugins/sentry-javascript-bundler-plugins/packages/bundler-plugin-core/sentry-release-injection-file.js\\\\\\";\\"],\\"names\\":[\\"window\\",\\"g\\",\\"self\\",\\"SENTRY_RELEASE\\",\\"id\\",\\"__webpack_module_cache__\\",\\"__webpack_require__\\",\\"moduleId\\",\\"cachedModule\\",\\"undefined\\",\\"exports\\",\\"module\\",\\"__webpack_modules__\\",\\"globalThis\\",\\"this\\",\\"Function\\",\\"e\\",\\"r\\",\\"Symbol\\",\\"toStringTag\\",\\"Object\\",\\"defineProperty\\",\\"value\\",\\"fibonacci\\",\\"n\\",\\"Error\\",\\"console\\",\\"log\\"],\\"mappings\\":\\"4BAMwB,oBAAXA,OACLA,YACkB,IAAX,EAAAC,EACL,EAAAA,EACgB,oBAATC,KACLA,KACA,CAAC,GAEDC,eAAe,CAACC,GAAG,wB,GCb3BC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaE,QAGrB,IAAIC,EAASN,EAAyBE,GAAY,CAGjDG,QAAS,CAAC,GAOX,OAHAE,EAAoBL,GAAUI,EAAQA,EAAOD,QAASJ,GAG/CK,EAAOD,OACf,CCtBAJ,EAAoBL,EAAI,WACvB,GAA0B,iBAAfY,WAAyB,OAAOA,WAC3C,IACC,OAAOC,MAAQ,IAAIC,SAAS,cAAb,EAGhB,CAFE,MAAOC,GACR,GAAsB,iBAAXhB,OAAqB,OAAOA,MACxC,CACA,CAPuB,GCCxBM,EAAoBW,EAAKP,IACH,oBAAXQ,QAA0BA,OAAOC,aAC1CC,OAAOC,eAAeX,EAASQ,OAAOC,YAAa,CAAEG,MAAO,WAE7DF,OAAOC,eAAeX,EAAS,aAAc,CAAEY,OAAO,GAAO,E,0CCLvD,MAAMC,EAAaC,IACxB,GAAU,IAANA,EACF,MAAM,IAAIC,MAAM,yBAElB,OAAID,GAAK,EACAA,EAEFD,EAAUC,EAAI,GAAKD,EAAUC,EAAI,EAAE,ECN5CE,QAAQC,IAAI,6BAEZJ,EAAU,IAEVG,QAAQC,IAAI,W\\"}",
     "name": "~/index.js.map",
   },
 ]
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

"name": "~/index.js.map",
},
]
`;
Copy link

Choose a reason for hiding this comment

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

E2E snapshot contains stale webpack5 release name

Low Severity

The webpack e2e snapshot key was renamed from webpack5 to webpack to match the BUNDLERS array (["rollup", "vite", "esbuild", "webpack"]), but the snapshot content still contains basic-upload-webpack5 as the release name. Since the test constructs the release as `${pluginConfig.release?.name}-${bundler}` which yields basic-upload-webpack, the actual downloaded content would have basic-upload-webpack — not matching this stale snapshot.

Fix in Cursor Fix in Web

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