diff --git a/package-lock.json b/package-lock.json index 14982996..cba703b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "c8": "10.1.3", "cpy": "12.1.0", "cz-conventional-changelog": "3.3.0", - "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1", + "fetch-mock": "12.6.0", "lockfile-lint": "4.14.1", "ls-engines": "0.9.3", "npm-run-all2": "8.0.4", @@ -116,153 +116,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/compat-data": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.5.tgz", - "integrity": "sha512-6uFXyCayocRbqhZOB+6XcuZbkMNimwfVGFji8CTZnCzOHVGvDqzvitu1re2AU5LROliz7eQPhB8CpAMvnx9EjA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz", - "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.5", - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-module-transforms": "^7.28.3", - "@babel/helpers": "^7.28.4", - "@babel/parser": "^7.28.5", - "@babel/template": "^7.27.2", - "@babel/traverse": "^7.28.5", - "@babel/types": "^7.28.5", - "@jridgewell/remapping": "^2.3.5", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/generator": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.5.tgz", - "integrity": "sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.28.5", - "@babel/types": "^7.28.5", - "@jridgewell/gen-mapping": "^0.3.12", - "@jridgewell/trace-mapping": "^0.3.28", - "jsesc": "^3.0.2" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.27.2", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", - "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/compat-data": "^7.27.2", - "@babel/helper-validator-option": "^7.27.1", - "browserslist": "^4.24.0", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/@babel/helper-globals": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", - "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", - "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.27.1", - "@babel/types": "^7.27.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.28.3", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.3.tgz", - "integrity": "sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-module-imports": "^7.27.1", - "@babel/helper-validator-identifier": "^7.27.1", - "@babel/traverse": "^7.28.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-validator-identifier": { "version": "7.28.5", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", @@ -273,104 +126,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-validator-option": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", - "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.4.tgz", - "integrity": "sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.5.tgz", - "integrity": "sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.28.5" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/runtime": { - "version": "7.28.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz", - "integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.27.2", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", - "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/parser": "^7.27.2", - "@babel/types": "^7.27.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.5.tgz", - "integrity": "sha512-TCCj4t55U90khlYkVV/0TfkJkAkUg3jZFA3Neb7unZT8CPok7iiRfaX0F+WnqWqt7OxhOn0uBKXCw4lbL8W0aQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.5", - "@babel/helper-globals": "^7.28.0", - "@babel/parser": "^7.28.5", - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.5", - "debug": "^4.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.5.tgz", - "integrity": "sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@bcoe/v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", @@ -583,28 +338,6 @@ "node": ">=8" } }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.13", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", - "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.0", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, - "node_modules/@jridgewell/remapping": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", - "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - } - }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", @@ -1018,6 +751,7 @@ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", "license": "MIT", + "peer": true, "dependencies": { "@octokit/auth-token": "^6.0.0", "@octokit/graphql": "^9.0.3", @@ -1800,6 +1534,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/glob-to-regexp": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@types/glob-to-regexp/-/glob-to-regexp-0.4.4.tgz", + "integrity": "sha512-nDKoaKJYbnn1MZxUY0cA1bPmmgZbg0cTq7Rh13d0KWYNOiKbqoR+2d89SnRPszGh7ROzSwZ/GOjZ4jPbmmZ6Eg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", @@ -1807,17 +1548,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/node": { - "version": "25.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.2.tgz", - "integrity": "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "undici-types": "~7.16.0" - } - }, "node_modules/@types/normalize-package-data": { "version": "2.4.4", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", @@ -1906,6 +1636,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2380,16 +2111,6 @@ ], "license": "MIT" }, - "node_modules/baseline-browser-mapping": { - "version": "2.9.7", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.7.tgz", - "integrity": "sha512-k9xFKplee6KIio3IDbwj+uaCLpqzOwakOgmqzPezM0sFJlFKcg30vk2wOiAJtkTSfx0SSQDSe8q+mWA/fSH5Zg==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "baseline-browser-mapping": "dist/cli.js" - } - }, "node_modules/before-after-hook": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz", @@ -2484,40 +2205,6 @@ "node": ">=8" } }, - "node_modules/browserslist": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.1.tgz", - "integrity": "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "baseline-browser-mapping": "^2.9.0", - "caniuse-lite": "^1.0.30001759", - "electron-to-chromium": "^1.5.263", - "node-releases": "^2.0.27", - "update-browserslist-db": "^1.2.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -2805,27 +2492,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/caniuse-lite": { - "version": "1.0.30001760", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001760.tgz", - "integrity": "sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "CC-BY-4.0" - }, "node_modules/cbor": { "version": "10.0.11", "resolved": "https://registry.npmjs.org/cbor/-/cbor-10.0.11.tgz", @@ -3618,18 +3284,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/core-js": { - "version": "3.47.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.47.0.tgz", - "integrity": "sha512-c3Q2VVkGAUyupsjRnaNX6u8Dq2vAdzm9iuPj5FW0fRxzlxgq9Q39MDq10IvmQSpLgHQNyQzQmOo6bgGHmH3NNg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -3643,6 +3297,7 @@ "integrity": "sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "env-paths": "^2.2.1", "import-fresh": "^3.3.0", @@ -4077,6 +3732,16 @@ "dev": true, "license": "MIT" }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", @@ -4214,13 +3879,6 @@ "dev": true, "license": "MIT" }, - "node_modules/electron-to-chromium": { - "version": "1.5.267", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.267.tgz", - "integrity": "sha512-0Drusm6MVRXSOJpGbaSVgcQsuB4hEkMpHXaVstcPmhu5LIedxs1xNK/nIxmQIU/RPC0+1/o0AVZfBTkTNJOdUw==", - "dev": true, - "license": "ISC" - }, "node_modules/emittery": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.2.0.tgz", @@ -4248,31 +3906,6 @@ "dev": true, "license": "MIT" }, - "node_modules/encoding": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", - "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "iconv-lite": "^0.6.2" - } - }, - "node_modules/encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/env-ci": { "version": "11.2.0", "resolved": "https://registry.npmjs.org/env-ci/-/env-ci-11.2.0.tgz", @@ -4879,39 +4512,19 @@ } }, "node_modules/fetch-mock": { - "name": "@gr2m/fetch-mock", - "version": "9.11.0-pull-request-644.1", - "resolved": "https://registry.npmjs.org/@gr2m/fetch-mock/-/fetch-mock-9.11.0-pull-request-644.1.tgz", - "integrity": "sha512-gTp6RCHzlOXS1qRb0APfuyz48Lw/JFPa4uiar+kEgL1STsDwth75HJZ4x30tBlXMJXV8XDTDzJ2Hz9w3RWiHJA==", - "deprecated": "The fix has been implemented in fetch-mock@10", + "version": "12.6.0", + "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-12.6.0.tgz", + "integrity": "sha512-oAy0OqAvjAvduqCeWveBix7LLuDbARPqZZ8ERYtBcCURA3gy7EALA3XWq0tCNxsSg+RmmJqyaeeZlOCV9abv6w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/core": "^7.0.0", - "@babel/runtime": "^7.0.0", - "core-js": "^3.0.0", - "debug": "^4.1.1", - "glob-to-regexp": "^0.4.0", - "is-subset": "^0.1.1", - "lodash.isequal": "^4.5.0", - "path-to-regexp": "^2.2.1", - "querystring": "^0.2.0", - "whatwg-url": "^6.5.0" + "@types/glob-to-regexp": "^0.4.4", + "dequal": "^2.0.3", + "glob-to-regexp": "^0.4.1", + "regexparam": "^3.0.0" }, "engines": { - "node": ">=4.0.0" - }, - "funding": { - "type": "charity", - "url": "https://www.justgiving.com/refugee-support-europe" - }, - "peerDependencies": { - "node-fetch": "*" - }, - "peerDependenciesMeta": { - "node-fetch": { - "optional": true - } + "node": ">=18.11.0" } }, "node_modules/figures": { @@ -5291,16 +4904,6 @@ "node": ">= 0.4" } }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -6680,13 +6283,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", - "dev": true, - "license": "MIT" - }, "node_modules/is-symbol": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", @@ -6957,19 +6553,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jsesc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", - "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", - "dev": true, - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/json-file-plus": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/json-file-plus/-/json-file-plus-3.3.2.tgz", @@ -7024,19 +6607,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/jsonfile": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", @@ -7226,14 +6796,6 @@ "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==", "license": "MIT" }, - "node_modules/lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -7269,13 +6831,6 @@ "license": "MIT", "optional": true }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", - "dev": true, - "license": "MIT" - }, "node_modules/lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", @@ -7370,16 +6925,6 @@ "node": ">=0.10.0" } }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^3.0.2" - } - }, "node_modules/ls-engines": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/ls-engines/-/ls-engines-0.9.3.tgz", @@ -7784,6 +7329,7 @@ "integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==", "dev": true, "license": "MIT", + "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -8693,13 +8239,6 @@ "dev": true, "license": "ISC" }, - "node_modules/node-releases": { - "version": "2.0.27", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", - "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", - "dev": true, - "license": "MIT" - }, "node_modules/node.extend": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/node.extend/-/node.extend-2.0.3.tgz", @@ -11109,6 +10648,7 @@ "dev": true, "inBundle": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -11956,13 +11496,6 @@ "dev": true, "license": "ISC" }, - "node_modules/path-to-regexp": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.4.0.tgz", - "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==", - "dev": true, - "license": "MIT" - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -12354,27 +11887,6 @@ "url": "https://bjornlu.com/sponsor" } }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/querystring": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz", - "integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==", - "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -12668,6 +12180,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/regexparam": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-3.0.0.tgz", + "integrity": "sha512-RSYAtP31mvYLkAHrOlh25pCNQ5hWnT106VukGaaFfuJrZFkGRX5GhUAdPqpSDXxOhA2c4akmRuplv1mRqnBn6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/registry-auth-token": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-5.1.0.tgz", @@ -12989,6 +12511,7 @@ "integrity": "sha512-6qGjWccl5yoyugHt3jTgztJ9Y0JVzyH8/Voc/D8PlLat9pwxQYXz7W1Dpnq5h0/G5GCYGUaDSlYcyk3AMh5A6g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@semantic-release/commit-analyzer": "^13.0.1", "@semantic-release/error": "^4.0.0", @@ -14578,16 +14101,6 @@ "node": ">=8.0" } }, - "node_modules/tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", - "dev": true, - "license": "MIT", - "dependencies": { - "punycode": "^2.1.0" - } - }, "node_modules/traverse": { "version": "0.6.8", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.8.tgz", @@ -14861,22 +14374,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "optional": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, "node_modules/uglify-js": { "version": "3.19.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", @@ -15008,37 +14505,6 @@ "node": ">= 10.0.0" } }, - "node_modules/update-browserslist-db": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.2.tgz", - "integrity": "sha512-E85pfNzMQ9jpKkA7+TJAi4TJN+tBCuWh5rUcS/sv6cFi+1q9LYDwDI5dpUL0u/73EElyQ8d3TEaeW4sPedBqYA==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "escalade": "^3.2.0", - "picocolors": "^1.1.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, "node_modules/url-join": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/url-join/-/url-join-5.0.0.tgz", @@ -15115,13 +14581,6 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", - "dev": true, - "license": "BSD-2-Clause" - }, "node_modules/well-known-symbols": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", @@ -15132,18 +14591,6 @@ "node": ">=6" } }, - "node_modules/whatwg-url": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", - "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -15551,13 +14998,6 @@ "node": ">=10" } }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "dev": true, - "license": "ISC" - }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/package.json b/package.json index 1ed6ced1..58cb85fa 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "c8": "10.1.3", "cpy": "12.1.0", "cz-conventional-changelog": "3.3.0", - "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1", + "fetch-mock": "12.6.0", "lockfile-lint": "4.14.1", "ls-engines": "0.9.3", "npm-run-all2": "8.0.4", diff --git a/test/add-channel.test.js b/test/add-channel.test.js index e14d696d..d028b57c 100644 --- a/test/add-channel.test.js +++ b/test/add-channel.test.js @@ -34,15 +34,16 @@ test("Update a release", async (t) => { const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId, }, + { repeat: 1 }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -53,6 +54,7 @@ test("Update a release", async (t) => { name: nextRelease.name, prerelease: false, }, + repeat: 1, }, ); @@ -68,7 +70,7 @@ test("Update a release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -78,7 +80,7 @@ test("Update a release", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Update a maintenance release", async (t) => { @@ -96,15 +98,16 @@ test("Update a maintenance release", async (t) => { const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId, }, + { repeat: 1 }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -115,6 +118,7 @@ test("Update a maintenance release", async (t) => { name: nextRelease.name, prerelease: false, }, + repeat: 1, }, ); @@ -130,7 +134,7 @@ test("Update a maintenance release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -140,7 +144,7 @@ test("Update a maintenance release", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Update a prerelease", async (t) => { @@ -157,15 +161,16 @@ test("Update a prerelease", async (t) => { const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId, }, + { repeat: 1 }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -176,6 +181,7 @@ test("Update a prerelease", async (t) => { name: nextRelease.name, prerelease: false, }, + repeat: 1, }, ); @@ -191,7 +197,7 @@ test("Update a prerelease", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -201,7 +207,7 @@ test("Update a prerelease", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Update a release with a custom github url", async (t) => { @@ -222,15 +228,16 @@ test("Update a release with a custom github url", async (t) => { const releaseUrl = `${env.GH_URL}/${owner}/${repo}/releases/${nextRelease.version}`; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://othertesturl.com:443/prefix/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId, }, + { repeat: 1 }, ) - .patchOnce( + .patch( `https://othertesturl.com:443/prefix/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -241,6 +248,7 @@ test("Update a release with a custom github url", async (t) => { name: nextRelease.name, prerelease: false, }, + repeat: 1, }, ); @@ -256,7 +264,7 @@ test("Update a release with a custom github url", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -266,7 +274,7 @@ test("Update a release with a custom github url", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Create the new release if current one is missing", async (t) => { @@ -282,13 +290,14 @@ test("Create the new release if current one is missing", async (t) => { const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` }; const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, 404, + { repeat: 1 }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { html_url: releaseUrl, @@ -300,6 +309,7 @@ test("Create the new release if current one is missing", async (t) => { body: nextRelease.notes, prerelease: false, }, + repeat: 1, }, ); @@ -315,7 +325,7 @@ test("Create the new release if current one is missing", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -329,7 +339,7 @@ test("Create the new release if current one is missing", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw error if cannot read current release", async (t) => { @@ -344,11 +354,12 @@ test("Throw error if cannot read current release", async (t) => { }; const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` }; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, 500, + { repeat: 1 }, ); const error = await t.throwsAsync( @@ -364,14 +375,14 @@ test("Throw error if cannot read current release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); t.is(error.status, 500); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw error if cannot create missing current release", async (t) => { @@ -388,19 +399,21 @@ test("Throw error if cannot create missing current release", async (t) => { repositoryUrl: `https://github.com/${owner}/${repo}.git`, }; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, 404, + { repeat: 1 }, ) - .postOnce(`https://api.github.local/repos/${owner}/${repo}/releases`, 500, { + .post(`https://api.github.local/repos/${owner}/${repo}/releases`, 500, { body: { tag_name: nextRelease.gitTag, name: nextRelease.name, body: nextRelease.notes, prerelease: false, }, + repeat: 1, }); const error = await t.throwsAsync( @@ -416,14 +429,14 @@ test("Throw error if cannot create missing current release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); t.is(error.status, 500); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw error if cannot update release", async (t) => { @@ -439,13 +452,14 @@ test("Throw error if cannot update release", async (t) => { const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` }; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce( + const fm = fetchMock + .createInstance() + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId }, + { repeat: 1 }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, 404, { @@ -454,6 +468,7 @@ test("Throw error if cannot update release", async (t) => { name: nextRelease.name, prerelease: false, }, + repeat: 1, }, ); @@ -470,12 +485,12 @@ test("Throw error if cannot update release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); t.is(error.status, 404); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); diff --git a/test/fail.test.js b/test/fail.test.js index 6d1f9d91..3a764c8a 100644 --- a/test/fail.test.js +++ b/test/fail.test.js @@ -36,26 +36,35 @@ test("Open a new issue with the list of errors", async (t) => { new SemanticReleaseError("Error message 2", "ERR2", "Error 2 details"), new SemanticReleaseError("Error message 3", "ERR3", "Error 3 details"), ]; - const fetch = fetchMock - .sandbox() - .getOnce("https://api.github.local/repos/test_user/test_repo", { - full_name: `${redirectedOwner}/${redirectedRepo}`, - }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + const fm = fetchMock + .createInstance() + .get( + "https://api.github.local/repos/test_user/test_repo", + { + full_name: `${redirectedOwner}/${redirectedRepo}`, + }, + { repeat: 1 }, + ) + .post( + "https://api.github.local/graphql", + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }) - .postOnce( - (url, { body }) => { - t.is( - url, - `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues`, - ); - - const data = JSON.parse(body); + { repeat: 1 }, + ) + .post( + ({ url, options }) => { + if ( + url !== + `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues` + ) + return false; + + const data = JSON.parse(options.body); t.is(data.title, failTitle); t.regex( data.body, @@ -68,6 +77,7 @@ test("Open a new issue with the list of errors", async (t) => { html_url: "https://github.com/issues/1", number: 1, }, + { repeat: 1 }, ); await fail( @@ -82,7 +92,7 @@ test("Open a new issue with the list of errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -94,7 +104,7 @@ test("Open a new issue with the list of errors", async (t) => { "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Open a new issue with the list of errors and custom title and comment", async (t) => { @@ -113,20 +123,28 @@ test("Open a new issue with the list of errors and custom title and comment", as new SemanticReleaseError("Error message 3", "ERR3", "Error 3 details"), ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - clone_url: `https://api.github.local/${owner}/${repo}.git`, - }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + clone_url: `https://api.github.local/${owner}/${repo}.git`, + }, + { repeat: 1 }, + ) + .post( + "https://api.github.local/graphql", + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }) - .postOnce( + { repeat: 1 }, + ) + .post( `https://api.github.local/repos/${owner}/${repo}/issues`, { html_url: "https://github.com/issues/1", number: 1 }, { @@ -135,6 +153,7 @@ test("Open a new issue with the list of errors and custom title and comment", as body: `branch master Error message 1 Error message 2 Error message 3\n\n${ISSUE_ID}`, labels: ["semantic-release", RELEASE_FAIL_LABEL], }, + repeat: 1, }, ); @@ -150,7 +169,7 @@ test("Open a new issue with the list of errors and custom title and comment", as { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -162,7 +181,7 @@ test("Open a new issue with the list of errors and custom title and comment", as "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Open a new issue with assignees and the list of errors", async (t) => { @@ -180,24 +199,33 @@ test("Open a new issue with assignees and the list of errors", async (t) => { new SemanticReleaseError("Error message 2", "ERR2", "Error 2 details"), ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - clone_url: `https://api.github.local/${owner}/${repo}.git`, - }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + clone_url: `https://api.github.local/${owner}/${repo}.git`, + }, + { repeat: 1 }, + ) + .post( + "https://api.github.local/graphql", + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }) - .postOnce( - (url, { body }) => { - t.is(url, `https://api.github.local/repos/${owner}/${repo}/issues`); + { repeat: 1 }, + ) + .post( + ({ url, options }) => { + if (url !== `https://api.github.local/repos/${owner}/${repo}/issues`) + return false; - const data = JSON.parse(body); + const data = JSON.parse(options.body); t.is(data.title, failTitle); t.regex( data.body, @@ -208,6 +236,7 @@ test("Open a new issue with assignees and the list of errors", async (t) => { return true; }, { html_url: "https://github.com/issues/1", number: 1 }, + { repeat: 1 }, ); await fail( @@ -222,7 +251,7 @@ test("Open a new issue with assignees and the list of errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -234,7 +263,7 @@ test("Open a new issue with assignees and the list of errors", async (t) => { "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Open a new issue without labels and the list of errors", async (t) => { @@ -252,24 +281,33 @@ test("Open a new issue without labels and the list of errors", async (t) => { new SemanticReleaseError("Error message 2", "ERR2", "Error 2 details"), ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - clone_url: `https://api.github.local/${owner}/${repo}.git`, - }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + clone_url: `https://api.github.local/${owner}/${repo}.git`, + }, + { repeat: 1 }, + ) + .post( + "https://api.github.local/graphql", + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }) - .postOnce( - (url, { body }) => { - t.is(url, `https://api.github.local/repos/${owner}/${repo}/issues`); + { repeat: 1 }, + ) + .post( + ({ url, options }) => { + if (url !== `https://api.github.local/repos/${owner}/${repo}/issues`) + return false; - const data = JSON.parse(body); + const data = JSON.parse(options.body); t.is(data.title, failTitle); t.regex( data.body, @@ -279,6 +317,7 @@ test("Open a new issue without labels and the list of errors", async (t) => { return true; }, { html_url: "https://github.com/issues/1", number: 1 }, + { repeat: 1 }, ); await fail( @@ -293,7 +332,7 @@ test("Open a new issue without labels and the list of errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -305,7 +344,7 @@ test("Open a new issue without labels and the list of errors", async (t) => { "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Update the first existing issue with the list of errors", async (t) => { @@ -328,32 +367,42 @@ test("Update the first existing issue with the list of errors", async (t) => { { number: 3, body: `Issue 3 body\n\n${ISSUE_ID}`, title: failTitle }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - clone_url: `https://api.github.local/${owner}/${repo}.git`, - }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: issues }, + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + clone_url: `https://api.github.local/${owner}/${repo}.git`, + }, + { repeat: 1 }, + ) + .post( + "https://api.github.local/graphql", + { + data: { + repository: { + issues: { nodes: issues }, + }, }, }, - }) - .postOnce( - (url, { body }) => { - t.is( - url, - `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, - ); + { repeat: 1 }, + ) + .post( + ({ url, options }) => { + if ( + url !== + `https://api.github.local/repos/${owner}/${repo}/issues/2/comments` + ) + return false; t.regex( - JSON.parse(body).body, + JSON.parse(options.body).body, /---\n\n### Error message 1\n\nError 1 details\n\n---\n\n### Error message 2\n\nError 2 details\n\n---\n\n### Error message 3\n\nError 3 details\n\n---/, ); return true; }, { html_url: "https://github.com/issues/2", number: 2 }, + { repeat: 1 }, ); await fail( @@ -368,7 +417,7 @@ test("Update the first existing issue with the list of errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -383,7 +432,7 @@ test("Update the first existing issue with the list of errors", async (t) => { "https://github.com/issues/2", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Skip if "failComment" is "false"', async (t) => { @@ -494,15 +543,19 @@ test('Does not post comments on existing issues when "failCommentCondition" is " { number: 3, body: `Issue 3 body\n\n${ISSUE_ID}`, title: failTitle }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - }) - .postOnce( - (url, { body }) => + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + }, + { repeat: 1 }, + ) + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getSRIssues("), + JSON.parse(options.body).query.includes("query getSRIssues("), { data: { repository: { @@ -510,6 +563,7 @@ test('Does not post comments on existing issues when "failCommentCondition" is " }, }, }, + { repeat: 1 }, ); await fail( @@ -524,12 +578,12 @@ test('Does not post comments on existing issues when "failCommentCondition" is " { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.true(t.context.log.calledWith("Skip commenting on or creating an issue.")); }); @@ -548,15 +602,19 @@ test(`Post new issue if none exists yet, but don't comment on existing issues wh repositoryUrl: `https://github.com/${owner}/${repo}.git`, }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { - full_name: `${owner}/${repo}`, - }) - .postOnce( - (url, { body }) => + const fm = fetchMock + .createInstance() + .get( + `https://api.github.local/repos/${owner}/${repo}`, + { + full_name: `${owner}/${repo}`, + }, + { repeat: 1 }, + ) + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getSRIssues("), + JSON.parse(options.body).query.includes("query getSRIssues("), { data: { repository: { @@ -564,17 +622,20 @@ test(`Post new issue if none exists yet, but don't comment on existing issues wh }, }, }, + { repeat: 1 }, ) - .postOnce( - (url, { body }) => { - t.is(url, `https://api.github.local/repos/${owner}/${repo}/issues`); + .post( + ({ url, options }) => { + if (url !== `https://api.github.local/repos/${owner}/${repo}/issues`) + return false; t.regex( - JSON.parse(body).body, + JSON.parse(options.body).body, /Error: Release for branch master failed with error: An error occured\n\n/, ); return true; }, { html_url: "https://github.com/issues/2", number: 2 }, + { repeat: 1 }, ); await fail( @@ -589,12 +650,12 @@ test(`Post new issue if none exists yet, but don't comment on existing issues wh { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.true( t.context.log.calledWith( "Created issue #%d: %s.", diff --git a/test/find-sr-issue.test.js b/test/find-sr-issue.test.js index 5009372d..e3f51eba 100644 --- a/test/find-sr-issue.test.js +++ b/test/find-sr-issue.test.js @@ -29,18 +29,20 @@ test("Filter out issues without ID", async (t) => { { number: 3, body: `Issue 3 body\n\n${ISSUE_ID}`, title }, ]; - const fetch = fetchMock - .sandbox() - .postOnce("https://api.github.local/graphql", { + const fm = fetchMock.createInstance().post( + "https://api.github.local/graphql", + { data: { repository: { issues: { nodes: issues }, }, }, - }); + }, + { repeat: 1 }, + ); const srIssues = await findSRIssues( - new TestOctokit({ request: { fetch } }), + new TestOctokit({ request: { fetch: fm.fetchHandler } }), t.context.logger, title, labels, @@ -61,7 +63,7 @@ test("Filter out issues without ID", async (t) => { }, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Return empty array if not issues found", async (t) => { @@ -69,18 +71,20 @@ test("Return empty array if not issues found", async (t) => { const repo = "test_repo"; const title = "The automated release is failing 🚨"; const labels = []; - const fetch = fetchMock - .sandbox() - .postOnce("https://api.github.local/graphql", { + const fm = fetchMock.createInstance().post( + "https://api.github.local/graphql", + { data: { repository: { issues: { nodes: [] }, }, }, - }); + }, + { repeat: 1 }, + ); const srIssues = await findSRIssues( - new TestOctokit({ request: { fetch } }), + new TestOctokit({ request: { fetch: fm.fetchHandler } }), t.context.logger, title, labels, @@ -90,7 +94,7 @@ test("Return empty array if not issues found", async (t) => { t.deepEqual(srIssues, []); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Return empty array if not issues has matching ID", async (t) => { @@ -102,18 +106,20 @@ test("Return empty array if not issues has matching ID", async (t) => { { number: 1, body: "Issue 1 body", title }, { number: 2, body: "Issue 2 body", title }, ]; - const fetch = fetchMock - .sandbox() - .postOnce("https://api.github.local/graphql", { + const fm = fetchMock.createInstance().post( + "https://api.github.local/graphql", + { data: { repository: { issues: { nodes: issues }, }, }, - }); + }, + { repeat: 1 }, + ); const srIssues = await findSRIssues( - new TestOctokit({ request: { fetch } }), + new TestOctokit({ request: { fetch: fm.fetchHandler } }), t.context.logger, title, labels, @@ -122,5 +128,5 @@ test("Return empty array if not issues has matching ID", async (t) => { ); t.deepEqual(srIssues, []); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); diff --git a/test/integration.test.js b/test/integration.test.js index b4b83f55..bcf3eb37 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -30,9 +30,9 @@ test("Verify GitHub auth", async (t) => { repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`, }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -46,13 +46,13 @@ test("Verify GitHub auth", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify GitHub auth with publish options", async (t) => { @@ -63,8 +63,8 @@ test("Verify GitHub auth with publish options", async (t) => { publish: { path: "@semantic-release/github" }, repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`, }; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, @@ -79,13 +79,13 @@ test("Verify GitHub auth with publish options", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify GitHub auth and assets config", async (t) => { @@ -103,9 +103,9 @@ test("Verify GitHub auth and assets config", async (t) => { publish: [{ path: "@semantic-release/npm" }], repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`, }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -119,13 +119,13 @@ test("Verify GitHub auth and assets config", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw SemanticReleaseError if invalid config", async (t) => { @@ -161,7 +161,7 @@ test("Throw SemanticReleaseError if invalid config", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -209,15 +209,15 @@ test("Publish a release with an array of assets", async (t) => { const uploadUri = `/api/uploads/repos/${owner}/${repo}/releases/${releaseId}/assets`; const uploadUrl = `${uploadOrigin}${uploadUri}{?name,label}`; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, html_url: releaseUrl, id: releaseId }, { @@ -230,14 +230,14 @@ test("Publish a release with an array of assets", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { body: { draft: false }, }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( "upload_file_name.txt", )}&`, @@ -245,7 +245,7 @@ test("Publish a release with an array of assets", async (t) => { browser_download_url: assetUrl, }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( "other_file.txt", )}&label=${encodeURIComponent("Other File")}`, @@ -265,7 +265,7 @@ test("Publish a release with an array of assets", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -275,7 +275,7 @@ test("Publish a release with an array of assets", async (t) => { t.true(t.context.log.calledWith("Published file %s", otherAssetUrl)); t.true(t.context.log.calledWith("Published file %s", assetUrl)); t.true(t.context.log.calledWith("Published GitHub release: %s", releaseUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release with release information in assets", async (t) => { @@ -304,15 +304,15 @@ test("Publish a release with release information in assets", async (t) => { const uploadUri = `/api/uploads/repos/${owner}/${repo}/releases/${releaseId}/assets`; const uploadUrl = `${uploadOrigin}${uploadUri}{?name,label}`; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, html_url: releaseUrl, id: releaseId }, { @@ -325,14 +325,14 @@ test("Publish a release with release information in assets", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { body: { draft: false }, }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( "file_with_release_v1.0.0_in_filename.txt", )}&label=${encodeURIComponent("File with release v1.0.0 in label")}`, @@ -352,7 +352,7 @@ test("Publish a release with release information in assets", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -361,7 +361,7 @@ test("Publish a release with release information in assets", async (t) => { t.deepEqual(t.context.log.args[0], ["Verify GitHub authentication"]); t.true(t.context.log.calledWith("Published file %s", assetUrl)); t.true(t.context.log.calledWith("Published GitHub release: %s", releaseUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Update a release", async (t) => { @@ -377,19 +377,19 @@ test("Update a release", async (t) => { const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`; const releaseId = 1; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .getOnce( + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { @@ -414,7 +414,7 @@ test("Update a release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -425,7 +425,7 @@ test("Update a release", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Comment and add labels on PR included in the releases", async (t) => { @@ -443,8 +443,8 @@ test("Comment and add labels on PR included in the releases", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get( `https://api.github.local/repos/${owner}/${repo}`, { @@ -456,12 +456,10 @@ test("Comment and add labels on PR included in the releases", async (t) => { repeat: 2, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -478,38 +476,30 @@ test("Comment and add labels on PR included in the releases", async (t) => { }, }, }, + { repeat: 1 }, ) - .getOnce( + .get( `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [{ sha: commits[0].hash }], + { repeat: 1 }, ) - .postOnce( - (url, { body }) => { - t.is( - url, - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - ); - - const data = JSON.parse(body); - t.regex(data.body, /This PR is included/); - - return true; - }, + .post( + `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { html_url: "https://github.com/successcomment-1" }, + { repeat: 1 }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"], + repeat: 1, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -517,6 +507,7 @@ test("Comment and add labels on PR included in the releases", async (t) => { }, }, }, + { repeat: 1 }, ); await t.context.m.success( @@ -533,7 +524,7 @@ test("Comment and add labels on PR included in the releases", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -549,7 +540,7 @@ test("Comment and add labels on PR included in the releases", async (t) => { t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["released"], 1), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Open a new issue with the list of errors", async (t) => { @@ -564,8 +555,8 @@ test("Open a new issue with the list of errors", async (t) => { new SemanticReleaseError("Error message 3", "ERR3", "Error 3 details"), ]; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get( `https://api.github.local/repos/${owner}/${repo}`, { @@ -575,17 +566,18 @@ test("Open a new issue with the list of errors", async (t) => { }, { repeat: 2 }, ) - .postOnce("https://api.github.local/graphql", { + .post("https://api.github.local/graphql", { data: { repository: { issues: { nodes: [] }, }, }, }) - .postOnce( - (url, { body }) => { - t.is(url, `https://api.github.local/repos/${owner}/${repo}/issues`); - const data = JSON.parse(body); + .post( + ({ url, options }) => { + if (url !== `https://api.github.local/repos/${owner}/${repo}/issues`) + return false; + const data = JSON.parse(options.body); t.is(data.title, failTitle); t.regex( data.body, @@ -611,7 +603,7 @@ test("Open a new issue with the list of errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -624,7 +616,7 @@ test("Open a new issue with the list of errors", async (t) => { "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify, release and notify success", async (t) => { @@ -658,8 +650,8 @@ test("Verify, release and notify success", async (t) => { const prs = [{ number: 1, pull_request: true, state: "closed" }]; const commits = [{ hash: "123", message: "Commit 1 message" }]; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get( `https://api.github.local/repos/${owner}/${repo}`, { @@ -671,10 +663,10 @@ test("Verify, release and notify success", async (t) => { repeat: 2, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -692,10 +684,10 @@ test("Verify, release and notify success", async (t) => { }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getSRIssues("), + JSON.parse(options.body).query.includes("query getSRIssues("), { data: { repository: { @@ -704,7 +696,7 @@ test("Verify, release and notify success", async (t) => { }, }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -721,25 +713,24 @@ test("Verify, release and notify success", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { body: { draft: false } }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"] }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent("upload.txt")}&`, { browser_download_url: assetUrl }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=other_file.txt&label=${encodeURIComponent( "Other File", )}`, @@ -747,12 +738,9 @@ test("Verify, release and notify success", async (t) => { browser_download_url: otherAssetUrl, }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { - html_url: "https://github.com/successcomment-1", - }, - ); + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }); await t.notThrowsAsync( t.context.m.verifyConditions( @@ -761,7 +749,7 @@ test("Verify, release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -779,7 +767,7 @@ test("Verify, release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -797,7 +785,7 @@ test("Verify, release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -806,7 +794,7 @@ test("Verify, release and notify success", async (t) => { t.true(t.context.log.calledWith("Published file %s", otherAssetUrl)); t.true(t.context.log.calledWith("Published file %s", assetUrl)); t.true(t.context.log.calledWith("Published GitHub release: %s", releaseUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify, update release and notify success", async (t) => { @@ -833,8 +821,8 @@ test("Verify, update release and notify success", async (t) => { { hash: "123", message: "Commit 1 message", tree: { long: "aaa" } }, ]; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get( `https://api.github.local/repos/${owner}/${repo}`, { @@ -846,11 +834,11 @@ test("Verify, update release and notify success", async (t) => { repeat: 2, }, ) - .getOnce( + .get( `https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`, { id: releaseId }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { @@ -861,12 +849,10 @@ test("Verify, update release and notify success", async (t) => { }, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -883,30 +869,30 @@ test("Verify, update release and notify success", async (t) => { }, }, }, + { repeat: 1 }, ) - .getOnce( + .get( `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [{ sha: commits[0].hash }], + { repeat: 1 }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { - html_url: "https://github.com/successcomment-1", - }, + { html_url: "https://github.com/successcomment-1" }, + { repeat: 1 }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"], + repeat: 1, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -914,6 +900,7 @@ test("Verify, update release and notify success", async (t) => { }, }, }, + { repeat: 1 }, ); await t.notThrowsAsync( @@ -923,7 +910,7 @@ test("Verify, update release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -941,7 +928,7 @@ test("Verify, update release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -959,7 +946,7 @@ test("Verify, update release and notify success", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -969,7 +956,7 @@ test("Verify, update release and notify success", async (t) => { "Updated GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify and notify failure", async (t) => { @@ -984,8 +971,8 @@ test("Verify and notify failure", async (t) => { new SemanticReleaseError("Error message 3", "ERR3", "Error 3 details"), ]; - const fetch = fetchMock - .sandbox() + const fm = fetchMock + .createInstance() .get( `https://api.github.local/repos/${owner}/${repo}`, { @@ -997,14 +984,14 @@ test("Verify and notify failure", async (t) => { repeat: 2, }, ) - .postOnce("https://api.github.local/graphql", { + .post("https://api.github.local/graphql", { data: { repository: { issues: { nodes: [] }, }, }, }) - .postOnce(`https://api.github.local/repos/${owner}/${repo}/issues`, { + .post(`https://api.github.local/repos/${owner}/${repo}/issues`, { html_url: "https://github.com/issues/1", number: 1, }); @@ -1016,7 +1003,7 @@ test("Verify and notify failure", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1034,7 +1021,7 @@ test("Verify and notify failure", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1047,5 +1034,5 @@ test("Verify and notify failure", async (t) => { "https://github.com/issues/1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); diff --git a/test/publish.test.js b/test/publish.test.js index 3009068a..71558605 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -40,7 +40,7 @@ test("Publish a release without creating discussion", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -70,7 +70,7 @@ test("Publish a release without creating discussion", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -80,7 +80,7 @@ test("Publish a release without creating discussion", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release and create discussion", async (t) => { @@ -103,7 +103,7 @@ test("Publish a release and create discussion", async (t) => { const discussionId = 1; const discussionUrl = `https://github.com/${owner}/${repo}/discussions/${discussionId}`; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -135,7 +135,7 @@ test("Publish a release and create discussion", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -149,7 +149,7 @@ test("Publish a release and create discussion", async (t) => { "Created GitHub release discussion: %s", discussionUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release on a channel", async (t) => { @@ -169,7 +169,7 @@ test("Publish a release on a channel", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -199,7 +199,7 @@ test("Publish a release on a channel", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -209,7 +209,7 @@ test("Publish a release on a channel", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a prerelease wihtout creating discussion", async (t) => { @@ -229,7 +229,7 @@ test("Publish a prerelease wihtout creating discussion", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -259,7 +259,7 @@ test("Publish a prerelease wihtout creating discussion", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -269,7 +269,7 @@ test("Publish a prerelease wihtout creating discussion", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a prerelease and create discussion", async (t) => { @@ -291,7 +291,7 @@ test("Publish a prerelease and create discussion", async (t) => { const discussionId = 1; const discussionUrl = `https://github.com/${owner}/${repo}/discussions/${discussionId}`; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -323,7 +323,7 @@ test("Publish a prerelease and create discussion", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -337,7 +337,7 @@ test("Publish a prerelease and create discussion", async (t) => { "Created GitHub release discussion: %s", discussionUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a maintenance release", async (t) => { @@ -357,7 +357,7 @@ test("Publish a maintenance release", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -393,7 +393,7 @@ test("Publish a maintenance release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -403,7 +403,7 @@ test("Publish a maintenance release", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release with one asset", async (t) => { @@ -431,9 +431,9 @@ test("Publish a release with one asset", async (t) => { const uploadUrl = `${uploadOrigin}${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock - .sandbox() - .postOnce( + const fm = fetchMock + .createInstance() + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -451,12 +451,12 @@ test("Publish a release with one asset", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { upload_url: uploadUrl, html_url: releaseUrl }, { body: { draft: false } }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( ".dotfile", )}&label=${encodeURIComponent("A dotfile with no ext")}`, @@ -476,7 +476,7 @@ test("Publish a release with one asset", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -484,7 +484,7 @@ test("Publish a release with one asset", async (t) => { t.is(result.url, releaseUrl); t.true(t.context.log.calledWith("Published GitHub release: %s", releaseUrl)); t.true(t.context.log.calledWith("Published file %s", assetUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release with one asset and custom github url", async (t) => { @@ -518,9 +518,9 @@ test("Publish a release with one asset and custom github url", async (t) => { const uploadUrl = `${env.GH_URL}${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock - .sandbox() - .postOnce( + const fm = fetchMock + .createInstance() + .post( `${env.GH_URL}/prefix/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -538,12 +538,12 @@ test("Publish a release with one asset and custom github url", async (t) => { }, }, ) - .patchOnce( + .patch( `${env.GH_URL}/prefix/repos/${owner}/${repo}/releases/${releaseId}`, { upload_url: uploadUrl, html_url: releaseUrl }, { body: { draft: false } }, ) - .postOnce( + .post( `${env.GH_URL}${uploadUri}?name=${encodeURIComponent( "upload.txt", )}&label=${encodeURIComponent("A text file")}`, @@ -565,7 +565,7 @@ test("Publish a release with one asset and custom github url", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -573,7 +573,7 @@ test("Publish a release with one asset and custom github url", async (t) => { t.is(result.url, releaseUrl); t.true(t.context.log.calledWith("Published GitHub release: %s", releaseUrl)); t.true(t.context.log.calledWith("Published file %s", assetUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release with an array of missing assets", async (t) => { @@ -599,9 +599,9 @@ test("Publish a release with an array of missing assets", async (t) => { const uploadUrl = `${uploadOrigin}${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock - .sandbox() - .postOnce( + const fm = fetchMock + .createInstance() + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -619,7 +619,7 @@ test("Publish a release with an array of missing assets", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl }, { body: { draft: false } }, @@ -638,7 +638,7 @@ test("Publish a release with an array of missing assets", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -657,7 +657,7 @@ test("Publish a release with an array of missing assets", async (t) => { emptyDirectory, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release with asset and create discussion", async (t) => { @@ -688,9 +688,9 @@ test("Publish a release with asset and create discussion", async (t) => { const discussionId = 1; const discussionUrl = `https://github.com/${owner}/${repo}/discussions/${discussionId}`; - const fetch = fetchMock - .sandbox() - .postOnce( + const fm = fetchMock + .createInstance() + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -708,7 +708,7 @@ test("Publish a release with asset and create discussion", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { upload_url: uploadUrl, @@ -722,7 +722,7 @@ test("Publish a release with asset and create discussion", async (t) => { }, }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( ".dotfile", )}&label=${encodeURIComponent("A dotfile with no ext")}`, @@ -742,7 +742,7 @@ test("Publish a release with asset and create discussion", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -756,7 +756,7 @@ test("Publish a release with asset and create discussion", async (t) => { ), ); t.true(t.context.log.calledWith("Published file %s", assetUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a draft release", async (t) => { @@ -776,7 +776,7 @@ test("Publish a draft release", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -807,7 +807,7 @@ test("Publish a draft release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -817,7 +817,7 @@ test("Publish a draft release", async (t) => { "Created GitHub draft release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a draft release with one asset", async (t) => { @@ -845,9 +845,9 @@ test("Publish a draft release with one asset", async (t) => { const uploadUrl = `${uploadOrigin}${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock - .sandbox() - .postOnce( + const fm = fetchMock + .createInstance() + .post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -865,7 +865,7 @@ test("Publish a draft release with one asset", async (t) => { }, }, ) - .postOnce( + .post( `${uploadOrigin}${uploadUri}?name=${encodeURIComponent( ".dotfile", )}&label=${encodeURIComponent("A dotfile with no ext")}`, @@ -885,7 +885,7 @@ test("Publish a draft release with one asset", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -895,7 +895,7 @@ test("Publish a draft release with one asset", async (t) => { t.context.log.calledWith("Created GitHub draft release: %s", releaseUrl), ); t.true(t.context.log.calledWith("Published file %s", assetUrl)); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a release when env.GITHUB_URL is set to https://github.com (Default in GitHub Actions, #268)", async (t) => { @@ -921,7 +921,7 @@ test("Publish a release when env.GITHUB_URL is set to https://github.com (Defaul const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.com/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -951,7 +951,7 @@ test("Publish a release when env.GITHUB_URL is set to https://github.com (Defaul { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -961,7 +961,7 @@ test("Publish a release when env.GITHUB_URL is set to https://github.com (Defaul "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a custom release body", async (t) => { @@ -984,7 +984,7 @@ test("Publish a custom release body", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -1014,7 +1014,7 @@ test("Publish a custom release body", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1024,7 +1024,7 @@ test("Publish a custom release body", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Publish a custom release name", async (t) => { @@ -1047,7 +1047,7 @@ test("Publish a custom release name", async (t) => { const uploadUrl = `https://github.com${uploadUri}{?name,label}`; const branch = "test_branch"; - const fetch = fetchMock.sandbox().postOnce( + const fm = fetchMock.createInstance().post( `https://api.github.local/repos/${owner}/${repo}/releases`, { upload_url: uploadUrl, @@ -1077,7 +1077,7 @@ test("Publish a custom release name", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1087,5 +1087,5 @@ test("Publish a custom release name", async (t) => { "Published GitHub release: %s", releaseUrl, ]); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); diff --git a/test/success.test.js b/test/success.test.js index e88e1b70..cca1d2b4 100644 --- a/test/success.test.js +++ b/test/success.test.js @@ -58,16 +58,16 @@ test("Add comment and labels to PRs associated with release commits and issues s { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${redirectedOwner}/${redirectedRepo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -95,10 +95,10 @@ test("Add comment and labels to PRs associated with release commits and issues s }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -180,58 +180,56 @@ test("Add comment and labels to PRs associated with release commits and issues s }, }, ) - .getOnce( + .get( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/pulls/1/commits`, [{ sha: commits[0].hash }], ) - .getOnce( + .get( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/pulls/2/commits`, [{ sha: commits[1].hash }], ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/1/comments`, { html_url: "https://github.com/successcomment-1", }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/1/labels`, {}, { body: ["released"] }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/2/comments`, { html_url: "https://github.com/successcomment-2" }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/2/labels`, {}, { body: ["released"] }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/3/comments`, { html_url: "https://github.com/successcomment-3" }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/3/labels`, {}, { body: ["released"] }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/4/comments`, { html_url: "https://github.com/successcomment-4" }, ) - .postOnce( + .post( `https://api.github.local/repos/${redirectedOwner}/${redirectedRepo}/issues/4/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -254,7 +252,7 @@ test("Add comment and labels to PRs associated with release commits and issues s { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -299,7 +297,7 @@ test("Add comment and labels to PRs associated with release commits and issues s t.true( t.context.log.calledWith("Added labels %O to issue #%d", ["released"], 4), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Add comment and labels to PRs associated with release commits and issues (multipaged associatedPRs)", async (t) => { @@ -336,53 +334,20 @@ test("Add comment and labels to PRs associated with release commits and issues ( { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - commit123: { - oid: "123", - associatedPullRequests: { - pageInfo: { - endCursor: "YE", - hasNextPage: true, - }, - nodes: [prs[0]], - }, - }, - commit456: { - oid: "456", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, - }, - nodes: [prs[1]], - }, - }, - commit789: { - oid: "789", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, - }, - nodes: [prs[2]], - }, - }, - }, - }, - }) - .postOnce( - "https://api.github.local/graphql", + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { - commit: { + commit123: { + oid: "123", associatedPullRequests: { pageInfo: { endCursor: "NE", @@ -391,17 +356,35 @@ test("Add comment and labels to PRs associated with release commits and issues ( nodes: [prs[3]], }, }, + commit456: { + oid: "456", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], + }, + }, + commit789: { + oid: "789", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], + }, + }, }, }, }, - { - overwriteRoutes: true, - }, + { repeat: 1 }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -483,43 +466,37 @@ test("Add comment and labels to PRs associated with release commits and issues ( }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/6/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/3/comments`, - { html_url: "https://github.com/successcomment-3" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/6/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/3/comments`, { + html_url: "https://github.com/successcomment-3", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/3/labels`, {}, { body: ["released"] }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, - { html_url: "https://github.com/successcomment-4" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, { + html_url: "https://github.com/successcomment-4", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released"] }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/6/comments`, - { html_url: "https://github.com/successcomment-6" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/6/comments`, { + html_url: "https://github.com/successcomment-6", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/6/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -542,7 +519,7 @@ test("Add comment and labels to PRs associated with release commits and issues ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -577,7 +554,7 @@ test("Add comment and labels to PRs associated with release commits and issues ( t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["released"], 6), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Add comment and labels to PRs associated with release commits and issues closed by PR/commits comments with custom URL", async (t) => { @@ -611,15 +588,15 @@ test("Add comment and labels to PRs associated with release commits and issues c { name: "GitHub release", url: "https://custom-url.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://custom-url.com/prefix/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://custom-url.com/prefix/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://custom-url.com/prefix/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -647,10 +624,10 @@ test("Add comment and labels to PRs associated with release commits and issues c }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://custom-url.com/prefix/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -732,64 +709,62 @@ test("Add comment and labels to PRs associated with release commits and issues c }, }, ) - .getOnce( + .get( `https://custom-url.com/prefix/repos/${owner}/${repo}/pulls/1/commits`, [{ sha: commits[0].hash }], ) - .getOnce( + .get( `https://custom-url.com/prefix/repos/${owner}/${repo}/pulls/2/commits`, [{ sha: commits[1].hash }], ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/1/comments`, { html_url: "https://custom-url.com/successcomment-1", }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released on @next"] }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/2/comments`, { html_url: "https://custom-url.com/successcomment-2", }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/2/labels`, {}, { body: ["released on @next"] }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/3/comments`, { html_url: "https://custom-url.com/successcomment-3", }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/3/labels`, {}, { body: ["released on @next"] }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/4/comments`, { html_url: "https://custom-url.com/successcomment-4", }, ) - .postOnce( + .post( `https://custom-url.com/prefix/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released on @next"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://custom-url.com/prefix/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://custom-url.com/prefix/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -812,7 +787,7 @@ test("Add comment and labels to PRs associated with release commits and issues c { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -873,7 +848,7 @@ test("Add comment and labels to PRs associated with release commits and issues c 4, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Make multiple search queries if necessary", async (t) => { @@ -908,18 +883,16 @@ test("Make multiple search queries if necessary", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -987,102 +960,88 @@ test("Make multiple search queries if necessary", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: commits[1].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, - [{ sha: commits[2].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/4/commits`, - [{ sha: commits[3].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/5/commits`, - [{ sha: commits[4].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/6/commits`, - [{ sha: commits[5].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: commits[1].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, [ + { sha: commits[2].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/4/commits`, [ + { sha: commits[3].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/5/commits`, [ + { sha: commits[4].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/6/commits`, [ + { sha: commits[5].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"], }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, - { html_url: "https://github.com/successcomment-2" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, { + html_url: "https://github.com/successcomment-2", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/2/labels`, {}, { body: ["released"], }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/3/comments`, - { html_url: "https://github.com/successcomment-3" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/3/comments`, { + html_url: "https://github.com/successcomment-3", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/3/labels`, {}, { body: ["released"], }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, - { html_url: "https://github.com/successcomment-4" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, { + html_url: "https://github.com/successcomment-4", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released"], }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, - { html_url: "https://github.com/successcomment-5" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, { + html_url: "https://github.com/successcomment-5", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/5/labels`, {}, { body: ["released"], }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/6/comments`, - { html_url: "https://github.com/successcomment-6" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/6/comments`, { + html_url: "https://github.com/successcomment-6", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/6/labels`, {}, { body: ["released"], }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1105,7 +1064,7 @@ test("Make multiple search queries if necessary", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1170,7 +1129,7 @@ test("Make multiple search queries if necessary", async (t) => { t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["released"], 6), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Do not add comment and labels for unrelated PR returned by search (compare sha and merge_commit_sha)", async (t) => { @@ -1196,18 +1155,16 @@ test("Do not add comment and labels for unrelated PR returned by search (compare { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1235,37 +1192,30 @@ test("Do not add comment and labels for unrelated PR returned by search (compare }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: "rebased_sha" }], - ) - .getOnce(`https://api.github.local/repos/${owner}/${repo}/pulls/1`, { + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: "rebased_sha" }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1`, { merge_commit_sha: commits[0].hash, }) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: "rebased_sha" }], - ) - .getOnce(`https://api.github.local/repos/${owner}/${repo}/pulls/2`, { + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: "rebased_sha" }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2`, { merge_commit_sha: "unrelated_sha", }) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { - html_url: "https://github.com/successcomment-1", - }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1288,7 +1238,7 @@ test("Do not add comment and labels for unrelated PR returned by search (compare { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1303,7 +1253,7 @@ test("Do not add comment and labels for unrelated PR returned by search (compare t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["released"], 1), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Do not add comment and labels if no PR is associated with release commits", async (t) => { @@ -1322,18 +1272,16 @@ test("Do not add comment and labels if no PR is associated with release commits" { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1351,12 +1299,10 @@ test("Do not add comment and labels if no PR is associated with release commits" }, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1379,12 +1325,12 @@ test("Do not add comment and labels if no PR is associated with release commits" { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Do not add comment and labels if no commits is found for release", async (t) => { @@ -1403,19 +1349,25 @@ test("Do not add comment and labels if no commits is found for release", async ( { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }); + { repeat: 1 }, + ); await success( pluginConfig, @@ -1430,12 +1382,12 @@ test("Do not add comment and labels if no commits is found for release", async ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.true(t.context.log.calledWith("No commits found in release")); t.true( t.context.log.calledWith("Skip commenting on issues and pull requests."), @@ -1462,54 +1414,58 @@ test("Do not add comment and labels to PR/issues from other repo", async (t) => { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - commit123: { - oid: "123", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + commit123: { + oid: "123", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, - }, - commit456: { - oid: "456", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + commit456: { + oid: "456", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, - }, - commit789: { - oid: "789", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + commit789: { + oid: "789", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, }, }, }, - }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getRelatedIssues\(/); - return true; - }, + { repeat: 1 }, + ) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getRelatedIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1553,21 +1509,18 @@ test("Do not add comment and labels to PR/issues from other repo", async (t) => }, }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, - { html_url: "https://github.com/successcomment-2" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, { + html_url: "https://github.com/successcomment-2", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/2/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1590,7 +1543,7 @@ test("Do not add comment and labels to PR/issues from other repo", async (t) => { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1605,7 +1558,7 @@ test("Do not add comment and labels to PR/issues from other repo", async (t) => t.true( t.context.log.calledWith("Added labels %O to issue #%d", ["released"], 2), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Ignore missing and forbidden issues/PRs", async (t) => { @@ -1633,16 +1586,16 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -1680,10 +1633,10 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -1802,59 +1755,51 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: commits[1].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, - [{ sha: commits[2].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: commits[1].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, [ + { sha: commits[2].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released"] }, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, 404, ) - .postOnce( + .post( `https://api.github.local/repos/${owner}/${repo}/issues/3/comments`, 403, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, - { html_url: "https://github.com/successcomment-4" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, { + html_url: "https://github.com/successcomment-4", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released"] }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, - { html_url: "https://github.com/successcomment-5" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, { + html_url: "https://github.com/successcomment-5", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/5/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1877,7 +1822,7 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -1924,7 +1869,7 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { 3, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Add custom comment and labels", async (t) => { @@ -1951,18 +1896,16 @@ test("Add custom comment and labels", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -1980,28 +1923,22 @@ test("Add custom comment and labels", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { - html_url: "https://github.com/successcomment-1", - body: `last release: ${lastRelease.version} nextRelease: ${nextRelease.version} branch: master commits: 1 releases: 1 PR attribute: PR prop`, - }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + body: `last release: ${lastRelease.version} nextRelease: ${nextRelease.version} branch: master commits: 1 releases: 1 PR attribute: PR prop`, + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["released on @next", "released from master"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2026,7 +1963,7 @@ test("Add custom comment and labels", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2045,7 +1982,7 @@ test("Add custom comment and labels", async (t) => { 1, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Add custom label", async (t) => { @@ -2063,18 +2000,16 @@ test("Add custom label", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2092,25 +2027,21 @@ test("Add custom label", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/labels`, {}, { body: ["custom label"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2135,7 +2066,7 @@ test("Add custom label", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2150,7 +2081,7 @@ test("Add custom label", async (t) => { t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["custom label"], 1), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Comment on issue/PR without ading a label", async (t) => { @@ -2168,18 +2099,16 @@ test("Comment on issue/PR without ading a label", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2197,20 +2126,16 @@ test("Comment on issue/PR without ading a label", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2235,7 +2160,7 @@ test("Comment on issue/PR without ading a label", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2247,7 +2172,7 @@ test("Comment on issue/PR without ading a label", async (t) => { "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release to include all release links at the bottom", async (t) => { @@ -2280,18 +2205,16 @@ test("Editing the release to include all release links at the bottom", async (t) { name: "Docker: docker.io/python:slim" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2309,20 +2232,16 @@ test("Editing the release to include all release links at the bottom", async (t) }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2331,7 +2250,7 @@ test("Editing the release to include all release links at the bottom", async (t) }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -2358,7 +2277,7 @@ test("Editing the release to include all release links at the bottom", async (t) { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2370,7 +2289,7 @@ test("Editing the release to include all release links at the bottom", async (t) "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release to include all release links at the top", async (t) => { @@ -2403,18 +2322,16 @@ test("Editing the release to include all release links at the top", async (t) => { name: "Docker: docker.io/python:slim" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2432,20 +2349,16 @@ test("Editing the release to include all release links at the top", async (t) => }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2454,7 +2367,7 @@ test("Editing the release to include all release links at the top", async (t) => }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`, { html_url: releaseUrl, @@ -2481,7 +2394,7 @@ test("Editing the release to include all release links at the top", async (t) => { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2493,7 +2406,7 @@ test("Editing the release to include all release links at the top", async (t) => "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release to include all release links with no additional releases (top)", async (t) => { @@ -2523,18 +2436,16 @@ test("Editing the release to include all release links with no additional releas }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2552,20 +2463,16 @@ test("Editing the release to include all release links with no additional releas }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2590,7 +2497,7 @@ test("Editing the release to include all release links with no additional releas { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2602,7 +2509,7 @@ test("Editing the release to include all release links with no additional releas "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release to include all release links with no additional releases (bottom)", async (t) => { @@ -2632,18 +2539,16 @@ test("Editing the release to include all release links with no additional releas }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2661,20 +2566,16 @@ test("Editing the release to include all release links with no additional releas }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2699,7 +2600,7 @@ test("Editing the release to include all release links with no additional releas { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2711,7 +2612,7 @@ test("Editing the release to include all release links with no additional releas "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release to include all release links with no releases", async (t) => { @@ -2734,18 +2635,16 @@ test("Editing the release to include all release links with no releases", async const commits = [{ hash: "123", message: "Commit 1 message" }]; const releases = []; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2763,20 +2662,16 @@ test("Editing the release to include all release links with no releases", async }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2801,7 +2696,7 @@ test("Editing the release to include all release links with no releases", async { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2813,7 +2708,7 @@ test("Editing the release to include all release links with no releases", async "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Editing the release with no ID in the release", async (t) => { @@ -2838,18 +2733,16 @@ test("Editing the release with no ID in the release", async (t) => { { name: "Docker: docker.io/python:slim" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2867,20 +2760,16 @@ test("Editing the release with no ID in the release", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, - { html_url: "https://github.com/successcomment-1" }, - ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, { + html_url: "https://github.com/successcomment-1", + }) + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2905,7 +2794,7 @@ test("Editing the release with no ID in the release", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -2917,7 +2806,7 @@ test("Editing the release with no ID in the release", async (t) => { "https://github.com/successcomment-1", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Ignore errors when adding comments and closing issues", async (t) => { @@ -2947,18 +2836,16 @@ test("Ignore errors when adding comments and closing issues", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -2986,33 +2873,28 @@ test("Ignore errors when adding comments and closing issues", async (t) => { }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: commits[1].hash }], - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/1/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: commits[1].hash }, + ]) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/1/comments`, 400, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, - { html_url: "https://github.com/successcomment-2" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, { + html_url: "https://github.com/successcomment-2", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/2/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -3021,16 +2903,12 @@ test("Ignore errors when adding comments and closing issues", async (t) => { }, }, ) - .patchOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/2`, - 500, - { - body: { - state: "closed", - }, + .patch(`https://api.github.local/repos/${owner}/${repo}/issues/2`, 500, { + body: { + state: "closed", }, - ) - .patchOnce( + }) + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/3`, { html_url: "https://github.com/issues/3" }, { @@ -3057,7 +2935,7 @@ test("Ignore errors when adding comments and closing issues", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -3086,7 +2964,7 @@ test("Ignore errors when adding comments and closing issues", async (t) => { "https://github.com/issues/3", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Close open issues when a release is successful", async (t) => { @@ -3107,18 +2985,16 @@ test("Close open issues when a release is successful", async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getAssociatedPRs\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -3136,12 +3012,10 @@ test("Close open issues when a release is successful", async (t) => { }, }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -3150,7 +3024,7 @@ test("Close open issues when a release is successful", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/2`, { html_url: "https://github.com/issues/2" }, { @@ -3159,7 +3033,7 @@ test("Close open issues when a release is successful", async (t) => { }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/3`, { html_url: "https://github.com/issues/3" }, { @@ -3183,7 +3057,7 @@ test("Close open issues when a release is successful", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -3202,7 +3076,7 @@ test("Close open issues when a release is successful", async (t) => { "https://github.com/issues/3", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Skip comment on on issues/PR if "successComment" is "false"', async (t) => { @@ -3226,18 +3100,16 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) => { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -3261,7 +3133,7 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) => { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -3269,7 +3141,7 @@ test('Skip comment on on issues/PR if "successComment" is "false"', async (t) => t.true( t.context.log.calledWith("Skip commenting on issues and pull requests."), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Does not comment/label on issues/PR if "successCommentCondition" is "false"', async (t) => { @@ -3293,18 +3165,24 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - issues: { nodes: [] }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + issues: { nodes: [] }, + }, }, }, - }); + { repeat: 1 }, + ); await success( pluginConfig, @@ -3320,7 +3198,7 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -3328,7 +3206,7 @@ test('Does not comment/label on issues/PR if "successCommentCondition" is "false t.true( t.context.log.calledWith("Skip commenting on issues and pull requests."), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Add comment and label to found issues/associatedPR using the "successCommentCondition": if specific label is found', async (t) => { @@ -3464,15 +3342,15 @@ test('Add comment and label to found issues/associatedPR using the "successComme }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -3500,18 +3378,16 @@ test('Add comment and label to found issues/associatedPR using the "successComme }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/4/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/5/commits`, - [{ sha: commits[1].hash }], - ) - .postOnce( - (url, { body }) => + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/4/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/5/commits`, [ + { sha: commits[1].hash }, + ]) + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getSRIssues("), + JSON.parse(options.body).query.includes("query getSRIssues("), { data: { repository: { @@ -3520,16 +3396,15 @@ test('Add comment and label to found issues/associatedPR using the "successComme }, }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, - { html_url: "https://github.com/successcomment-5" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/5/comments`, { + html_url: "https://github.com/successcomment-5", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/5/labels`, {}, { body: ["released"] }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/2`, { html_url: "https://github.com/issues/2" }, { @@ -3538,7 +3413,7 @@ test('Add comment and label to found issues/associatedPR using the "successComme }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/3`, { html_url: "https://github.com/issues/3" }, { @@ -3562,7 +3437,7 @@ test('Add comment and label to found issues/associatedPR using the "successComme { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -3577,7 +3452,7 @@ test('Add comment and label to found issues/associatedPR using the "successComme t.true( t.context.log.calledWith("Added labels %O to PR #%d", ["released"], 5), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Does not comment/label associatedPR and relatedIssues created by "Bots"', async (t) => { @@ -3705,15 +3580,15 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -3741,10 +3616,10 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -3826,38 +3701,32 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, - [{ sha: commits[1].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, - { html_url: "https://github.com/successcomment-4" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, [ + { sha: commits[1].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, { + html_url: "https://github.com/successcomment-4", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released"] }, ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, - { html_url: "https://github.com/successcomment-2" }, - ) - .postOnce( + .post(`https://api.github.local/repos/${owner}/${repo}/issues/2/comments`, { + html_url: "https://github.com/successcomment-2", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/2/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => { - t.is(url, "https://api.github.local/graphql"); - t.regex(JSON.parse(body).query, /query getSRIssues\(/); - return true; - }, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getSRIssues\(/.test(JSON.parse(options.body).query), { data: { repository: { @@ -3866,7 +3735,7 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/1`, { html_url: "https://github.com/issues/1" }, { @@ -3890,7 +3759,7 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -3913,7 +3782,7 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', t.true( t.context.log.calledWith("Added labels %O to issue #%d", ["released"], 4), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Does not comment/label "associatedPR" when "successCommentCondition" disables it: Only comment on "relatedIssues"', async (t) => { @@ -3951,15 +3820,15 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab { number: 3, __typename: "PullRequest", state: "closed" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, }) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getAssociatedPRs("), + JSON.parse(options.body).query.includes("query getAssociatedPRs("), { data: { repository: { @@ -3987,10 +3856,10 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab }, }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getRelatedIssues("), + JSON.parse(options.body).query.includes("query getRelatedIssues("), { data: { repository: { @@ -4035,27 +3904,24 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab }, }, ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, - [{ sha: commits[0].hash }], - ) - .getOnce( - `https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, - [{ sha: commits[1].hash }], - ) - .postOnce( - `https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, - { html_url: "https://github.com/successcomment-4" }, - ) - .postOnce( + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/2/commits`, [ + { sha: commits[0].hash }, + ]) + .get(`https://api.github.local/repos/${owner}/${repo}/pulls/3/commits`, [ + { sha: commits[1].hash }, + ]) + .post(`https://api.github.local/repos/${owner}/${repo}/issues/4/comments`, { + html_url: "https://github.com/successcomment-4", + }) + .post( `https://api.github.local/repos/${owner}/${repo}/issues/4/labels`, {}, { body: ["released"] }, ) - .postOnce( - (url, { body }) => + .post( + ({ url, options }) => url === "https://api.github.local/graphql" && - JSON.parse(body).query.includes("query getSRIssues("), + JSON.parse(options.body).query.includes("query getSRIssues("), { data: { repository: { @@ -4064,7 +3930,7 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab }, }, ) - .patchOnce( + .patch( `https://api.github.local/repos/${owner}/${repo}/issues/1`, { html_url: "https://github.com/issues/1" }, { @@ -4088,7 +3954,7 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -4110,7 +3976,7 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab t.true( t.context.log.calledWith("Added labels %O to issue #%d", ["released"], 4), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Skip closing issues if "failComment" is "false"', async (t) => { @@ -4125,28 +3991,34 @@ test('Skip closing issues if "failComment" is "false"', async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - commit123: { - oid: "123", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + commit123: { + oid: "123", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, }, }, }, - }); + { repeat: 1 }, + ); await success( pluginConfig, @@ -4162,7 +4034,7 @@ test('Skip closing issues if "failComment" is "false"', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -4172,7 +4044,7 @@ test('Skip closing issues if "failComment" is "false"', async (t) => { "DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Skip closing issues if "failTitle" is "false"', async (t) => { @@ -4187,28 +4059,34 @@ test('Skip closing issues if "failTitle" is "false"', async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - commit123: { - oid: "123", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + commit123: { + oid: "123", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, }, }, }, - }); + { repeat: 1 }, + ); await success( pluginConfig, @@ -4224,7 +4102,7 @@ test('Skip closing issues if "failTitle" is "false"', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); @@ -4234,7 +4112,7 @@ test('Skip closing issues if "failTitle" is "false"', async (t) => { "DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.", ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Skip closing issues if "failCommentCondition" is "false"', async (t) => { @@ -4249,28 +4127,34 @@ test('Skip closing issues if "failCommentCondition" is "false"', async (t) => { { name: "GitHub release", url: "https://github.com/release" }, ]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { full_name: `${owner}/${repo}`, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .postOnce("https://api.github.local/graphql", { - data: { - repository: { - commit123: { - oid: "123", - associatedPullRequests: { - pageInfo: { - endCursor: "NI", - hasNextPage: false, + .post( + ({ url, options }) => + url === "https://api.github.local/graphql" && + /query getAssociatedPRs\(/.test(JSON.parse(options.body).query), + { + data: { + repository: { + commit123: { + oid: "123", + associatedPullRequests: { + pageInfo: { + endCursor: "NI", + hasNextPage: false, + }, + nodes: [], }, - nodes: [], }, }, }, }, - }); + { repeat: 1 }, + ); await success( pluginConfig, @@ -4286,10 +4170,10 @@ test('Skip closing issues if "failCommentCondition" is "false"', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ); t.true(t.context.log.calledWith("Skip closing issue.")); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); diff --git a/test/verify.test.js b/test/verify.test.js index d5154c36..bc6c7934 100644 --- a/test/verify.test.js +++ b/test/verify.test.js @@ -32,9 +32,9 @@ test("Verify package, token and repository access", async (t) => { const labels = ["semantic-release"]; const discussionCategoryName = "Announcements"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -62,12 +62,12 @@ test("Verify package, token and repository access", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify package, token and repository access with "proxy", "asset", "discussionCategoryName", "successComment", "failTitle", "failComment" and "label" set to "null"', async (t) => { @@ -82,9 +82,9 @@ test('Verify package, token and repository access with "proxy", "asset", "discus const labels = null; const discussionCategoryName = null; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -112,12 +112,12 @@ test('Verify package, token and repository access with "proxy", "asset", "discus { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify package, token and repository access and custom URL with prefix", async (t) => { @@ -127,9 +127,9 @@ test("Verify package, token and repository access and custom URL with prefix", a const githubUrl = "https://othertesturl.com:9090"; const githubApiPathPrefix = "prefix"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://othertesturl.com:9090/prefix/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://othertesturl.com:9090/prefix/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -149,13 +149,13 @@ test("Verify package, token and repository access and custom URL with prefix", a { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.deepEqual(t.context.log.args[0], [ "Verify GitHub authentication (%s)", "https://othertesturl.com:9090/prefix", @@ -168,9 +168,9 @@ test("Verify package, token and repository access and custom URL without prefix" const env = { GH_TOKEN: "github_token" }; const githubUrl = "https://othertesturl.com:9090"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://othertesturl.com:9090/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://othertesturl.com:9090/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -190,13 +190,13 @@ test("Verify package, token and repository access and custom URL without prefix" { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.deepEqual(t.context.log.args[0], [ "Verify GitHub authentication (%s)", "https://othertesturl.com:9090", @@ -209,9 +209,9 @@ test("Verify package, token and repository access and shorthand repositoryUrl UR const env = { GH_TOKEN: "github_token" }; const githubUrl = "https://othertesturl.com:9090"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://othertesturl.com:9090/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://othertesturl.com:9090/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -229,13 +229,13 @@ test("Verify package, token and repository access and shorthand repositoryUrl UR { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.deepEqual(t.context.log.args[0], [ "Verify GitHub authentication (%s)", "https://othertesturl.com:9090", @@ -251,9 +251,9 @@ test("Verify package, token and repository with environment variables", async (t GH_PREFIX: "prefix", HTTP_PROXY: "https://localhost", }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -273,13 +273,13 @@ test("Verify package, token and repository with environment variables", async (t { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.deepEqual(t.context.log.args[0], [ "Verify GitHub authentication (%s)", "https://othertesturl.com:443/prefix", @@ -295,9 +295,9 @@ test("Verify package, token and repository access with alternative environment v GITHUB_PREFIX: "prefix", }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -317,12 +317,12 @@ test("Verify package, token and repository access with alternative environment v { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify package, token and repository access with custom API URL", async (t) => { @@ -332,9 +332,9 @@ test("Verify package, token and repository access with custom API URL", async (t const githubUrl = "https://othertesturl.com:9090"; const githubApiUrl = "https://api.othertesturl.com:9090"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.othertesturl.com:9090/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.othertesturl.com:9090/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -352,13 +352,13 @@ test("Verify package, token and repository access with custom API URL", async (t { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); t.deepEqual(t.context.log.args[0], [ "Verify GitHub authentication (%s)", "https://api.othertesturl.com:9090", @@ -374,9 +374,9 @@ test("Verify package, token and repository access with API URL in environment va GITHUB_TOKEN: "github_token", }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.othertesturl.com:443/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.othertesturl.com:443/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -396,12 +396,12 @@ test("Verify package, token and repository access with API URL in environment va { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "proxy" is a String', async (t) => { @@ -410,9 +410,9 @@ test('Verify "proxy" is a String', async (t) => { const env = { GH_TOKEN: "github_token" }; const proxy = "https://locahost"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -430,13 +430,13 @@ test('Verify "proxy" is a String', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "proxy" is an object with "host" and "port" properties', async (t) => { @@ -445,9 +445,9 @@ test('Verify "proxy" is an object with "host" and "port" properties', async (t) const env = { GH_TOKEN: "github_token" }; const proxy = { host: "locahost", port: 80 }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -467,13 +467,13 @@ test('Verify "proxy" is an object with "host" and "port" properties', async (t) { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "proxy" is a Boolean set to false', async (t) => { @@ -482,9 +482,9 @@ test('Verify "proxy" is a Boolean set to false', async (t) => { const env = { GH_TOKEN: "github_token" }; const proxy = false; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -502,13 +502,13 @@ test('Verify "proxy" is a Boolean set to false', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assets" is a String', async (t) => { @@ -517,9 +517,9 @@ test('Verify "assets" is a String', async (t) => { const env = { GH_TOKEN: "github_token" }; const assets = "file2.js"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -537,13 +537,13 @@ test('Verify "assets" is a String', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assets" is an Object with a path property', async (t) => { @@ -552,9 +552,9 @@ test('Verify "assets" is an Object with a path property', async (t) => { const env = { GH_TOKEN: "github_token" }; const assets = { path: "file2.js" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -572,13 +572,13 @@ test('Verify "assets" is an Object with a path property', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assets" is an Array of Object with a path property', async (t) => { @@ -587,9 +587,9 @@ test('Verify "assets" is an Array of Object with a path property', async (t) => const env = { GH_TOKEN: "github_token" }; const assets = [{ path: "file1.js" }, { path: "file2.js" }]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -609,13 +609,13 @@ test('Verify "assets" is an Array of Object with a path property', async (t) => { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assets" is an Array of glob Arrays', async (t) => { @@ -624,9 +624,9 @@ test('Verify "assets" is an Array of glob Arrays', async (t) => { const env = { GH_TOKEN: "github_token" }; const assets = [["dist/**", "!**/*.js"], "file2.js"]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -644,13 +644,13 @@ test('Verify "assets" is an Array of glob Arrays', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assets" is an Array of Object with a glob Arrays in path property', async (t) => { @@ -659,9 +659,9 @@ test('Verify "assets" is an Array of Object with a glob Arrays in path property' const env = { GH_TOKEN: "github_token" }; const assets = [{ path: ["dist/**", "!**/*.js"] }, { path: "file2.js" }]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -681,13 +681,13 @@ test('Verify "assets" is an Array of Object with a glob Arrays in path property' { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "labels" is a String', async (t) => { @@ -696,9 +696,9 @@ test('Verify "labels" is a String', async (t) => { const env = { GH_TOKEN: "github_token" }; const labels = "semantic-release"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -716,13 +716,13 @@ test('Verify "labels" is a String', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "assignees" is a String', async (t) => { @@ -731,9 +731,9 @@ test('Verify "assignees" is a String', async (t) => { const env = { GH_TOKEN: "github_token" }; const assignees = "user"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -751,13 +751,13 @@ test('Verify "assignees" is a String', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "addReleases" is a valid string (top)', async (t) => { @@ -766,9 +766,9 @@ test('Verify "addReleases" is a valid string (top)', async (t) => { const env = { GH_TOKEN: "github_token" }; const addReleases = "top"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -786,13 +786,13 @@ test('Verify "addReleases" is a valid string (top)', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "addReleases" is a valid string (bottom)', async (t) => { @@ -801,9 +801,9 @@ test('Verify "addReleases" is a valid string (bottom)', async (t) => { const env = { GH_TOKEN: "github_token" }; const addReleases = "bottom"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -821,13 +821,13 @@ test('Verify "addReleases" is a valid string (bottom)', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "addReleases" is valid (false)', async (t) => { @@ -836,9 +836,9 @@ test('Verify "addReleases" is valid (false)', async (t) => { const env = { GH_TOKEN: "github_token" }; const addReleases = false; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -856,13 +856,13 @@ test('Verify "addReleases" is valid (false)', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "draftRelease" is valid (true)', async (t) => { @@ -871,9 +871,9 @@ test('Verify "draftRelease" is valid (true)', async (t) => { const env = { GH_TOKEN: "github_token" }; const draftRelease = true; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -891,13 +891,13 @@ test('Verify "draftRelease" is valid (true)', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Verify "draftRelease" is valid (false)', async (t) => { @@ -906,9 +906,9 @@ test('Verify "draftRelease" is valid (false)', async (t) => { const env = { GH_TOKEN: "github_token" }; const draftRelease = false; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -926,13 +926,13 @@ test('Verify "draftRelease" is valid (false)', async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); // https://github.com/semantic-release/github/issues/182 @@ -951,9 +951,9 @@ test("Verify if run in GitHub Action", async (t) => { const labels = ["semantic-release"]; const discussionCategoryName = "Announcements"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { clone_url: `https://api.github.local/${owner}/${repo}.git`, }); @@ -970,13 +970,13 @@ test("Verify if run in GitHub Action", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); // https://github.com/semantic-release/github/issues/182 @@ -995,9 +995,9 @@ test("Verify if run in GitHub Action and repo is renamed", async (t) => { const labels = ["semantic-release"]; const discussionCategoryName = "Announcements"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { clone_url: `https://api.github.local/${owner}/${repo}2.git`, }); @@ -1016,7 +1016,7 @@ test("Verify if run in GitHub Action and repo is renamed", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1025,7 +1025,7 @@ test("Verify if run in GitHub Action and repo is renamed", async (t) => { t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EMISMATCHGITHUBURL"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Verify if token is a Github installation token and repo is renamed", async (t) => { @@ -1033,18 +1033,15 @@ test("Verify if token is a Github installation token and repo is renamed", async const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: false, }, clone_url: `https://api.github.local/${owner}/${repo}2.git`, }) - .headOnce( - "https://api.github.local/installation/repositories?per_page=1", - 200, - ); + .head("https://api.github.local/installation/repositories?per_page=1", 200); const { errors: [error, ...errors], @@ -1059,7 +1056,7 @@ test("Verify if token is a Github installation token and repo is renamed", async { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1068,7 +1065,7 @@ test("Verify if token is a Github installation token and repo is renamed", async t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EMISMATCHGITHUBURL"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw SemanticReleaseError for missing github token", async (t) => { @@ -1087,7 +1084,7 @@ test("Throw SemanticReleaseError for missing github token", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1103,9 +1100,9 @@ test("Throw SemanticReleaseError for invalid token", async (t) => { const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, 401); + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, 401); const { errors: [error, ...errors], @@ -1120,7 +1117,7 @@ test("Throw SemanticReleaseError for invalid token", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1129,7 +1126,7 @@ test("Throw SemanticReleaseError for invalid token", async (t) => { t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDGHTOKEN"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw SemanticReleaseError for invalid repositoryUrl", async (t) => { @@ -1148,7 +1145,7 @@ test("Throw SemanticReleaseError for invalid repositoryUrl", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1164,18 +1161,15 @@ test("Throw SemanticReleaseError if token doesn't have the push permission on th const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: false, }, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .headOnce( - "https://api.github.local/installation/repositories?per_page=1", - 403, - ); + .head("https://api.github.local/installation/repositories?per_page=1", 403); const { errors: [error, ...errors], @@ -1190,7 +1184,7 @@ test("Throw SemanticReleaseError if token doesn't have the push permission on th { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1199,7 +1193,7 @@ test("Throw SemanticReleaseError if token doesn't have the push permission on th t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EGHNOPERMISSION"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Do not throw SemanticReleaseError if token doesn't have the push permission but it is a Github installation token", async (t) => { @@ -1207,18 +1201,15 @@ test("Do not throw SemanticReleaseError if token doesn't have the push permissio const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: false, }, clone_url: `https://api.github.local/${owner}/${repo}.git`, }) - .headOnce( - "https://api.github.local/installation/repositories?per_page=1", - 200, - ); + .head("https://api.github.local/installation/repositories?per_page=1", 200); await t.notThrowsAsync( verify( @@ -1231,13 +1222,13 @@ test("Do not throw SemanticReleaseError if token doesn't have the push permissio { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test("Throw SemanticReleaseError if the repository doesn't exist", async (t) => { @@ -1245,9 +1236,9 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) => const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, 404); + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, 404); const { errors: [error, ...errors], @@ -1262,7 +1253,7 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) => { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1271,19 +1262,19 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) => t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EMISSINGREPO"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test(`Don't throw an error if owner/repo only differs in case`, async (t) => { const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock.sandbox().getOnce( + const fm = fetchMock.createInstance().get( `https://api.github.local/repos/org/foo`, { permissions: { push: true }, clone_url: `https://github.com/ORG/FOO.git`, }, - { repeat: 2 }, + { repeat: 1 }, ); await t.notThrowsAsync( @@ -1299,13 +1290,13 @@ test(`Don't throw an error if owner/repo only differs in case`, async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); const urlFormats = [ @@ -1324,13 +1315,13 @@ for (const makeRepositoryUrl of urlFormats) { test(`Don't throw an error if clone_url differs from repositoryUrl but owner/repo is the same -- ${makeRepositoryUrl(owner, repo)} / ${make_clone_url(owner, repo)}`, async (t) => { const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock.sandbox().getOnce( + const fm = fetchMock.createInstance().get( `https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true }, clone_url: make_clone_url(owner, repo), }, - { repeat: 2 }, + { repeat: 1 }, ); await t.notThrowsAsync( @@ -1346,26 +1337,26 @@ for (const makeRepositoryUrl of urlFormats) { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); const repo2 = repo + "2"; test(`Throw SemanticReleaseError if the repository is renamed -- ${makeRepositoryUrl(owner, repo)} / ${make_clone_url(owner, repo2)}`, async (t) => { const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock.sandbox().getOnce( + const fm = fetchMock.createInstance().get( `https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true }, clone_url: make_clone_url(owner, repo2), }, - { repeat: 2 }, + { repeat: 1 }, ); const { @@ -1381,7 +1372,7 @@ for (const makeRepositoryUrl of urlFormats) { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1390,7 +1381,7 @@ for (const makeRepositoryUrl of urlFormats) { t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EMISMATCHGITHUBURL"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); } } @@ -1400,9 +1391,9 @@ test("Throw error if github return any other errors", async (t) => { const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, 500); + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, 500); const error = await t.throwsAsync( verify( @@ -1415,14 +1406,14 @@ test("Throw error if github return any other errors", async (t) => { { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), ); t.is(error.status, 500); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "proxy" option is not a String or an Object', async (t) => { @@ -1444,7 +1435,7 @@ test('Throw SemanticReleaseError if "proxy" option is not a String or an Object' { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1474,7 +1465,7 @@ test('Throw SemanticReleaseError if "proxy" option is an Object with invalid pro { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1491,9 +1482,9 @@ test('Throw SemanticReleaseError if "assets" option is not a String or an Array const env = { GH_TOKEN: "github_token" }; const assets = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1513,7 +1504,7 @@ test('Throw SemanticReleaseError if "assets" option is not a String or an Array { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1522,7 +1513,7 @@ test('Throw SemanticReleaseError if "assets" option is not a String or an Array t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSETS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assets" option is an Array with invalid elements', async (t) => { @@ -1531,9 +1522,9 @@ test('Throw SemanticReleaseError if "assets" option is an Array with invalid ele const env = { GH_TOKEN: "github_token" }; const assets = ["file.js", 42]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1553,7 +1544,7 @@ test('Throw SemanticReleaseError if "assets" option is an Array with invalid ele { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1562,7 +1553,7 @@ test('Throw SemanticReleaseError if "assets" option is an Array with invalid ele t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSETS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assets" option is an Object missing the "path" property', async (t) => { @@ -1571,9 +1562,9 @@ test('Throw SemanticReleaseError if "assets" option is an Object missing the "pa const env = { GH_TOKEN: "github_token" }; const assets = { name: "file.js" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1593,7 +1584,7 @@ test('Throw SemanticReleaseError if "assets" option is an Object missing the "pa { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1602,7 +1593,7 @@ test('Throw SemanticReleaseError if "assets" option is an Object missing the "pa t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSETS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assets" option is an Array with objects missing the "path" property', async (t) => { @@ -1611,9 +1602,9 @@ test('Throw SemanticReleaseError if "assets" option is an Array with objects mis const env = { GH_TOKEN: "github_token" }; const assets = [{ path: "lib/file.js" }, { name: "file.js" }]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1633,7 +1624,7 @@ test('Throw SemanticReleaseError if "assets" option is an Array with objects mis { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1642,7 +1633,7 @@ test('Throw SemanticReleaseError if "assets" option is an Array with objects mis t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSETS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "successComment" option is not a String', async (t) => { @@ -1651,9 +1642,9 @@ test('Throw SemanticReleaseError if "successComment" option is not a String', as const env = { GH_TOKEN: "github_token" }; const successComment = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1673,7 +1664,7 @@ test('Throw SemanticReleaseError if "successComment" option is not a String', as { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1682,7 +1673,7 @@ test('Throw SemanticReleaseError if "successComment" option is not a String', as t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDSUCCESSCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "successComment" option is an empty String', async (t) => { @@ -1691,9 +1682,9 @@ test('Throw SemanticReleaseError if "successComment" option is an empty String', const env = { GH_TOKEN: "github_token" }; const successComment = ""; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1713,7 +1704,7 @@ test('Throw SemanticReleaseError if "successComment" option is an empty String', { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1722,7 +1713,7 @@ test('Throw SemanticReleaseError if "successComment" option is an empty String', t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDSUCCESSCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "successComment" option is a whitespace String', async (t) => { @@ -1731,9 +1722,9 @@ test('Throw SemanticReleaseError if "successComment" option is a whitespace Stri const env = { GH_TOKEN: "github_token" }; const successComment = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1753,7 +1744,7 @@ test('Throw SemanticReleaseError if "successComment" option is a whitespace Stri { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1762,7 +1753,7 @@ test('Throw SemanticReleaseError if "successComment" option is a whitespace Stri t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDSUCCESSCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failTitle" option is not a String', async (t) => { @@ -1771,9 +1762,9 @@ test('Throw SemanticReleaseError if "failTitle" option is not a String', async ( const env = { GH_TOKEN: "github_token" }; const failTitle = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1793,7 +1784,7 @@ test('Throw SemanticReleaseError if "failTitle" option is not a String', async ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1802,7 +1793,7 @@ test('Throw SemanticReleaseError if "failTitle" option is not a String', async ( t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILTITLE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failTitle" option is an empty String', async (t) => { @@ -1811,9 +1802,9 @@ test('Throw SemanticReleaseError if "failTitle" option is an empty String', asyn const env = { GH_TOKEN: "github_token" }; const failTitle = ""; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1833,7 +1824,7 @@ test('Throw SemanticReleaseError if "failTitle" option is an empty String', asyn { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1842,7 +1833,7 @@ test('Throw SemanticReleaseError if "failTitle" option is an empty String', asyn t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILTITLE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failTitle" option is a whitespace String', async (t) => { @@ -1851,9 +1842,9 @@ test('Throw SemanticReleaseError if "failTitle" option is a whitespace String', const env = { GH_TOKEN: "github_token" }; const failTitle = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1873,7 +1864,7 @@ test('Throw SemanticReleaseError if "failTitle" option is a whitespace String', { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1882,7 +1873,7 @@ test('Throw SemanticReleaseError if "failTitle" option is a whitespace String', t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILTITLE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "discussionCategoryName" option is not a String', async (t) => { @@ -1891,9 +1882,9 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is not a Str const env = { GH_TOKEN: "github_token" }; const discussionCategoryName = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1913,7 +1904,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is not a Str { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1922,7 +1913,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is not a Str t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDDISCUSSIONCATEGORYNAME"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "discussionCategoryName" option is an empty String', async (t) => { @@ -1931,9 +1922,9 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is an empty const env = { GH_TOKEN: "github_token" }; const discussionCategoryName = ""; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1953,7 +1944,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is an empty { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -1962,7 +1953,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is an empty t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDDISCUSSIONCATEGORYNAME"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "discussionCategoryName" option is a whitespace String', async (t) => { @@ -1971,9 +1962,9 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is a whitesp const env = { GH_TOKEN: "github_token" }; const discussionCategoryName = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -1993,7 +1984,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is a whitesp { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2002,7 +1993,7 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is a whitesp t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDDISCUSSIONCATEGORYNAME"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failComment" option is not a String', async (t) => { @@ -2011,9 +2002,9 @@ test('Throw SemanticReleaseError if "failComment" option is not a String', async const env = { GH_TOKEN: "github_token" }; const failComment = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2033,7 +2024,7 @@ test('Throw SemanticReleaseError if "failComment" option is not a String', async { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2042,7 +2033,7 @@ test('Throw SemanticReleaseError if "failComment" option is not a String', async t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failComment" option is an empty String', async (t) => { @@ -2051,9 +2042,9 @@ test('Throw SemanticReleaseError if "failComment" option is an empty String', as const env = { GH_TOKEN: "github_token" }; const failComment = ""; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2073,7 +2064,7 @@ test('Throw SemanticReleaseError if "failComment" option is an empty String', as { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2082,7 +2073,7 @@ test('Throw SemanticReleaseError if "failComment" option is an empty String', as t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "failComment" option is a whitespace String', async (t) => { @@ -2091,9 +2082,9 @@ test('Throw SemanticReleaseError if "failComment" option is a whitespace String' const env = { GH_TOKEN: "github_token" }; const failComment = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2113,7 +2104,7 @@ test('Throw SemanticReleaseError if "failComment" option is a whitespace String' { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2122,7 +2113,7 @@ test('Throw SemanticReleaseError if "failComment" option is a whitespace String' t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDFAILCOMMENT"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "labels" option is not a String or an Array of String', async (t) => { @@ -2131,9 +2122,9 @@ test('Throw SemanticReleaseError if "labels" option is not a String or an Array const env = { GH_TOKEN: "github_token" }; const labels = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2153,7 +2144,7 @@ test('Throw SemanticReleaseError if "labels" option is not a String or an Array { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2162,7 +2153,7 @@ test('Throw SemanticReleaseError if "labels" option is not a String or an Array t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "labels" option is an Array with invalid elements', async (t) => { @@ -2171,9 +2162,9 @@ test('Throw SemanticReleaseError if "labels" option is an Array with invalid ele const env = { GH_TOKEN: "github_token" }; const labels = ["label1", 42]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2193,7 +2184,7 @@ test('Throw SemanticReleaseError if "labels" option is an Array with invalid ele { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2202,7 +2193,7 @@ test('Throw SemanticReleaseError if "labels" option is an Array with invalid ele t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "labels" option is a whitespace String', async (t) => { @@ -2211,9 +2202,9 @@ test('Throw SemanticReleaseError if "labels" option is a whitespace String', asy const env = { GH_TOKEN: "github_token" }; const labels = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2233,7 +2224,7 @@ test('Throw SemanticReleaseError if "labels" option is a whitespace String', asy { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2242,7 +2233,7 @@ test('Throw SemanticReleaseError if "labels" option is a whitespace String', asy t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assignees" option is not a String or an Array of String', async (t) => { @@ -2251,9 +2242,9 @@ test('Throw SemanticReleaseError if "assignees" option is not a String or an Arr const env = { GH_TOKEN: "github_token" }; const assignees = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2273,7 +2264,7 @@ test('Throw SemanticReleaseError if "assignees" option is not a String or an Arr { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2282,7 +2273,7 @@ test('Throw SemanticReleaseError if "assignees" option is not a String or an Arr t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSIGNEES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assignees" option is an Array with invalid elements', async (t) => { @@ -2291,9 +2282,9 @@ test('Throw SemanticReleaseError if "assignees" option is an Array with invalid const env = { GH_TOKEN: "github_token" }; const assignees = ["user", 42]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2313,7 +2304,7 @@ test('Throw SemanticReleaseError if "assignees" option is an Array with invalid { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2322,7 +2313,7 @@ test('Throw SemanticReleaseError if "assignees" option is an Array with invalid t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSIGNEES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "assignees" option is a whitespace String', async (t) => { @@ -2331,9 +2322,9 @@ test('Throw SemanticReleaseError if "assignees" option is a whitespace String', const env = { GH_TOKEN: "github_token" }; const assignees = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2353,7 +2344,7 @@ test('Throw SemanticReleaseError if "assignees" option is a whitespace String', { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2362,7 +2353,7 @@ test('Throw SemanticReleaseError if "assignees" option is a whitespace String', t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDASSIGNEES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "releasedLabels" option is not a String or an Array of String', async (t) => { @@ -2371,9 +2362,9 @@ test('Throw SemanticReleaseError if "releasedLabels" option is not a String or a const env = { GH_TOKEN: "github_token" }; const releasedLabels = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2393,7 +2384,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is not a String or a { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2402,7 +2393,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is not a String or a t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDRELEASEDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "releasedLabels" option is an Array with invalid elements', async (t) => { @@ -2411,9 +2402,9 @@ test('Throw SemanticReleaseError if "releasedLabels" option is an Array with inv const env = { GH_TOKEN: "github_token" }; const releasedLabels = ["label1", 42]; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2433,7 +2424,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is an Array with inv { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2442,7 +2433,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is an Array with inv t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDRELEASEDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "releasedLabels" option is a whitespace String', async (t) => { @@ -2451,9 +2442,9 @@ test('Throw SemanticReleaseError if "releasedLabels" option is a whitespace Stri const env = { GH_TOKEN: "github_token" }; const releasedLabels = " \n \r "; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2473,7 +2464,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is a whitespace Stri { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2482,7 +2473,7 @@ test('Throw SemanticReleaseError if "releasedLabels" option is a whitespace Stri t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDRELEASEDLABELS"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "addReleases" option is not a valid string (botom)', async (t) => { @@ -2491,9 +2482,9 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( const env = { GH_TOKEN: "github_token" }; const addReleases = "botom"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2513,7 +2504,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2522,7 +2513,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDADDRELEASES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "addReleases" option is not a valid string (true)', async (t) => { @@ -2531,9 +2522,9 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( const env = { GH_TOKEN: "github_token" }; const addReleases = true; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2553,7 +2544,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2562,7 +2553,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDADDRELEASES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "addReleases" option is not a valid string (number)', async (t) => { @@ -2571,9 +2562,9 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( const env = { GH_TOKEN: "github_token" }; const addReleases = 42; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2593,7 +2584,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2602,7 +2593,7 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string ( t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDADDRELEASES"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "draftRelease" option is not a valid boolean (string)', async (t) => { @@ -2611,9 +2602,9 @@ test('Throw SemanticReleaseError if "draftRelease" option is not a valid boolean const env = { GH_TOKEN: "github_token" }; const draftRelease = "test"; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2633,7 +2624,7 @@ test('Throw SemanticReleaseError if "draftRelease" option is not a valid boolean { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2642,7 +2633,7 @@ test('Throw SemanticReleaseError if "draftRelease" option is not a valid boolean t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDDRAFTRELEASE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "releaseBodyTemplate" option is an empty string', async (t) => { @@ -2650,9 +2641,9 @@ test('Throw SemanticReleaseError if "releaseBodyTemplate" option is an empty str const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2672,7 +2663,7 @@ test('Throw SemanticReleaseError if "releaseBodyTemplate" option is an empty str { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2681,7 +2672,7 @@ test('Throw SemanticReleaseError if "releaseBodyTemplate" option is an empty str t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDRELEASEBODYTEMPLATE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); }); test('Throw SemanticReleaseError if "releaseNameTemplate" option is an empty string', async (t) => { @@ -2689,9 +2680,9 @@ test('Throw SemanticReleaseError if "releaseNameTemplate" option is an empty str const repo = "test_repo"; const env = { GH_TOKEN: "github_token" }; - const fetch = fetchMock - .sandbox() - .getOnce(`https://api.github.local/repos/${owner}/${repo}`, { + const fm = fetchMock + .createInstance() + .get(`https://api.github.local/repos/${owner}/${repo}`, { permissions: { push: true, }, @@ -2711,7 +2702,7 @@ test('Throw SemanticReleaseError if "releaseNameTemplate" option is an empty str { Octokit: TestOctokit.defaults((options) => ({ ...options, - request: { ...options.request, fetch }, + request: { ...options.request, fetch: fm.fetchHandler }, })), }, ), @@ -2720,5 +2711,5 @@ test('Throw SemanticReleaseError if "releaseNameTemplate" option is an empty str t.is(errors.length, 0); t.is(error.name, "SemanticReleaseError"); t.is(error.code, "EINVALIDRELEASENAMETEMPLATE"); - t.true(fetch.done()); + t.true(fm.callHistory.done()); });