From af6a5a3885c6aa3d6544a12c0d0d4b086b72155f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2026 13:15:28 +0000 Subject: [PATCH 1/3] Bump msw from 2.15.0 to 3.0.5 in /extensions/ql-vscode Bumps [msw](https://github.com/mswjs/msw) from 2.15.0 to 3.0.5. - [Release notes](https://github.com/mswjs/msw/releases) - [Changelog](https://github.com/mswjs/msw/blob/main/CHANGELOG.md) - [Commits](https://github.com/mswjs/msw/compare/v2.15.0...v3.0.5) --- updated-dependencies: - dependency-name: msw dependency-version: 3.0.5 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- extensions/ql-vscode/package-lock.json | 313 +++++++++++++++++-------- extensions/ql-vscode/package.json | 2 +- 2 files changed, 214 insertions(+), 101 deletions(-) diff --git a/extensions/ql-vscode/package-lock.json b/extensions/ql-vscode/package-lock.json index 1fef11cf9c8..645297c15f6 100644 --- a/extensions/ql-vscode/package-lock.json +++ b/extensions/ql-vscode/package-lock.json @@ -25,7 +25,7 @@ "fs-extra": "^11.1.1", "js-yaml": "^5.4.2", "koffi": "^3.3.2", - "msw": "^2.15.0", + "msw": "^3.0.5", "p-queue": "^10.0.0", "proper-lockfile": "^4.1.2", "react": "^19.3.1", @@ -10304,29 +10304,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@msw/url": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@msw/url/-/url-0.1.2.tgz", + "integrity": "sha512-DdeBLQxQ+ZrtmwEmaj7GQ7lbzPCgbbbyAqOz/I4ulo68hwBpfdNvQJ5bmihJUkAAKOeCmqCIG3OFZGosqFN4mA==", + "license": "MIT" + }, "node_modules/@mswjs/interceptors": { - "version": "0.41.9", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.41.9.tgz", - "integrity": "sha512-VVPPgHyQ6ShqnrmDWuxjmUIsO9gWyOZFmuOfLd9LfBGQJwZfy0gvv9pbHSJuoFNIYC7ZDX9aoFwowjcdSC4E8w==", + "version": "0.45.12", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.45.12.tgz", + "integrity": "sha512-LLttQ/SSmseGFD/sNiHv9q34hd4gmPLN9uQdIIsU/V/o2AgTJm3dWoKHA4KTj0BzAans6CoEmpHYmp80yp69VA==", "license": "MIT", "dependencies": { - "@open-draft/deferred-promise": "^2.2.0", - "@open-draft/logger": "^0.3.0", - "@open-draft/until": "^2.0.0", + "@open-draft/until": "^3.0.1", + "@types/debug": "^4.1.13", + "debug": "^4.4.3", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", - "strict-event-emitter": "^0.5.1" + "rettime": "^0.11.12" }, "engines": { - "node": ">=18" + "node": ">=22" } }, - "node_modules/@mswjs/interceptors/node_modules/@open-draft/deferred-promise": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", - "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", - "license": "MIT" - }, "node_modules/@napi-rs/keyring": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@napi-rs/keyring/-/keyring-1.3.0.tgz", @@ -10851,28 +10851,15 @@ "@octokit/openapi-types": "^27.0.0" } }, - "node_modules/@open-draft/deferred-promise": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-3.0.0.tgz", - "integrity": "sha512-XW375UK8/9SqUVNVa6M0yEy8+iTi4QN5VZ7aZuRFQmy76LRwI9wy5F4YIBU6T+eTe2/DNDo8tqu8RHlwLHM6RA==", - "license": "MIT" - }, - "node_modules/@open-draft/logger": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", - "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", + "node_modules/@open-draft/until": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-3.0.1.tgz", + "integrity": "sha512-s7/9ELP4aP9YZtW7RJaa0Xf3RISaRH9+EFN18FtykJYRHGNrl8f9ymvoNXzjhrjmftFvkQudtuDU9RYhk0xs3A==", "license": "MIT", - "dependencies": { - "is-node-process": "^1.2.0", - "outvariant": "^1.4.0" + "funding": { + "url": "https://github.com/sponsors/kettanaito" } }, - "node_modules/@open-draft/until": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", - "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", - "license": "MIT" - }, "node_modules/@opentelemetry/api": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.7.0.tgz", @@ -12965,7 +12952,6 @@ "version": "4.1.13", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", - "dev": true, "license": "MIT", "dependencies": { "@types/ms": "*" @@ -13440,7 +13426,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", - "dev": true, "license": "MIT" }, "node_modules/@types/node": { @@ -13562,12 +13547,6 @@ "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", "dev": true }, - "node_modules/@types/statuses": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz", - "integrity": "sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==", - "license": "MIT" - }, "node_modules/@types/streamx": { "version": "2.9.5", "resolved": "https://registry.npmjs.org/@types/streamx/-/streamx-2.9.5.tgz", @@ -16488,6 +16467,7 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", @@ -16501,6 +16481,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "dependencies": { "color-convert": "^2.0.1" }, @@ -16514,12 +16495,14 @@ "node_modules/cliui/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true }, "node_modules/cliui/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, "engines": { "node": ">=8" } @@ -16528,6 +16511,7 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -16541,6 +16525,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -16683,12 +16668,12 @@ "dev": true }, "node_modules/cookie": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", - "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-2.0.2.tgz", + "integrity": "sha512-SL0cVuEdETEp7pN0FuZb01toc3vnODEfVUCooxG1SJN0yIirh7JMb9X9bvfCFf0vzzbT68RdbKDHYTiWy7a7iw==", "license": "MIT", "engines": { - "node": ">=18" + "node": ">=22" }, "funding": { "type": "opencollective", @@ -17287,7 +17272,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -19947,15 +19931,6 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, - "node_modules/graphql": { - "version": "16.14.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.14.0.tgz", - "integrity": "sha512-BBvQ/406p+4CZbTpCbVPSxfzrZrbnuWSP1ELYgyS6B+hNeKzgrdB4JczCa5VZUBQrDa9hUngm0KnexY6pJRN5Q==", - "license": "MIT", - "engines": { - "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" - } - }, "node_modules/gulp": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/gulp/-/gulp-5.0.1.tgz", @@ -27420,59 +27395,145 @@ "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/msw": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/msw/-/msw-2.15.0.tgz", - "integrity": "sha512-2wQAmKkQKxRuXvYJxVhPGG0wZNBQyD06oJvxqw90XqLvptdqxdlHrFUfEteKkpaNORX3Xzc+HtEl/q0nfmN2wQ==", - "hasInstallScript": true, + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/msw/-/msw-3.0.5.tgz", + "integrity": "sha512-RkzyWIaG+T2jYf9KOUrNOZuXl4sCpz35m13nVlt1ACFQhl/WjHU9zKMwlrR/6NatgKjL5U84UmVXOz9/+mvGsw==", "license": "MIT", "dependencies": { "@inquirer/confirm": "^6.0.11", - "@mswjs/interceptors": "^0.41.3", - "@open-draft/deferred-promise": "^3.0.0", - "@types/statuses": "^2.0.6", - "cookie": "^1.1.1", - "graphql": "^16.13.2", + "@msw/url": "^0.1.2", + "@mswjs/interceptors": "^0.45.11", + "cookie": "^2.0.1", "headers-polyfill": "^5.0.1", "is-node-process": "^1.2.0", "outvariant": "^1.4.3", - "path-to-regexp": "^6.3.0", - "picocolors": "^1.1.1", - "rettime": "^0.11.11", - "statuses": "^2.0.2", - "strict-event-emitter": "^0.5.1", - "tough-cookie": "^6.0.1", + "rettime": "^0.11.12", + "tough-cookie": "^6.0.2", "type-fest": "^5.5.0", "until-async": "^3.0.2", - "yargs": "^17.7.2" + "yargs": "^18.2.0" }, "bin": { "msw": "cli/index.js" }, "engines": { - "node": ">=18" + "node": ">=22.12.0" }, "funding": { "url": "https://github.com/sponsors/mswjs" }, "peerDependencies": { - "typescript": ">= 4.8.x" + "graphql": ">=16", + "typescript": ">=5.9.x", + "vite": ">=6" }, "peerDependenciesMeta": { + "graphql": { + "optional": true + }, "typescript": { "optional": true + }, + "vite": { + "optional": true } } }, - "node_modules/msw/node_modules/path-to-regexp": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", - "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "node_modules/msw/node_modules/ansi-regex": { + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.6.0.tgz", + "integrity": "sha512-XZ5apbzreCbXSKwPjJstu8R0zOi247w3XYwWxtwBXgpZrCyc1Ka7p9/xY0A9/diMewmHbEKz+FIraWaEWjlN5g==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/msw/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/msw/node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/msw/node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/msw/node_modules/emoji-regex": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz", + "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", "license": "MIT" }, + "node_modules/msw/node_modules/string-width": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.3.0.tgz", + "integrity": "sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==", + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/msw/node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/msw/node_modules/type-fest": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-5.6.0.tgz", @@ -27488,6 +27549,66 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/msw/node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/msw/node_modules/wrap-ansi/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/msw/node_modules/yargs": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.2.0.tgz", + "integrity": "sha512-9OpKOLeaoNFecEp7P6iYbzze/5CqWoH7N3SMs/6y1XF4nMvFMspEGZzJ6uFi9MmQwXhyzqYoSEKO3tvA3Z/o2w==", + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^8.2.1", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/msw/node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, "node_modules/mute-stdout": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-2.0.0.tgz", @@ -28531,6 +28652,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, "license": "ISC" }, "node_modules/picomatch": { @@ -29535,6 +29657,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -29705,9 +29828,9 @@ } }, "node_modules/rettime": { - "version": "0.11.11", - "resolved": "https://registry.npmjs.org/rettime/-/rettime-0.11.11.tgz", - "integrity": "sha512-ILJRqVWBCTlg9r42fFgwVZx1gnFAcQF8mRoMkbgQfIrjEDf9nbBFDFx00oloOa+Q869FUtaYDXZvEfnecQSCoQ==", + "version": "0.11.12", + "resolved": "https://registry.npmjs.org/rettime/-/rettime-0.11.12.tgz", + "integrity": "sha512-5ExtR1ppiDBQkVoPw5NAqdbfH4Iq2VOmQKHMtUoaFxA9bo2krzFYBtyq6K40xxbYp+2w/YOr6D+1ToF6tTN53A==", "license": "MIT" }, "node_modules/reusify": { @@ -30356,15 +30479,6 @@ "node": ">=8" } }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/stdin-discarder": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/stdin-discarder/-/stdin-discarder-0.2.2.tgz", @@ -30623,12 +30737,6 @@ "text-decoder": "^1.1.0" } }, - "node_modules/strict-event-emitter": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", - "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", - "license": "MIT" - }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -33583,6 +33691,7 @@ "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", @@ -33600,6 +33709,7 @@ "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, "engines": { "node": ">=12" } @@ -33607,12 +33717,14 @@ "node_modules/yargs/node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true }, "node_modules/yargs/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, "engines": { "node": ">=8" } @@ -33621,6 +33733,7 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index de4daa41e06..106dfea9bc9 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -2083,7 +2083,7 @@ "fs-extra": "^11.1.1", "js-yaml": "^5.4.2", "koffi": "^3.3.2", - "msw": "^2.15.0", + "msw": "^3.0.5", "p-queue": "^10.0.0", "proper-lockfile": "^4.1.2", "react": "^19.3.1", From 52a6282a2df15f8a5d5021cd36c0794e00af254d Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Fri, 20 Nov 2026 16:00:23 -0800 Subject: [PATCH 2/3] Migrate the extension and Jest to MSW 3 Load MSW lazily from a packaged ESM bundle with its HTTP parser WASM. Adapt mock servers to the frame API and keep Jest CommonJS with scoped transforms. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 38ed8c1c-77ab-4b31-bc49-7f28a5fdc865 --- extensions/ql-vscode/eslint.config.mjs | 10 ++- extensions/ql-vscode/gulpfile.ts/index.ts | 3 + .../ql-vscode/gulpfile.ts/msw-runtime.ts | 2 + .../ql-vscode/gulpfile.ts/typescript.ts | 36 ++++++++++ .../common/mock-gh-api/mock-gh-api-server.ts | 66 +++++++++++-------- .../common/mock-gh-api/request-handlers.ts | 22 ++++--- .../vscode/vscode-mock-gh-api-server.ts | 17 +++-- .../ql-vscode/test/babel-import-meta-url.cjs | 20 ++++++ extensions/ql-vscode/test/jest-config.ts | 36 ++++++++++ .../ql-vscode/test/unit-tests/jest.config.ts | 15 ++--- .../variant-analysis-manager.test.ts | 2 +- .../variant-analysis-results-manager.test.ts | 55 ++++++++-------- .../test/vscode-tests/jest.config.base.ts | 15 ++--- .../codeql-cli/distribution.test.ts | 2 +- 14 files changed, 215 insertions(+), 86 deletions(-) create mode 100644 extensions/ql-vscode/gulpfile.ts/msw-runtime.ts create mode 100644 extensions/ql-vscode/test/babel-import-meta-url.cjs diff --git a/extensions/ql-vscode/eslint.config.mjs b/extensions/ql-vscode/eslint.config.mjs index da96a4d7e9e..7178e949fce 100644 --- a/extensions/ql-vscode/eslint.config.mjs +++ b/extensions/ql-vscode/eslint.config.mjs @@ -98,7 +98,10 @@ export default tseslint.config( ecmaVersion: 2018, sourceType: "module", projectService: { - allowDefaultProject: ['jest.config.js'], + allowDefaultProject: [ + "jest.config.js", + "test/babel-import-meta-url.cjs", + ], }, tsconfigRootDir: import.meta.dirname, }, @@ -155,6 +158,11 @@ export default tseslint.config( "react-hooks/exhaustive-deps": "off", }, }, + { + files: ["test/babel-import-meta-url.cjs"], + languageOptions: { sourceType: "commonjs" }, + rules: { "import/no-commonjs": "off" }, + }, { files: ["test/vscode-tests/**/*"], languageOptions: { diff --git a/extensions/ql-vscode/gulpfile.ts/index.ts b/extensions/ql-vscode/gulpfile.ts/index.ts index 3c20b838c09..11397eb8b2a 100644 --- a/extensions/ql-vscode/gulpfile.ts/index.ts +++ b/extensions/ql-vscode/gulpfile.ts/index.ts @@ -6,6 +6,7 @@ import { watchCheckTypeScript, cleanOutput, copyModules, + buildMswRuntime, } from "./typescript"; import { compileTextMateGrammar } from "./textmate"; import { packageExtension } from "./package"; @@ -22,6 +23,7 @@ export const buildWithoutPackage = series( parallel( compileEsbuild, copyModules, + buildMswRuntime, checkTypeScript, compileTextMateGrammar, compileViewEsbuild, @@ -32,6 +34,7 @@ export const buildWithoutPackage = series( export const watch = parallel( // Always build first, so that we don't have to run build manually compileEsbuild, + buildMswRuntime, compileViewEsbuild, watchEsbuild, watchCheckTypeScript, diff --git a/extensions/ql-vscode/gulpfile.ts/msw-runtime.ts b/extensions/ql-vscode/gulpfile.ts/msw-runtime.ts new file mode 100644 index 00000000000..ac3de1d7483 --- /dev/null +++ b/extensions/ql-vscode/gulpfile.ts/msw-runtime.ts @@ -0,0 +1,2 @@ +export { http } from "msw"; +export { setupServer } from "msw/node"; diff --git a/extensions/ql-vscode/gulpfile.ts/typescript.ts b/extensions/ql-vscode/gulpfile.ts/typescript.ts index a735e6ebbea..fc82d36e508 100644 --- a/extensions/ql-vscode/gulpfile.ts/typescript.ts +++ b/extensions/ql-vscode/gulpfile.ts/typescript.ts @@ -57,6 +57,17 @@ export function compileEsbuild() { loader: { ".node": "copy", }, + plugins: [ + { + name: "msw-runtime", + setup(build) { + build.onResolve({ filter: /^msw(\/node)?$/ }, () => ({ + path: "./msw-runtime.mjs", + external: true, + })); + }, + }, + ], }), dest("out"), ); @@ -66,6 +77,23 @@ export function watchEsbuild() { watch(["src/**/*.ts", "!src/view/**/*.ts"], compileEsbuild); } +function compileMswRuntime() { + return pipeline( + src("./gulpfile.ts/msw-runtime.ts"), + esbuild({ + outfile: "msw-runtime.mjs", + bundle: true, + format: "esm", + platform: "node", + target: "node22", + banner: { + js: 'import { createRequire } from "node:module"; const require = createRequire(import.meta.url);', + }, + }), + dest("out"), + ); +} + export function checkTypeScript() { // This doesn't actually output the TypeScript files, it just // runs the TypeScript compiler and reports any errors. @@ -89,6 +117,13 @@ function copyWasmFiles() { }).pipe(dest("out")); } +function copyMswWasm() { + // The interceptor resolves this file relative to the ESM bundle's import.meta.url. + return src("node_modules/@mswjs/interceptors/lib/node/llhttp/llhttp.wasm", { + encoding: false, + }).pipe(dest("out/llhttp")); +} + function copyNativeAddonFiles() { // We need to copy these files manually because we only want to include Windows x64 to limit // the size of the extension. Windows x64 is the most common platform that requires short path @@ -107,3 +142,4 @@ function copyNativeAddonFiles() { } export const copyModules = parallel(copyWasmFiles, copyNativeAddonFiles); +export const buildMswRuntime = parallel(compileMswRuntime, copyMswWasm); diff --git a/extensions/ql-vscode/src/common/mock-gh-api/mock-gh-api-server.ts b/extensions/ql-vscode/src/common/mock-gh-api/mock-gh-api-server.ts index c317b5ec60c..827c7e702b6 100644 --- a/extensions/ql-vscode/src/common/mock-gh-api/mock-gh-api-server.ts +++ b/extensions/ql-vscode/src/common/mock-gh-api/mock-gh-api-server.ts @@ -1,8 +1,7 @@ import { join, resolve } from "path"; import { pathExists } from "fs-extra"; import type { SetupServer } from "msw/node"; -import { setupServer } from "msw/node"; -import type { UnhandledRequestStrategy } from "msw"; +import type { http, UnhandledFrameStrategy } from "msw"; import { DisposableObject } from "../disposable-object"; @@ -14,32 +13,44 @@ import { getDirectoryNamesInsidePath } from "../files"; * Enables mocking of the GitHub API server via HTTP interception, using msw. */ export class MockGitHubApiServer extends DisposableObject { - private _isListening: boolean; + private _isListening = false; - private readonly server: SetupServer; - private readonly recorder: Recorder; + private state?: { + server: SetupServer; + recorder: Recorder; + http: typeof http; + }; - constructor() { - super(); - this._isListening = false; + private async getState() { + if (this.state) { + return this.state; + } - this.server = setupServer(); - this.recorder = this.push(new Recorder(this.server)); + const [{ setupServer }, { http }] = await Promise.all([ + import("msw/node"), + import("msw"), + ]); + if (!this.state) { + const server = setupServer(); + this.state = { server, recorder: this.push(new Recorder(server)), http }; + } + return this.state; } - public startServer( - onUnhandledRequest: UnhandledRequestStrategy = "bypass", - ): void { + public async startServer( + onUnhandledFrame: UnhandledFrameStrategy = "bypass", + ): Promise { + const { server } = await this.getState(); if (this._isListening) { return; } - this.server.listen({ onUnhandledRequest }); + server.listen({ onUnhandledFrame }); this._isListening = true; } public stopServer(): void { - this.server.close(); + this.state?.server.close(); this._isListening = false; } @@ -56,8 +67,9 @@ export class MockGitHubApiServer extends DisposableObject { const scenarioPath = join(scenariosPath, scenarioName); - const handlers = await createRequestHandlers(scenarioPath); - this.server.resetHandlers(...handlers); + const { server, http } = await this.getState(); + const handlers = await createRequestHandlers(http, scenarioPath); + server.resetHandlers(...handlers); } public async saveScenario( @@ -71,7 +83,8 @@ export class MockGitHubApiServer extends DisposableObject { } } - const filePath = await this.recorder.save(scenariosPath, scenarioName); + const { recorder } = await this.getState(); + const filePath = await recorder.save(scenariosPath, scenarioName); await this.stopRecording(); @@ -87,7 +100,8 @@ export class MockGitHubApiServer extends DisposableObject { } public async startRecording(): Promise { - if (this.recorder.isRecording) { + const { recorder } = await this.getState(); + if (recorder.isRecording) { return; } @@ -95,12 +109,12 @@ export class MockGitHubApiServer extends DisposableObject { await this.unloadAllScenarios(); } - this.recorder.start(); + recorder.start(); } public async stopRecording(): Promise { - this.recorder.stop(); - this.recorder.clear(); + this.state?.recorder.stop(); + this.state?.recorder.clear(); } public async getScenarioNames(scenariosPath?: string): Promise { @@ -119,15 +133,15 @@ export class MockGitHubApiServer extends DisposableObject { } public get isRecording(): boolean { - return this.recorder.isRecording; + return this.state?.recorder.isRecording ?? false; } public get anyRequestsRecorded(): boolean { - return this.recorder.anyRequestsRecorded; + return this.state?.recorder.anyRequestsRecorded ?? false; } public get isScenarioLoaded(): boolean { - return this.server.listHandlers().length > 0; + return (this.state?.server.listHandlers().length ?? 0) > 0; } public async getDefaultScenariosPath(): Promise { @@ -146,6 +160,6 @@ export class MockGitHubApiServer extends DisposableObject { } private async unloadAllScenarios(): Promise { - this.server.resetHandlers(); + this.state?.server.resetHandlers(); } } diff --git a/extensions/ql-vscode/src/common/mock-gh-api/request-handlers.ts b/extensions/ql-vscode/src/common/mock-gh-api/request-handlers.ts index b6d3dc8b403..1393fccba20 100644 --- a/extensions/ql-vscode/src/common/mock-gh-api/request-handlers.ts +++ b/extensions/ql-vscode/src/common/mock-gh-api/request-handlers.ts @@ -1,7 +1,6 @@ import { join } from "path"; import { readdir, readJson, readFile } from "fs-extra"; -import type { RequestHandler } from "msw"; -import { http } from "msw"; +import type { http as mswHttp, RequestHandler } from "msw"; import type { GitHubApiRequest } from "./gh-api-request"; import { isCodeSearchRequest, @@ -29,17 +28,18 @@ const jsonResponse = ( }; export async function createRequestHandlers( + http: typeof mswHttp, scenarioDirPath: string, ): Promise { const requests = await readRequestFiles(scenarioDirPath); const handlers = [ - createGetRepoRequestHandler(requests), - createSubmitVariantAnalysisRequestHandler(requests), - createGetVariantAnalysisRequestHandler(requests), - createGetVariantAnalysisRepoRequestHandler(requests), - createGetVariantAnalysisRepoResultRequestHandler(requests), - createCodeSearchRequestHandler(requests), + createGetRepoRequestHandler(http, requests), + createSubmitVariantAnalysisRequestHandler(http, requests), + createGetVariantAnalysisRequestHandler(http, requests), + createGetVariantAnalysisRepoRequestHandler(http, requests), + createGetVariantAnalysisRepoResultRequestHandler(http, requests), + createCodeSearchRequestHandler(http, requests), ]; return handlers; @@ -84,6 +84,7 @@ async function readRequestFiles( } function createGetRepoRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const getRepoRequests = requests.filter(isGetRepoRequest); @@ -102,6 +103,7 @@ function createGetRepoRequestHandler( } function createSubmitVariantAnalysisRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const submitVariantAnalysisRequests = requests.filter( @@ -125,6 +127,7 @@ function createSubmitVariantAnalysisRequestHandler( } function createGetVariantAnalysisRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const getVariantAnalysisRequests = requests.filter( @@ -153,6 +156,7 @@ function createGetVariantAnalysisRequestHandler( } function createGetVariantAnalysisRepoRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const getVariantAnalysisRepoRequests = requests.filter( @@ -177,6 +181,7 @@ function createGetVariantAnalysisRepoRequestHandler( } function createGetVariantAnalysisRepoResultRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const getVariantAnalysisRepoResultRequests = requests.filter( @@ -208,6 +213,7 @@ function createGetVariantAnalysisRepoResultRequestHandler( } function createCodeSearchRequestHandler( + http: typeof mswHttp, requests: GitHubApiRequest[], ): RequestHandler { const codeSearchRequests = requests.filter(isCodeSearchRequest); diff --git a/extensions/ql-vscode/src/common/mock-gh-api/vscode/vscode-mock-gh-api-server.ts b/extensions/ql-vscode/src/common/mock-gh-api/vscode/vscode-mock-gh-api-server.ts index 8e1e04e9daa..56654ad7eda 100644 --- a/extensions/ql-vscode/src/common/mock-gh-api/vscode/vscode-mock-gh-api-server.ts +++ b/extensions/ql-vscode/src/common/mock-gh-api/vscode/vscode-mock-gh-api-server.ts @@ -7,6 +7,7 @@ import { MockGitHubApiConfigListener, } from "../../../config"; import { DisposableObject } from "../../disposable-object"; +import { getErrorMessage } from "../../helpers-pure"; import { MockGitHubApiServer } from "../mock-gh-api-server"; import type { MockGitHubApiServerCommands } from "../../commands"; import type { App } from "../../app"; @@ -45,7 +46,7 @@ export class VSCodeMockGitHubApiServer extends DisposableObject { } public async startServer(): Promise { - this.server.startServer(); + await this.server.startServer(); } public async stopServer(): Promise { @@ -265,16 +266,24 @@ export class VSCodeMockGitHubApiServer extends DisposableObject { } private setupConfigListener(): void { + const updateServer = () => { + void this.onConfigChange().catch((error: unknown) => + window.showErrorMessage( + `Could not update the mock GitHub API server: ${getErrorMessage(error)}`, + ), + ); + }; // The config "changes" from the default at startup, so we need to call onConfigChange() to ensure the server is // started if required. - void this.onConfigChange(); - this.config.onDidChangeConfiguration(() => void this.onConfigChange()); + updateServer(); + this.config.onDidChangeConfiguration(updateServer); } private async onConfigChange(): Promise { if (this.config.mockServerEnabled && !this.server.isListening) { await this.startServer(); - } else if (!this.config.mockServerEnabled && this.server.isListening) { + } + if (!this.config.mockServerEnabled && this.server.isListening) { await this.stopServer(); } } diff --git a/extensions/ql-vscode/test/babel-import-meta-url.cjs b/extensions/ql-vscode/test/babel-import-meta-url.cjs new file mode 100644 index 00000000000..12c4326a040 --- /dev/null +++ b/extensions/ql-vscode/test/babel-import-meta-url.cjs @@ -0,0 +1,20 @@ +module.exports = ({ types: t, template }) => ({ + visitor: { + MemberExpression(path) { + const { object, property, computed } = path.node; + if ( + !computed && + t.isMetaProperty(object) && + t.isIdentifier(object.meta, { name: "import" }) && + t.isIdentifier(object.property, { name: "meta" }) && + t.isIdentifier(property, { name: "url" }) + ) { + path.replaceWith( + template.expression.ast( + 'require("node:url").pathToFileURL(__filename).href', + ), + ); + } + }, + }, +}); diff --git a/extensions/ql-vscode/test/jest-config.ts b/extensions/ql-vscode/test/jest-config.ts index 4528dd0f886..220d99db06e 100644 --- a/extensions/ql-vscode/test/jest-config.ts +++ b/extensions/ql-vscode/test/jest-config.ts @@ -1,8 +1,12 @@ +import type { Config } from "jest"; + // These are all the packages that DO need to be transformed. All other packages will be ignored. // These packages all use ES modules, so need to be transformed const transformScopes = [ "@faker-js", "@microsoft", + "@msw", + "@mswjs", "@octokit", "@vscode-elements", "@lit", @@ -13,13 +17,17 @@ const transformScopes = [ const transformPackages = [ "before-after-hook", "chokidar", + "cookie", "data-uri-to-buffer", "delaunator", "exenv-es6", "fetch-blob", "formdata-polyfill", + "headers-polyfill", "internmap", "lit", + "msw", + "outvariant", "p-queue", "p-timeout", "readdirp", @@ -40,3 +48,31 @@ const transformPatterns = [ export const transformIgnorePatterns = [ `node_modules/(?!(?:${transformPatterns.join("|")})/.*)`, ]; + +export const dependencyTransform = [ + "babel-jest", + { + presets: ["@babel/preset-env"], + plugins: ["@babel/plugin-transform-modules-commonjs"], + overrides: [ + { + // Keep the Wasm lookup relative to the installed interceptor module. + test: "**/node_modules/@mswjs/interceptors/**", + plugins: [require.resolve("./babel-import-meta-url.cjs")], + }, + ], + }, +] satisfies NonNullable[string]; + +export const mswSourceBabelConfig = { + // Jest runs these TypeScript files as CommonJS, without a native ESM loader. + overrides: [ + { + test: "**/mock-gh-api/mock-gh-api-server.ts", + plugins: [ + "@babel/plugin-transform-dynamic-import", + "@babel/plugin-transform-modules-commonjs", + ], + }, + ], +}; diff --git a/extensions/ql-vscode/test/unit-tests/jest.config.ts b/extensions/ql-vscode/test/unit-tests/jest.config.ts index 21f0a38b2ea..1c47039016d 100644 --- a/extensions/ql-vscode/test/unit-tests/jest.config.ts +++ b/extensions/ql-vscode/test/unit-tests/jest.config.ts @@ -1,5 +1,9 @@ import type { Config } from "jest"; -import { transformIgnorePatterns } from "../jest-config"; +import { + dependencyTransform, + mswSourceBabelConfig, + transformIgnorePatterns, +} from "../jest-config"; /* * For a detailed explanation regarding each configuration property and type check, visit: @@ -169,15 +173,10 @@ const config: Config = { "ts-jest", { tsconfig: "/../tsconfig.json", + babelConfig: mswSourceBabelConfig, }, ], - node_modules: [ - "babel-jest", - { - presets: ["@babel/preset-env"], - plugins: ["@babel/plugin-transform-modules-commonjs"], - }, - ], + node_modules: dependencyTransform, }, // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation diff --git a/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-manager.test.ts b/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-manager.test.ts index 850e221d84f..f512e228887 100644 --- a/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-manager.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-manager.test.ts @@ -59,7 +59,7 @@ const server = setupServer(); beforeAll(() => server.listen({ - onUnhandledRequest: "error", + onUnhandledFrame: "error", }), ); afterEach(() => server.resetHandlers()); diff --git a/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-results-manager.test.ts b/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-results-manager.test.ts index 842dbaa29e0..3744ba562ab 100644 --- a/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-results-manager.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/activated-extension/variant-analysis/variant-analysis-results-manager.test.ts @@ -22,7 +22,7 @@ const server = setupServer(); beforeAll(() => server.listen({ - onUnhandledRequest: "error", + onUnhandledFrame: "error", }), ); afterEach(() => server.resetHandlers()); @@ -165,28 +165,21 @@ describe(VariantAnalysisResultsManager.name, () => { }); it("should report download progress", async () => { - server.resetHandlers( - http.get(dummyRepoTask.artifactUrl, () => { - // This generates a "fake" stream which "downloads" the file in 5 chunks, - // rather than in 1 chunk. This is used for testing that we actually get - // multiple progress reports. - const stream = new ReadableStream({ - start(controller) { - const partLength = fileContents.length / 5; - for (let i = 0; i < 5; i++) { - controller.enqueue( - fileContents.subarray(i * partLength, (i + 1) * partLength), - ); - } - controller.close(); - }, - }); - - return new Response(stream, { - headers: { - "Content-Length": fileContents.length.toString(), - }, - }); + // Stub fetch directly because MSW's transport can coalesce chunks. + const stream = new ReadableStream({ + start(controller) { + const partLength = fileContents.length / 5; + for (let i = 0; i < 5; i++) { + controller.enqueue( + fileContents.subarray(i * partLength, (i + 1) * partLength), + ); + } + controller.close(); + }, + }); + const fetchSpy = jest.spyOn(globalThis, "fetch").mockResolvedValueOnce( + new Response(stream, { + headers: { "Content-Length": fileContents.length.toString() }, }), ); @@ -194,12 +187,16 @@ describe(VariantAnalysisResultsManager.name, () => { .fn() .mockResolvedValue(undefined); - await variantAnalysisResultsManager.download( - variantAnalysisId, - dummyRepoTask, - variantAnalysisStoragePath, - downloadPercentageChanged, - ); + try { + await variantAnalysisResultsManager.download( + variantAnalysisId, + dummyRepoTask, + variantAnalysisStoragePath, + downloadPercentageChanged, + ); + } finally { + fetchSpy.mockRestore(); + } expect(downloadPercentageChanged).toHaveBeenCalledTimes(5); expect(downloadPercentageChanged).toHaveBeenCalledWith(20); diff --git a/extensions/ql-vscode/test/vscode-tests/jest.config.base.ts b/extensions/ql-vscode/test/vscode-tests/jest.config.base.ts index 4b2d69a28d1..9a98a3ba69c 100644 --- a/extensions/ql-vscode/test/vscode-tests/jest.config.base.ts +++ b/extensions/ql-vscode/test/vscode-tests/jest.config.base.ts @@ -1,6 +1,10 @@ import type { Config } from "jest"; import { resolve } from "path"; -import { transformIgnorePatterns } from "../jest-config"; +import { + dependencyTransform, + mswSourceBabelConfig, + transformIgnorePatterns, +} from "../jest-config"; /* * For a detailed explanation regarding each configuration property and type check, visit: @@ -170,15 +174,10 @@ const config: Config = { "ts-jest", { tsconfig: resolve(__dirname, "../tsconfig.json"), + babelConfig: mswSourceBabelConfig, }, ], - node_modules: [ - "babel-jest", - { - presets: ["@babel/preset-env"], - plugins: ["@babel/plugin-transform-modules-commonjs"], - }, - ], + node_modules: dependencyTransform, }, // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation diff --git a/extensions/ql-vscode/test/vscode-tests/no-workspace/codeql-cli/distribution.test.ts b/extensions/ql-vscode/test/vscode-tests/no-workspace/codeql-cli/distribution.test.ts index 965aebb1d21..1f3fbb56604 100644 --- a/extensions/ql-vscode/test/vscode-tests/no-workspace/codeql-cli/distribution.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/no-workspace/codeql-cli/distribution.test.ts @@ -182,7 +182,7 @@ describe("Distribution updates", () => { const server = setupServer(); beforeAll(() => server.listen({ - onUnhandledRequest: "error", + onUnhandledFrame: "error", }), ); afterEach(() => server.resetHandlers()); From 1f05a3b72fc12c8e1d3b9a00fd503a4a10c9e2f1 Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Fri, 20 Nov 2026 16:00:40 -0800 Subject: [PATCH 3/3] Cover MSW scenario recording and replay Exercise bypass recording, strict unmatched requests, and byte-for-byte ZIP replay. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 38ed8c1c-77ab-4b31-bc49-7f28a5fdc865 --- .../common/mock-gh-api-server.test.ts | 81 +++++++++++++++++++ .../gh-api/gh-api-client.test.ts | 22 +++++ 2 files changed, 103 insertions(+) create mode 100644 extensions/ql-vscode/test/unit-tests/common/mock-gh-api-server.test.ts diff --git a/extensions/ql-vscode/test/unit-tests/common/mock-gh-api-server.test.ts b/extensions/ql-vscode/test/unit-tests/common/mock-gh-api-server.test.ts new file mode 100644 index 00000000000..f255f3b8e6b --- /dev/null +++ b/extensions/ql-vscode/test/unit-tests/common/mock-gh-api-server.test.ts @@ -0,0 +1,81 @@ +import { once } from "events"; +import { readFile } from "fs/promises"; +import { createServer } from "http"; +import { join } from "path"; +import { setTimeout } from "timers/promises"; +import { withDir } from "tmp-promise"; +import { MockGitHubApiServer } from "../../../src/common/mock-gh-api/mock-gh-api-server"; + +it("records a bypassed response and replays it in strict mode", async () => { + const repository = { id: 123 }; + const upstream = createServer((_request, response) => { + response.writeHead(200, { "Content-Type": "application/json" }); + response.end(JSON.stringify(repository)); + }); + const mockServer = new MockGitHubApiServer(); + + try { + const listening = once(upstream, "listening"); + upstream.listen(0, "127.0.0.1"); + await listening; + const address = upstream.address(); + if (!address || typeof address === "string") { + throw new Error("Expected an IP address for the local upstream server"); + } + const upstreamUrl = `http://127.0.0.1:${address.port}/repos/example/project`; + + await mockServer.startServer(); + await mockServer.startRecording(); + const response = await fetch(upstreamUrl); + expect(await response.json()).toEqual(repository); + + // Recording reads the cloned body asynchronously after the fetch resolves. + for (let i = 0; i < 100 && !mockServer.anyRequestsRecorded; i++) { + await setTimeout(10); + } + expect(mockServer.anyRequestsRecorded).toBe(true); + + await withDir( + async ({ path }) => { + const savedScenario = await mockServer.saveScenario("recorded", path); + const recording = await readFile( + join(savedScenario, "0-getRepo.json"), + "utf8", + ); + expect(JSON.parse(recording)).toEqual({ + request: { kind: "getRepo" }, + response: { status: 200, body: repository }, + }); + + mockServer.stopServer(); + await mockServer.startServer("error"); + await mockServer.loadScenario("recorded", path); + const replay = await fetch( + "https://api.github.com/repos/example/project", + ); + expect(replay.status).toBe(200); + expect(await replay.json()).toEqual(repository); + + const errorLog = jest + .spyOn(console, "error") + .mockImplementation(() => {}); + try { + await expect(fetch(upstreamUrl)).rejects.toMatchObject({ + cause: { + message: expect.stringContaining("Cannot bypass a request"), + }, + }); + } finally { + errorLog.mockRestore(); + } + }, + { unsafeCleanup: true }, + ); + } finally { + mockServer.stopServer(); + mockServer.dispose(); + await new Promise((resolve, reject) => + upstream.close((error) => (error ? reject(error) : resolve())), + ); + } +}); diff --git a/extensions/ql-vscode/test/unit-tests/variant-analysis/gh-api/gh-api-client.test.ts b/extensions/ql-vscode/test/unit-tests/variant-analysis/gh-api/gh-api-client.test.ts index 85a956a5e8c..35cfa8e2916 100644 --- a/extensions/ql-vscode/test/unit-tests/variant-analysis/gh-api/gh-api-client.test.ts +++ b/extensions/ql-vscode/test/unit-tests/variant-analysis/gh-api/gh-api-client.test.ts @@ -1,3 +1,5 @@ +import { readFile } from "fs/promises"; +import { join } from "path"; import { getRepositoryFromNwo, getVariantAnalysis, @@ -79,4 +81,24 @@ describe("getRepositoryFromNwo", () => { expect(result).toBeDefined(); expect(result.id).toBe(response.body.id); }); + + it("replays a binary variant analysis result without changing its bytes", async () => { + const scenario = "mrva-problem-query-success"; + await mockServer.loadScenario(scenario); + + const result = await fetch( + "https://objects-origin.githubusercontent.com/codeql-query-console/codeql-variant-analysis-repo-tasks/1/23418517/result.zip", + ); + expect(result.status).toBe(200); + expect(result.headers.get("content-type")).toBe("application/zip"); + + const scenariosPath = await mockServer.getDefaultScenariosPath(); + if (!scenariosPath) { + throw new Error("Could not locate mock GitHub API scenarios"); + } + const expected = await readFile( + join(scenariosPath, scenario, "13-getVariantAnalysisRepoResult.body.zip"), + ); + expect(Buffer.from(await result.arrayBuffer()).equals(expected)).toBe(true); + }); });