diff --git a/package-lock.json b/package-lock.json index 64a2cbf71..be01c172d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -95,7 +95,7 @@ "@types/webpack-env": "^1.18.8", "@types/which": "^3.0.4", "@types/ws": "^8.18.1", - "@vitest/coverage-v8": "^3.2.4", + "@vitest/coverage-v8": "^4.0.1", "aws-sdk-client-mock": "^4.1.0", "cheerio": "^1.1.2", "css-loader": "^7.1.2", @@ -117,7 +117,7 @@ "terser-webpack-plugin": "^5.3.14", "ts-loader": "^9.5.4", "typescript": "^5.9.3", - "vitest": "^3.0.7", + "vitest": "^4.0.1", "vitest-fetch-mock": "^0.4.5", "webpack": "^5.102.1", "webpack-cli": "^6.0.1", @@ -135,20 +135,6 @@ "@rollup/rollup-win32-x64-msvc": "*" } }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@apm-js-collab/code-transformer": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/@apm-js-collab/code-transformer/-/code-transformer-0.8.2.tgz", @@ -2203,119 +2189,6 @@ "node": ">=6" } }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", - "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/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==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@isaacs/cliui/node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", - "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -3728,17 +3601,6 @@ "url": "https://opencollective.com/parcel" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -5135,6 +4997,13 @@ "text-hex": "1.0.x" } }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", + "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", + "dev": true, + "license": "MIT" + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -5680,32 +5549,30 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.2.4.tgz", - "integrity": "sha512-EyF9SXU6kS5Ku/U82E259WSnvg6c8KTjppUncuNdm5QHpe17mwREHnjDzozC8x9MZ0xfBUFSaLkRv4TMA75ALQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.1.tgz", + "integrity": "sha512-nmB+UVryiWQLC0pfPQ6KmJacew1ecpuKeUyiGbXtp1+KoYtCTAAlLI++8X/wJfzlULil+l/1jiWPreFnB1U5Mg==", "dev": true, "license": "MIT", "dependencies": { - "@ampproject/remapping": "^2.3.0", "@bcoe/v8-coverage": "^1.0.2", - "ast-v8-to-istanbul": "^0.3.3", - "debug": "^4.4.1", + "@vitest/utils": "4.0.1", + "ast-v8-to-istanbul": "^0.3.5", + "debug": "^4.4.3", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", "istanbul-lib-source-maps": "^5.0.6", - "istanbul-reports": "^3.1.7", - "magic-string": "^0.30.17", + "istanbul-reports": "^3.2.0", "magicast": "^0.3.5", "std-env": "^3.9.0", - "test-exclude": "^7.0.1", - "tinyrainbow": "^2.0.0" + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "3.2.4", - "vitest": "3.2.4" + "@vitest/browser": "4.0.1", + "vitest": "4.0.1" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -5714,39 +5581,40 @@ } }, "node_modules/@vitest/expect": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", - "integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.1.tgz", + "integrity": "sha512-KtvGLN/IWoZfg68JF2q/zbDEo+UJTWnc7suYJ8RF+ZTBeBcBz4NIOJDxO4Q3bEY9GsOYhgy5cOevcVPFh4+V7g==", "dev": true, "license": "MIT", "dependencies": { + "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "tinyrainbow": "^2.0.0" + "@vitest/spy": "4.0.1", + "@vitest/utils": "4.0.1", + "chai": "^6.0.1", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/mocker": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.4.tgz", - "integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.1.tgz", + "integrity": "sha512-fwmvg8YvwSAE41Hyhul7dL4UzPhG+k2VaZCcL+aHagLx4qlNQgKYTw7coF4YdjAxSBBt0b408gQFYMX1Qeqweg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "3.2.4", + "@vitest/spy": "4.0.1", "estree-walker": "^3.0.3", - "magic-string": "^0.30.17" + "magic-string": "^0.30.19" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + "vite": "^6.0.0 || ^7.0.0-0" }, "peerDependenciesMeta": { "msw": { @@ -5758,42 +5626,41 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.4.tgz", - "integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.1.tgz", + "integrity": "sha512-6nq3JY/zQ91+oX1vd4fajiVNyA/HMhaF9cOw5P9cQi6ML7PRi7ilVaQ77PulF+4kvUKr9bcLm9GoAtwlVFbGzw==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^2.0.0" + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.4.tgz", - "integrity": "sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.1.tgz", + "integrity": "sha512-nxUoWmw7ZX2OiSNwolJeSOOzrrR/o79wRTwP7HhiW/lDFwQHtWMj9snMhrdvccFqanvI8897E81eXjgDbrRvqA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "3.2.4", - "pathe": "^2.0.3", - "strip-literal": "^3.0.0" + "@vitest/utils": "4.0.1", + "pathe": "^2.0.3" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/snapshot": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.4.tgz", - "integrity": "sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.1.tgz", + "integrity": "sha512-CvfsEWutEIN/Z9ScXYup7YwlPeK9JICrV7FN9p3pVytsyh+aCHAH0PUi//YlTiQ7T8qYxJYpUrAwZL9XqmZ5ZA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "magic-string": "^0.30.17", + "@vitest/pretty-format": "4.0.1", + "magic-string": "^0.30.19", "pathe": "^2.0.3" }, "funding": { @@ -5801,28 +5668,24 @@ } }, "node_modules/@vitest/spy": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.4.tgz", - "integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.1.tgz", + "integrity": "sha512-Hj0/TBQ2EN72wDpfKiUf63mRCkE0ZiSGXGeDDvW9T3LBKVVApItd0GyQLDBIe03kWbyK9gOTEbJVVWthcLFzCg==", "dev": true, "license": "MIT", - "dependencies": { - "tinyspy": "^4.0.3" - }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.4.tgz", - "integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.1.tgz", + "integrity": "sha512-uRrACgpIz5sxuT87ml7xhh7EdKtW8k0N9oSFVBPl8gHB/JfLObLe9dXO6ZrsNN55FzciGIRqIEILgTQvg1eNHw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "3.2.4", - "loupe": "^3.1.4", - "tinyrainbow": "^2.0.0" + "@vitest/pretty-format": "4.0.1", + "tinyrainbow": "^3.0.3" }, "funding": { "url": "https://opencollective.com/vitest" @@ -6779,16 +6642,6 @@ "node": ">= 0.8" } }, - "node_modules/cac": { - "version": "6.7.14", - "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", - "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/cachedir": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.4.0.tgz", @@ -6887,18 +6740,11 @@ "license": "Apache-2.0" }, "node_modules/chai": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", - "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.0.tgz", + "integrity": "sha512-aUTnJc/JipRzJrNADXVvpVqi6CO0dn3nx4EVPxijri+fj3LUUDyZQOgVeW54Ob3Y1Xh9Iz8f+CgaCl8v0mn9bA==", "dev": true, "license": "MIT", - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.1.1", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, "engines": { "node": ">=18" } @@ -6954,16 +6800,6 @@ "pnpm": ">=8" } }, - "node_modules/check-error": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", - "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, "node_modules/cheerio": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.1.2.tgz", @@ -7938,16 +7774,6 @@ } } }, - "node_modules/deep-eql": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", - "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -8122,13 +7948,6 @@ "node": ">= 0.4" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true, - "license": "MIT" - }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -9005,36 +8824,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/foreground-child": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", - "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", - "dev": true, - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.6", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/foreground-child/node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -9297,27 +9086,6 @@ "assert-plus": "^1.0.0" } }, - "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -10474,22 +10242,6 @@ "node": ">=8" } }, - "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -11238,13 +10990,6 @@ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", "license": "Apache-2.0" }, - "node_modules/loupe": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", - "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", - "dev": true, - "license": "MIT" - }, "node_modules/lru-cache": { "version": "11.2.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", @@ -11519,16 +11264,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/mkdirp": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", @@ -12267,13 +12002,6 @@ "node": ">=6" } }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", @@ -12387,30 +12115,6 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "license": "MIT" }, - "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.18" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, "node_modules/path-to-regexp": { "version": "8.3.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", @@ -12451,16 +12155,6 @@ "dev": true, "license": "MIT" }, - "node_modules/pathval": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", - "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14.16" - } - }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -14581,22 +14275,6 @@ "node": ">=8" } }, - "node_modules/string-width-cjs": { - "name": "string-width", - "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, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/string.prototype.padend": { "version": "3.1.6", "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.6.tgz", @@ -14688,20 +14366,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -14722,19 +14386,6 @@ "node": ">=6" } }, - "node_modules/strip-literal": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", - "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "js-tokens": "^9.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/antfu" - } - }, "node_modules/strnum": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.1.tgz", @@ -15058,21 +14709,6 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "license": "MIT" }, - "node_modules/test-exclude": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", - "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", - "dev": true, - "license": "ISC", - "dependencies": { - "@istanbuljs/schema": "^0.1.2", - "glob": "^10.4.1", - "minimatch": "^9.0.4" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/text-decoder": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", @@ -15188,30 +14824,10 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/tinypool": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", - "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.0.0 || >=20.0.0" - } - }, "node_modules/tinyrainbow": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", - "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/tinyspy": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz", - "integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", + "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", "dev": true, "license": "MIT", "engines": { @@ -15851,29 +15467,6 @@ } } }, - "node_modules/vite-node": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", - "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", - "dev": true, - "license": "MIT", - "dependencies": { - "cac": "^6.7.14", - "debug": "^4.4.1", - "es-module-lexer": "^1.7.0", - "pathe": "^2.0.3", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" - }, - "bin": { - "vite-node": "vite-node.mjs" - }, - "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, "node_modules/vite/node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -15907,42 +15500,39 @@ } }, "node_modules/vitest": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz", - "integrity": "sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.1.tgz", + "integrity": "sha512-4rwTfUNF0MExMZBiNirkzZpeyUZGOs3JD76N2qHNP9i6w6/bff7MRv2I9yFJKd1ICxzn2igpra+E4t9o2EfQhw==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "@types/chai": "^5.2.2", - "@vitest/expect": "3.2.4", - "@vitest/mocker": "3.2.4", - "@vitest/pretty-format": "^3.2.4", - "@vitest/runner": "3.2.4", - "@vitest/snapshot": "3.2.4", - "@vitest/spy": "3.2.4", - "@vitest/utils": "3.2.4", - "chai": "^5.2.0", - "debug": "^4.4.1", - "expect-type": "^1.2.1", - "magic-string": "^0.30.17", + "@vitest/expect": "4.0.1", + "@vitest/mocker": "4.0.1", + "@vitest/pretty-format": "4.0.1", + "@vitest/runner": "4.0.1", + "@vitest/snapshot": "4.0.1", + "@vitest/spy": "4.0.1", + "@vitest/utils": "4.0.1", + "debug": "^4.4.3", + "es-module-lexer": "^1.7.0", + "expect-type": "^1.2.2", + "magic-string": "^0.30.19", "pathe": "^2.0.3", - "picomatch": "^4.0.2", + "picomatch": "^4.0.3", "std-env": "^3.9.0", "tinybench": "^2.9.0", "tinyexec": "^0.3.2", - "tinyglobby": "^0.2.14", - "tinypool": "^1.1.1", - "tinyrainbow": "^2.0.0", - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", - "vite-node": "3.2.4", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.0.3", + "vite": "^6.0.0 || ^7.0.0", "why-is-node-running": "^2.3.0" }, "bin": { "vitest": "vitest.mjs" }, "engines": { - "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" }, "funding": { "url": "https://opencollective.com/vitest" @@ -15950,9 +15540,11 @@ "peerDependencies": { "@edge-runtime/vm": "*", "@types/debug": "^4.1.12", - "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", - "@vitest/browser": "3.2.4", - "@vitest/ui": "3.2.4", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.0.1", + "@vitest/browser-preview": "4.0.1", + "@vitest/browser-webdriverio": "4.0.1", + "@vitest/ui": "4.0.1", "happy-dom": "*", "jsdom": "*" }, @@ -15966,7 +15558,13 @@ "@types/node": { "optional": true }, - "@vitest/browser": { + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { "optional": true }, "@vitest/ui": { @@ -16519,25 +16117,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "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, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index c934ba235..9ae40e6ee 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "@types/webpack-env": "^1.18.8", "@types/which": "^3.0.4", "@types/ws": "^8.18.1", - "@vitest/coverage-v8": "^3.2.4", + "@vitest/coverage-v8": "^4.0.1", "aws-sdk-client-mock": "^4.1.0", "cheerio": "^1.1.2", "css-loader": "^7.1.2", @@ -126,7 +126,7 @@ "terser-webpack-plugin": "^5.3.14", "ts-loader": "^9.5.4", "typescript": "^5.9.3", - "vitest": "^3.0.7", + "vitest": "^4.0.1", "vitest-fetch-mock": "^0.4.5", "webpack": "^5.102.1", "webpack-cli": "^6.0.1", diff --git a/test/app/config-tests.ts b/test/app/config-tests.ts index 9f9bfd062..4ca64a583 100644 --- a/test/app/config-tests.ts +++ b/test/app/config-tests.ts @@ -67,11 +67,13 @@ import { } from '../../lib/app/config.js'; import type {AppArguments} from '../../lib/app.interfaces.js'; import * as logger from '../../lib/logger.js'; -import type {CompilerProps} from '../../lib/properties.js'; import * as props from '../../lib/properties.js'; import type {Language, LanguageKey} from '../../types/languages.interfaces.js'; // Mock modules +// Vitest 4.0 requires constructor mocks to be actual classes/functions, not arrow functions. +// We define classes directly here because .mockImplementation() gets auto-converted to arrow +// functions by Biome, which breaks constructor calls. Do not refactor to arrow functions! vi.mock('node:os', async () => { const actual = await vi.importActual('node:os'); return { @@ -92,28 +94,30 @@ vi.mock('../../lib/logger.js', async () => { }; }); +// Shared mock implementation for ceProps +const cePropsImpl = vi.fn(); + vi.mock('../../lib/properties.js', async () => { const actual = await vi.importActual('../../lib/properties.js'); + class MockCompilerProps { + ceProps = cePropsImpl; + } return { ...actual, initialize: vi.fn(), propsFor: vi.fn(), setDebug: vi.fn(), - CompilerProps: vi.fn().mockImplementation(() => ({ - ceProps: vi.fn(), - })), + CompilerProps: MockCompilerProps, }; }); -// Mock PromClient.Gauge class -class MockGauge { - set = vi.fn(); -} - vi.mock('prom-client', () => { + class MockGauge { + set = vi.fn(); + } return { default: { - Gauge: vi.fn().mockImplementation(() => new MockGauge()), + Gauge: MockGauge, }, }; }); @@ -144,7 +148,7 @@ describe('Config Module', () => { // Ensure hostname is properly mocked hostnameBackup = os.hostname; - os.hostname = vi.fn().mockReturnValue('test-hostname'); + os.hostname = vi.fn(() => 'test-hostname'); }); afterEach(() => { @@ -278,7 +282,7 @@ describe('Config Module', () => { }); it('should not set up monitoring if interval is 0', () => { - const mockCeProps = vi.fn().mockImplementation((key: string, defaultValue: any) => { + const mockCeProps = vi.fn((key: string, defaultValue: any) => { if (key === 'eventLoopMeasureIntervalMs') return 0; return defaultValue; }); @@ -288,7 +292,7 @@ describe('Config Module', () => { }); it('should set up monitoring if interval is greater than 0', () => { - const mockCeProps = vi.fn().mockImplementation((key: string, defaultValue: any) => { + const mockCeProps = vi.fn((key: string, defaultValue: any) => { if (key === 'eventLoopMeasureIntervalMs') return 100; if (key === 'eventLoopLagThresholdWarn') return 50; if (key === 'eventLoopLagThresholdErr') return 100; @@ -302,7 +306,6 @@ describe('Config Module', () => { describe('loadConfiguration', () => { let mockCeProps: any; - let mockCompilerProps: CompilerProps; beforeEach(() => { // Mock needed dependencies @@ -323,14 +326,11 @@ describe('Config Module', () => { return defaultValue; }); - mockCompilerProps = { - ceProps: vi.fn().mockImplementation((key: string, defaultValue: any) => { - if (key === 'storageSolution') return 'local'; - return defaultValue; - }), - } as any; - - vi.spyOn(props, 'CompilerProps').mockImplementation(() => mockCompilerProps); + // Configure cePropsImpl to return the values we need + cePropsImpl.mockImplementation((key: string, defaultValue: any) => { + if (key === 'storageSolution') return 'local'; + return defaultValue; + }); }); afterEach(() => { @@ -348,7 +348,7 @@ describe('Config Module', () => { // Verify initialization happened correctly expect(props.initialize).toHaveBeenCalledWith(path.normalize('/test/root/config'), expect.any(Array)); expect(props.propsFor).toHaveBeenCalledWith('compiler-explorer'); - expect(props.CompilerProps).toHaveBeenCalled(); + // CompilerProps is a class, not a spy, so we can't check if it was called // Verify expected result properties expect(result).toHaveProperty('ceProps'); diff --git a/test/app/main-tests.ts b/test/app/main-tests.ts index d20ba5cb2..af3b5f7d1 100644 --- a/test/app/main-tests.ts +++ b/test/app/main-tests.ts @@ -29,39 +29,82 @@ import {initialiseApplication} from '../../lib/app/main.js'; import * as server from '../../lib/app/server.js'; import {AppArguments} from '../../lib/app.interfaces.js'; import * as aws from '../../lib/aws.js'; -import {CompilationEnvironment} from '../../lib/compilation-env.js'; import {CompilationQueue} from '../../lib/compilation-queue.js'; -import {CompilerFinder} from '../../lib/compiler-finder.js'; import * as exec from '../../lib/exec.js'; import {RemoteExecutionQuery} from '../../lib/execution/execution-query.js'; import * as execTriple from '../../lib/execution/execution-triple.js'; import * as execQueue from '../../lib/execution/sqs-execution-queue.js'; -import {FormattingService} from '../../lib/formatting-service.js'; -import {CompileHandler} from '../../lib/handlers/compile.js'; -import {NoScriptHandler} from '../../lib/handlers/noscript.js'; -import {RouteAPI} from '../../lib/handlers/route-api.js'; import {logger} from '../../lib/logger.js'; import {setupMetricsServer} from '../../lib/metrics-server.js'; -import {ClientOptionsHandler} from '../../lib/options-handler.js'; import * as sentry from '../../lib/sentry.js'; import * as sponsors from '../../lib/sponsors.js'; import {getStorageTypeByKey} from '../../lib/storage/index.js'; // We need to mock all these modules to avoid actual API calls +// Vitest 4.0 requires constructor mocks to be actual classes/functions, not arrow functions. +// We define classes directly here because .mockImplementation() gets auto-converted to arrow +// functions by Biome, which breaks constructor calls. Do not refactor to arrow functions! vi.mock('../../lib/aws.js'); vi.mock('../../lib/exec.js'); vi.mock('../../lib/execution/execution-query.js'); vi.mock('../../lib/execution/execution-triple.js'); vi.mock('../../lib/execution/sqs-execution-queue.js'); -vi.mock('../../lib/compilation-env.js'); +vi.mock('../../lib/compilation-env.js', () => ({ + CompilationEnvironment: class { + setCompilerFinder = vi.fn(); + }, +})); vi.mock('../../lib/compilation-queue.js'); -vi.mock('../../lib/compiler-finder.js'); -vi.mock('../../lib/formatting-service.js'); -vi.mock('../../lib/handlers/compile.js'); -vi.mock('../../lib/handlers/noscript.js'); -vi.mock('../../lib/handlers/route-api.js'); +// Shared mock implementations for CompilerFinder +const mockCompilerFinderFind = vi.fn(); +const mockCompilerFinderLoadPrediscovered = vi.fn(); +const mockCompilerFinderCompileHandler = {findCompiler: vi.fn()}; + +vi.mock('../../lib/compiler-finder.js', () => ({ + CompilerFinder: class { + find = mockCompilerFinderFind; + loadPrediscovered = mockCompilerFinderLoadPrediscovered; + compileHandler = mockCompilerFinderCompileHandler; + }, +})); +vi.mock('../../lib/formatting-service.js', () => ({ + FormattingService: class { + initialize = vi.fn().mockResolvedValue(undefined); + }, +})); +vi.mock('../../lib/handlers/compile.js', () => ({ + CompileHandler: class { + findCompiler = vi.fn().mockReturnValue({ + possibleArguments: {possibleArguments: []}, + }); + handle = vi.fn(); + }, +})); +vi.mock('../../lib/handlers/noscript.js', () => ({ + NoScriptHandler: class { + initializeRoutes = vi.fn(); + createRouter = vi.fn().mockReturnValue({}); + }, +})); +vi.mock('../../lib/handlers/route-api.js', () => ({ + RouteAPI: class { + apiHandler = { + setCompilers: vi.fn(), + setLanguages: vi.fn(), + setOptions: vi.fn(), + }; + initializeRoutes = vi.fn(); + }, +})); vi.mock('../../lib/metrics-server.js'); -vi.mock('../../lib/options-handler.js'); +vi.mock('../../lib/options-handler.js', () => ({ + ClientOptionsHandler: class { + setCompilers = vi.fn().mockResolvedValue(undefined); + get = vi.fn(); + getHash = vi.fn(); + getJSON = vi.fn(); + }, +})); vi.mock('../../lib/sentry.js'); vi.mock('../../lib/sponsors.js'); vi.mock('../../lib/storage/index.js'); @@ -113,9 +156,9 @@ describe('Main module', () => { }; const mockConfig = { - ceProps: vi.fn(), + ceProps: vi.fn((_key: string, defaultValue?: any) => defaultValue), compilerProps: { - ceProps: vi.fn(), + ceProps: vi.fn((_key: string, defaultValue?: any) => defaultValue), }, languages: {}, staticMaxAgeSecs: 60, @@ -147,48 +190,23 @@ describe('Main module', () => { vi.mocked(exec.startWineInit).mockReturnValue(); vi.mocked(RemoteExecutionQuery.initRemoteExecutionArchs).mockReturnValue(); - const mockFormattingService = { - initialize: vi.fn().mockResolvedValue(undefined), - }; - vi.mocked(FormattingService).mockImplementation(() => mockFormattingService as unknown as FormattingService); + // Classes are mocked with proper constructors in vi.mock above + // Configure the default behavior for CompilerFinder methods + mockCompilerFinderFind.mockResolvedValue({compilers: mockCompilers, foundClash: false}); + mockCompilerFinderLoadPrediscovered.mockResolvedValue(mockCompilers); + mockCompilerFinderCompileHandler.findCompiler.mockReturnValue({possibleArguments: {possibleArguments: []}}); const mockCompilationQueue = { queue: vi.fn(), }; vi.mocked(CompilationQueue.fromProps).mockReturnValue(mockCompilationQueue as unknown as CompilationQueue); - const mockCompilationEnv = { - setCompilerFinder: vi.fn(), - }; - vi.mocked(CompilationEnvironment).mockImplementation( - () => mockCompilationEnv as unknown as CompilationEnvironment, - ); - - const mockCompileHandler = { - findCompiler: vi.fn().mockReturnValue({ - possibleArguments: {possibleArguments: []}, - }), - handle: vi.fn(), - }; - vi.mocked(CompileHandler).mockImplementation(() => mockCompileHandler as unknown as CompileHandler); - const mockStorageType = vi.fn(); vi.mocked(getStorageTypeByKey).mockReturnValue( mockStorageType as unknown as ReturnType, ); - const mockFindResult = { - compilers: mockCompilers, - foundClash: false, - }; - const mockCompilerFinder = { - find: vi.fn().mockResolvedValue(mockFindResult), - loadPrediscovered: vi.fn().mockResolvedValue(mockCompilers), - compileHandler: {findCompiler: mockCompileHandler.findCompiler}, - }; - vi.mocked(CompilerFinder).mockImplementation(() => mockCompilerFinder as any); - - vi.mocked(mockConfig.ceProps).mockImplementation((key, defaultValue) => { + vi.mocked(mockConfig.ceProps).mockImplementation((key: string, defaultValue?: any) => { if (key === 'execqueue.is_worker') return false; if (key === 'healthCheckFilePath') return null; if (key === 'sentrySlowRequestMs') return 0; @@ -216,34 +234,7 @@ describe('Main module', () => { }; vi.mocked(server.setupWebServer).mockResolvedValue(mockWebServerResult); vi.mocked(server.startListening).mockImplementation(() => {}); - - const mockNoscriptHandler = { - initializeRoutes: vi.fn(), - createRouter: vi.fn().mockReturnValue({}), - }; - vi.mocked(NoScriptHandler).mockImplementation(() => mockNoscriptHandler as unknown as NoScriptHandler); - - const mockApiHandler = { - setCompilers: vi.fn(), - setLanguages: vi.fn(), - setOptions: vi.fn(), - }; - const mockRouteApi = { - apiHandler: mockApiHandler, - initializeRoutes: vi.fn(), - }; - vi.mocked(RouteAPI).mockImplementation(() => mockRouteApi as unknown as RouteAPI); - - // Mock ClientOptionsHandler - const mockClientOptionsHandler = { - setCompilers: vi.fn().mockResolvedValue(undefined), - get: vi.fn(), - getHash: vi.fn(), - getJSON: vi.fn(), - }; - vi.mocked(ClientOptionsHandler).mockImplementation( - () => mockClientOptionsHandler as unknown as ClientOptionsHandler, - ); + // NoScriptHandler, RouteAPI, and ClientOptionsHandler are already properly mocked with classes }); afterEach(() => { @@ -306,7 +297,7 @@ describe('Main module', () => { }); it('should initialize execution worker if configured', async () => { - vi.mocked(mockConfig.ceProps).mockImplementation((key, defaultValue) => { + vi.mocked(mockConfig.ceProps).mockImplementation((key: string, defaultValue?: any) => { if (key === 'execqueue.is_worker') return true; return defaultValue; }); @@ -323,10 +314,7 @@ describe('Main module', () => { }); it('should throw an error if no compilers are found', async () => { - const mockCompilerFinder = { - find: vi.fn().mockResolvedValue({compilers: [], foundClash: false}), - }; - vi.mocked(CompilerFinder).mockImplementation(() => mockCompilerFinder as any); + mockCompilerFinderFind.mockResolvedValue({compilers: [], foundClash: false}); await expect( initialiseApplication({ @@ -339,10 +327,7 @@ describe('Main module', () => { }); it('should throw an error if there are compiler clashes and ensureNoCompilerClash is set', async () => { - const mockCompilerFinder = { - find: vi.fn().mockResolvedValue({compilers: mockCompilers, foundClash: true}), - }; - vi.mocked(CompilerFinder).mockImplementation(() => mockCompilerFinder as any); + mockCompilerFinderFind.mockResolvedValue({compilers: mockCompilers, foundClash: true}); await expect( initialiseApplication({