From b7ad9974f4f6c63f83ad31ac92ddbb6590afbe63 Mon Sep 17 00:00:00 2001 From: Carlos Espa Date: Sun, 11 May 2025 18:38:31 +0200 Subject: [PATCH] feat(jest-to-node-test): add initial implementation --- package-lock.json | 1354 ++++++++++++++++- recipes/jest-to-node-test/.codemodrc.json | 13 + recipes/jest-to-node-test/README.md | 20 + recipes/jest-to-node-test/package.json | 43 + .../src/fixtures/e2e/test.ts | 125 ++ .../src/workflow.test.snap.cjs | 3 + .../jest-to-node-test/src/workflow.test.ts | 537 +++++++ recipes/jest-to-node-test/src/workflow.ts | 503 ++++++ recipes/jest-to-node-test/tsconfig.json | 27 + 9 files changed, 2622 insertions(+), 3 deletions(-) create mode 100644 recipes/jest-to-node-test/.codemodrc.json create mode 100644 recipes/jest-to-node-test/README.md create mode 100644 recipes/jest-to-node-test/package.json create mode 100644 recipes/jest-to-node-test/src/fixtures/e2e/test.ts create mode 100644 recipes/jest-to-node-test/src/workflow.test.snap.cjs create mode 100644 recipes/jest-to-node-test/src/workflow.test.ts create mode 100644 recipes/jest-to-node-test/src/workflow.ts create mode 100644 recipes/jest-to-node-test/tsconfig.json diff --git a/package-lock.json b/package-lock.json index 021c8532..9e289265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -505,9 +505,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", - "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz", + "integrity": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -598,6 +598,61 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-flow": { "version": "7.26.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.26.0.tgz", @@ -613,6 +668,48 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.27.1.tgz", + "integrity": "sha512-oFT0FrKHgF53f4vOsZGi2Hh3I35PfSmVs4IBFLFj4dnafP+hIWDLg3VyKmUHfLoLHlyxY4C7DGtmHuJgn+IGww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-jsx": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", @@ -628,6 +725,116 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-typescript": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", @@ -1155,6 +1362,239 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/@jest/transform/node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "license": "ISC", + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", @@ -1399,6 +1839,13 @@ "node": ">=14" } }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, "node_modules/@sindresorhus/slugify": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.2.1.tgz", @@ -1430,6 +1877,63 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "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", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, "node_modules/@types/jscodeshift": { "version": "0.11.11", "resolved": "https://registry.npmjs.org/@types/jscodeshift/-/jscodeshift-0.11.11.tgz", @@ -1476,6 +1980,30 @@ "form-data": "^4.0.0" } }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true, + "license": "MIT" + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -1551,6 +2079,30 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/ast-types": { "version": "0.14.2", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.14.2.tgz", @@ -1578,6 +2130,50 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", + "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-import-attributes": "^7.24.7", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1679,6 +2275,16 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "node-int64": "^0.4.0" + } + }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", @@ -1709,6 +2315,16 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "license": "MIT" }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001687", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz", @@ -1760,6 +2376,22 @@ "node": "*" } }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", @@ -1982,6 +2614,16 @@ "node": ">=0.3.1" } }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/digest-fetch": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz", @@ -2053,6 +2695,23 @@ "node": ">=6" } }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -2067,6 +2726,23 @@ "node": ">=4" } }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bser": "2.1.1" + } + }, "node_modules/filename-reserved-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-3.0.0.tgz", @@ -2205,6 +2881,21 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "license": "ISC" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -2214,6 +2905,16 @@ "node": ">=6.9.0" } }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/git-up": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", @@ -2448,6 +3149,33 @@ "node": ">=0.10.0" } }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jackspeak": { "version": "3.4.3", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", @@ -2463,12 +3191,239 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-to-node-test-runner": { + "resolved": "recipes/jest-to-node-test-runner", + "link": true + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "license": "MIT" }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/jscodeshift": { "version": "0.15.2", "resolved": "https://registry.npmjs.org/jscodeshift/-/jscodeshift-0.15.2.tgz", @@ -2644,6 +3599,16 @@ "semver": "bin/semver" } }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tmpl": "1.0.5" + } + }, "node_modules/md5": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", @@ -2655,6 +3620,13 @@ "is-buffer": "~1.1.6" } }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -2737,6 +3709,13 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -2816,12 +3795,29 @@ } } }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true, + "license": "MIT" + }, "node_modules/node-releases": { "version": "2.0.18", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", "license": "MIT" }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -3085,12 +4081,47 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/protocols": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==", "license": "MIT" }, + "node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true, + "license": "MIT" + }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -3120,6 +4151,16 @@ "node": ">= 4" } }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -3308,6 +4349,16 @@ "url": "https://github.com/steveukx/git-js?sponsor=1" } }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -3327,6 +4378,36 @@ "source-map": "^0.6.0" } }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/stack-utils/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -3414,6 +4495,67 @@ "node": ">=6.0.0" } }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/tiny-invariant": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", @@ -3432,6 +4574,13 @@ "node": ">=0.6.0" } }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true, + "license": "BSD-3-Clause" + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -3477,6 +4626,16 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/type-fest": { "version": "4.41.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", @@ -3552,6 +4711,16 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "license": "MIT" }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "makeerror": "1.0.12" + } + }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", @@ -3702,6 +4871,185 @@ "engines": { "node": ">=22.15.0" } + }, + "recipes/jest-to-node-test-runner": { + "version": "1.0.0-rc.1", + "license": "MIT", + "dependencies": { + "@ast-grep/napi": "^0.38.1" + }, + "devDependencies": { + "@jest/globals": "^29.7.0", + "@types/node": "^22.15.5", + "expect": "^29.7.0" + }, + "engines": { + "node": ">=22.6.0" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi/-/napi-0.38.1.tgz", + "integrity": "sha512-7OxLNxyugFYRMNksdyQXo806BDHA+SClHmGD7H5IJXeiRS4ICEV5NAYiLxr1NAOOKVwwFk0yFQj0YZ2BkH8joA==", + "license": "MIT", + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@ast-grep/napi-darwin-arm64": "0.38.1", + "@ast-grep/napi-darwin-x64": "0.38.1", + "@ast-grep/napi-linux-arm64-gnu": "0.38.1", + "@ast-grep/napi-linux-arm64-musl": "0.38.1", + "@ast-grep/napi-linux-x64-gnu": "0.38.1", + "@ast-grep/napi-linux-x64-musl": "0.38.1", + "@ast-grep/napi-win32-arm64-msvc": "0.38.1", + "@ast-grep/napi-win32-ia32-msvc": "0.38.1", + "@ast-grep/napi-win32-x64-msvc": "0.38.1" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-darwin-arm64": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-darwin-arm64/-/napi-darwin-arm64-0.38.1.tgz", + "integrity": "sha512-1YG5PgqfcDleO/5AFsbEDjkOYGLyth2oWpAUhz/JE7mzPdax586O/oBcISPDP2jV7QUGIV5TJ8J8Feft/No1gg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-darwin-x64": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-darwin-x64/-/napi-darwin-x64-0.38.1.tgz", + "integrity": "sha512-2ubMVa8BZaqmwsPTDpScIWTorQfXug8XIBI+1TsbUgpVQFTQREZ5U0s7M3uOJ/bQqxx+14easGX4Z/IyH6heuA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-linux-arm64-gnu": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-linux-arm64-gnu/-/napi-linux-arm64-gnu-0.38.1.tgz", + "integrity": "sha512-fUr02gEA4mweG7xfHch66/LlAyyOwiGHczUlfST9g84vThMGY/YEqjgiMwuUlynglvYzW/Cr9Wd1zEapvnW6zA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-linux-arm64-musl": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-linux-arm64-musl/-/napi-linux-arm64-musl-0.38.1.tgz", + "integrity": "sha512-Cm0BbMcHPqg2IrUL2Rn1WdLcFzi8L2iqm62+hKs6334ht7OgFezt3YhoLgzP75bstNNlGT9NJuSk1m6/Fxa0HA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-linux-x64-gnu": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-linux-x64-gnu/-/napi-linux-x64-gnu-0.38.1.tgz", + "integrity": "sha512-EThfZGW8OekPIS1rHJj6MpU9d14YZQazp24bb7QWcyyfo4lbe9etexLuF7ujbGF/rMovhi2TRbF/Tn0HvuJBpg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-linux-x64-musl": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-linux-x64-musl/-/napi-linux-x64-musl-0.38.1.tgz", + "integrity": "sha512-PnI1RRP9yn+yyGUjxCXzgiUktEDH/gUyfV3tEFZEjqWzTZFUd7TdkC7hB6HlIHFrJ2ykXWUBMwXRR3k/2XDaMw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-win32-arm64-msvc": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-win32-arm64-msvc/-/napi-win32-arm64-msvc-0.38.1.tgz", + "integrity": "sha512-Q6xEk2KTjZIYuDi3sIgHYF87i6uhly6g5kJC7G2loW1Io9GApHKqpLBuDdTSApwzwbwQgfyeLDPdHvwu5P1y5A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-win32-ia32-msvc": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-win32-ia32-msvc/-/napi-win32-ia32-msvc-0.38.1.tgz", + "integrity": "sha512-k2GnuAv30+XATjgEUZNb2gtWU7g7H4CvsSwaZLgvlpsKfMTIXf9julksh8M5WkU5F4WIx40wEUQeDALoKO/Ltw==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "recipes/jest-to-node-test-runner/node_modules/@ast-grep/napi-win32-x64-msvc": { + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@ast-grep/napi-win32-x64-msvc/-/napi-win32-x64-msvc-0.38.1.tgz", + "integrity": "sha512-bbV/GNY4QCEahpo5MvRXkUg7m1wDamfQzaS2f0ncUr7ZW2ML6RC0qR7yQy3eLCvpdZl3cXUBnGydEsMe3hTnvw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } } } diff --git a/recipes/jest-to-node-test/.codemodrc.json b/recipes/jest-to-node-test/.codemodrc.json new file mode 100644 index 00000000..59ee207e --- /dev/null +++ b/recipes/jest-to-node-test/.codemodrc.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://codemod-utils.s3.us-west-1.amazonaws.com/configuration_schema.json", + "name": "jest-to-node-test-runner", + "description": "Convert Jest tests to Node Test Runner tests", + "version": "1.0.0", + "engine": "ast-grep", + "private": false, + "arguments": [], + "meta": { + "git": "https://github.com/nodejs/userland-migrations/tree/main/recipe/jest-to-node-test-runner", + "tags": ["jest", "import", "node", "typescript"] + } +} diff --git a/recipes/jest-to-node-test/README.md b/recipes/jest-to-node-test/README.md new file mode 100644 index 00000000..f6e2dd10 --- /dev/null +++ b/recipes/jest-to-node-test/README.md @@ -0,0 +1,20 @@ +# Jest to Node Test + +This package transforms Jest test files into `node:test` files. + +This is a one-and-done process, and the updated source-code should be committed to your version control (eg git); thereafter, source-code import statements should be authored compliant with the ECMAScript (JavaScript) standard. + +## TODO: + +- Remove `jest`, `@types/jest`, `@jest/globals` and related modules from `package.json` +- Check/install `expect` +- Update `package.json` scripts that use `jest` +- remove `jest` config files +- remove `jest` config from `package.json` and `tsconfig.json` +- Migrate snapshots ✅ +- Convert mocks ✅ +- Convert setup/teardown files +- Migrate assertions +- Migrate test/it config (e.g. timeout) +- Migrate suite methods (e.g. `it.each`) +- Check non-TS CJS/ESM support diff --git a/recipes/jest-to-node-test/package.json b/recipes/jest-to-node-test/package.json new file mode 100644 index 00000000..ebfa467d --- /dev/null +++ b/recipes/jest-to-node-test/package.json @@ -0,0 +1,43 @@ +{ + "name": "jest-to-node-test", + "version": "1.0.0-rc.1", + "description": "Convert Jest tests to node:test tests", + "type": "module", + "main": "./src/workflow.ts", + "engines": { + "node": ">=22.6.0" + }, + "scripts": { + "start": "node --no-warnings --experimental-import-meta-resolve --experimental-strip-types ./src/workflow.ts", + "test": "node --no-warnings --experimental-import-meta-resolve --experimental-test-module-mocks --experimental-test-snapshots --experimental-strip-types --import='../../test/snapshots.ts' --test --experimental-test-coverage --test-coverage-include='src/**/*' --test-coverage-exclude='**/*.test.ts' './**/*.test.ts'" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/nodejs/userland-migrations.git", + "directory": "recipes/jest-to-node-test-runner" + }, + "files": [ + "README.md", + ".codemodrc.json", + "bundle.js" + ], + "keywords": [ + "codemod", + "esm", + "typescript" + ], + "author": "Carlos Espa", + "license": "MIT", + "bugs": { + "url": "https://github.com/nodejs/userland-migrations/issues" + }, + "homepage": "https://github.com/nodejs/userland-migrations/tree/main/jest-to-node-test-runner#readme", + "devDependencies": { + "@jest/globals": "^29.7.0", + "@types/node": "^22.15.5", + "expect": "^29.7.0" + }, + "dependencies": { + "@ast-grep/napi": "^0.38.1" + } +} diff --git a/recipes/jest-to-node-test/src/fixtures/e2e/test.ts b/recipes/jest-to-node-test/src/fixtures/e2e/test.ts new file mode 100644 index 00000000..610121da --- /dev/null +++ b/recipes/jest-to-node-test/src/fixtures/e2e/test.ts @@ -0,0 +1,125 @@ +import { describe, it, expect, jest } from "@jest/globals"; + +describe("test", () => { + it("should be a test", () => { + const a = jest.fn((i: number, j: number) => i + j); + const b = jest.fn(async (i: number, j: number) => i - j); + jest.mock("./workflow.ts"); + + const logSpy = jest.spyOn(console, "log"); + console.log("Hello, world!"); + + expect(logSpy.mock.calls[0][0]).toBe("Hello, world!"); + + a(1, 1); + a(2, 2); + + expect(a).toHaveBeenCalled(); + expect(a).toBeCalled(); + + expect(a).toHaveBeenCalledTimes(2); + expect(a).toBeCalledTimes(2); + + expect(a).toHaveBeenCalledWith(1, 1); + expect(a).toBeCalledWith(1, 1); + + expect(a).toHaveBeenLastCalledWith(2, 2); + expect(a).lastCalledWith(2, 2); + + expect(a).toHaveBeenNthCalledWith(1, 1, 1); + expect(a).nthCalledWith(2, 2, 2); + + expect(a).toHaveReturned(); + expect(a).toReturn(); + + expect(a).toHaveReturnedTimes(2); + expect(a).toReturnTimes(2); + + expect(a).toHaveReturnedWith(2); + expect(a).toReturnWith(4); + + expect(a).toHaveLastReturnedWith(4); + expect(a).lastReturnedWith(4); + + expect(a).toHaveNthReturnedWith(1, 2); + expect(a).nthReturnedWith(2, 4); + + a.mock.calls; + + a.mock.results; + + // a.mock.instances; + + // a.mock.contexts; + + a.mock.lastCall; + + a.mockClear(); + + a.mockReset(); + + a.mockRestore(); + + a.mockImplementation((i: number, j: number) => i * j); + + a.mockImplementationOnce((i: number, j: number) => i - j); + + // a.mockName("myMock"); + + // a.mockReturnThis(); + + a.mockReturnValue(42); + + a.mockReturnValueOnce(42); + + b.mockRejectedValue(new Error("Test error")); + + b.mockRejectedValueOnce(new Error("Test error once")); + + b.mockResolvedValue(42); + + b.mockResolvedValueOnce(42); + + expect({ a: 1 }).toMatchSnapshot(); + + expect({ b: 2 }).toMatchInlineSnapshot(` +{ + "b": 2, +} +`); + + jest.useFakeTimers(); + + jest.useRealTimers(); + + jest.runAllTicks(); + + jest.runAllTimers(); + + jest.runAllTimersAsync(); + + jest.runAllImmediates(); + + jest.advanceTimersByTime(1000); + + jest.advanceTimersByTimeAsync(1000); + + jest.runOnlyPendingTimers(); + + jest.runOnlyPendingTimersAsync(); + + // jest.advanceTimersToNextTimer(5); + + // jest.advanceTimersToNextTimerAsync(5); + + jest.clearAllTimers(); + + // jest.getTimerCount(); + + jest.now(); + + jest.setSystemTime(1000); + + // jest.getRealSystemTime(); + }); +}); diff --git a/recipes/jest-to-node-test/src/workflow.test.snap.cjs b/recipes/jest-to-node-test/src/workflow.test.snap.cjs new file mode 100644 index 00000000..ebab1280 --- /dev/null +++ b/recipes/jest-to-node-test/src/workflow.test.snap.cjs @@ -0,0 +1,3 @@ +exports[`workflow > should migrate jest to node:test 1`] = ` +"import { describe, it, mock } from \\"node:test\\";\\nimport { expect } from \\"expect\\";\\n\\ndescribe(\\"test\\", () => {\\n\\tit(\\"should be a test\\", (t) => {\\n\\t\\tconst a = mock.fn((i: number, j: number) => i + j);\\n\\t\\tconst b = mock.fn(async (i: number, j: number) => i - j);\\n\\t\\tmock.module(\\"./workflow.ts\\");\\n\\n\\t\\tconst logSpy = mock.method(console,\\"log\\");\\n\\t\\tconsole.log(\\"Hello, world!\\");\\n\\n\\t\\texpect(logSpy.mock.calls.map((call) => call.arguments)[0][0]).toBe(\\"Hello, world!\\");\\n\\n\\t\\ta(1, 1);\\n\\t\\ta(2, 2);\\n\\n\\t\\texpect(a.mock.callCount()).toBeTruthy();\\n\\t\\texpect(a.mock.callCount()).toBeTruthy();\\n\\n\\t\\texpect(a.mock.callCount()).toBe(2);\\n\\t\\texpect(a.mock.callCount()).toBe(2);\\n\\n\\t\\texpect(a.mock.calls.map(call => call.arguments)).toContainEqual([1,1]);\\n\\t\\texpect(a.mock.calls.map(call => call.arguments)).toContainEqual([1,1]);\\n\\n\\t\\texpect(a.mock.calls.at(-1)?.arguments).toStrictEqual([2,2]);\\n\\t\\texpect(a.mock.calls.at(-1)?.arguments).toStrictEqual([2,2]);\\n\\n\\t\\texpect(a.mock.calls[0].arguments).toStrictEqual([1,1]);\\n\\t\\texpect(a.mock.calls[1].arguments).toStrictEqual([2,2]);\\n\\n\\t\\texpect(a.mock.calls.some(call => call.error === undefined)).toBeTruthy();\\n\\t\\texpect(a.mock.calls.some(call => call.error === undefined)).toBeTruthy();\\n\\n\\t\\texpect(a.mock.calls.filter(call => call.error === undefined)).toHaveLength(2);\\n\\t\\texpect(a.mock.calls.filter(call => call.error === undefined)).toHaveLength(2);\\n\\n\\t\\texpect(a.mock.calls.map(call => call.result)).toContainEqual(2);\\n\\t\\texpect(a.mock.calls.map(call => call.result)).toContainEqual(4);\\n\\n\\t\\texpect(a.mock.calls.at(-1)?.result).toBe(4);\\n\\t\\texpect(a.mock.calls.at(-1)?.result).toBe(4);\\n\\n\\t\\texpect(a.mock.calls[0].result).toBe(2);\\n\\t\\texpect(a.mock.calls[1].result).toBe(4);\\n\\n\\t\\ta.mock.calls.map((call) => call.arguments);\\n\\n\\t\\ta.mock.calls.map((call) => ({\\n\\ttype: call.error ? \\"throw\\" : \\"return\\",\\n\\tvalue: call.error ? call.error : call.result,\\n}));\\n\\n\\t\\t// a.mock.instances;\\n\\n\\t\\t// a.mock.contexts;\\n\\n\\t\\ta.mock.calls.at(-1)?.arguments;\\n\\n\\t\\ta.mock.resetCalls();\\n\\n\\t\\ta.mock.restore();\\n\\n\\t\\ta.mock.restore();\\n\\n\\t\\ta.mock.mockImplementation((i: number, j: number) => i * j);\\n\\n\\t\\ta.mock.mockImplementationOnce((i: number, j: number) => i - j);\\n\\n\\t\\t// a.mockName(\\"myMock\\");\\n\\n\\t\\t// a.mockReturnThis();\\n\\n\\t\\ta.mock.mockImplementation(() => 42);\\n\\n\\t\\ta.mock.mockImplementationOnce(() => 42);\\n\\n\\t\\tb.mock.mockImplementation(async () => {\\n\\tthrow new Error(\\"Test error\\");\\n});\\n\\n\\t\\tb.mock.mockImplementationOnce(async () => {\\n\\tthrow new Error(\\"Test error once\\");\\n});\\n\\n\\t\\tb.mock.mockImplementation(async () => 42);\\n\\n\\t\\tb.mock.mockImplementationOnce(async () => 42);\\n\\n\\t\\tt.assert.snapshot({ a: 1 });\\n\\n\\t\\tt.assert.snapshot({ b: 2 });\\n\\n\\t\\tmock.timers.enable();\\n\\n\\t\\tmock.timers.reset();\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\tmock.timers.tick(1000);\\n\\n\\t\\tmock.timers.tick(1000);\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\tmock.timers.runAll();\\n\\n\\t\\t// jest.advanceTimersToNextTimer(5);\\n\\n\\t\\t// jest.advanceTimersToNextTimerAsync(5);\\n\\n\\t\\tmock.timers.reset();\\n\\n\\t\\tjest.getTimerCount();\\n\\n\\t\\tDate.now();\\n\\n\\t\\tmock.timers.setTime(Number(1000));\\n\\n\\t\\t// jest.getRealSystemTime();\\n\\t});\\n});\\n" +`; diff --git a/recipes/jest-to-node-test/src/workflow.test.ts b/recipes/jest-to-node-test/src/workflow.test.ts new file mode 100644 index 00000000..a8ffb443 --- /dev/null +++ b/recipes/jest-to-node-test/src/workflow.test.ts @@ -0,0 +1,537 @@ +import { readFile } from "node:fs/promises"; +import { resolve } from "node:path"; +import { describe, it } from "node:test"; +import { fileURLToPath } from "node:url"; + +import { workflow } from "./workflow.ts"; + +describe("workflow", () => { + it("should migrate jest to node:test", async (t) => { + const e2eFixtPath = fileURLToPath(import.meta.resolve("./fixtures/e2e/")); + const source = await readFile(resolve(e2eFixtPath, "test.ts"), { encoding: "utf-8" }); + const result = await workflow(source); + + t.assert.snapshot(result); + }); + + it("should migrate jest.fn with no arguments", async (t) => { + const source = "const mockFn = jest.fn();"; + const result = await workflow(source); + t.assert.match(result, /const mockFn = mock\.fn\(\);/); + }); + + it("should migrate jest.fn with argument", async (t) => { + const source = "const a = jest.fn((i: number, j: number) => i + j);"; + const result = await workflow(source); + t.assert.match(result, /const a = mock\.fn\(\(i: number, j: number\) => i \+ j\);/); + }); + + it("should migrate jest.mock", async (t) => { + const source = 'jest.mock("./workflow.ts");'; + const result = await workflow(source); + t.assert.match(result, /mock\.module\("\.\/workflow\.ts"\);/); + }); + + it("should migrate jest.spyOn", async (t) => { + const source = 'const logSpy = jest.spyOn(console, "log");'; + const result = await workflow(source); + t.assert.match(result, /const logSpy = mock\.method\(console,"log"\);/); + }); + + it("should migrate toHaveBeenCalled", async (t) => { + const source = "expect(a).toHaveBeenCalled();"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.callCount\(\)\).toBeTruthy\(\);/); + }); + + it("should migrate toBeCalled", async (t) => { + const source = "expect(a).toBeCalled();"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.callCount\(\)\).toBeTruthy\(\);/); + }); + + it("should migrate toHaveBeenCalledTimes", async (t) => { + const source = "expect(a).toHaveBeenCalledTimes(2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.callCount\(\)\).toBe\(2\);/); + }); + + it("should migrate toBeCalledTimes", async (t) => { + const source = "expect(a).toBeCalledTimes(2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.callCount\(\)\).toBe\(2\);/); + }); + + it("should migrate toHaveBeenCalledWith", async (t) => { + const source = "expect(a).toHaveBeenCalledWith(1, 1);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.map\(call => call.arguments\)\).toContainEqual\(\[1,1\]\);/, + ); + }); + + it("should migrate toBeCalledWith", async (t) => { + const source = "expect(a).toBeCalledWith(1, 1);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.map\(call => call.arguments\)\).toContainEqual\(\[1,1\]\);/, + ); + }); + + it("should migrate toHaveBeenLastCalledWith", async (t) => { + const source = "expect(a).toHaveBeenLastCalledWith(2, 2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls.at\(-1\)\?.arguments\).toStrictEqual\(\[2,2\]\);/); + }); + + it("should migrate lastCalledWith", async (t) => { + const source = "expect(a).lastCalledWith(2, 2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls.at\(-1\)\?.arguments\).toStrictEqual\(\[2,2\]\);/); + }); + + it("should migrate toHaveBeenNthCalledWith", async (t) => { + const source = "expect(a).toHaveBeenNthCalledWith(1, 1, 1);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls\[0\].arguments\).toStrictEqual\(\[1,1\]\);/); + }); + + it("should migrate nthCalledWith", async (t) => { + const source = "expect(a).nthCalledWith(2, 2, 2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls\[1\].arguments\).toStrictEqual\(\[2,2\]\);/); + }); + + it("should migrate toHaveReturned", async (t) => { + const source = "expect(a).toHaveReturned();"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.some\(call => call.error === undefined\)\).toBeTruthy\(\);/, + ); + }); + + it("should migrate toReturn", async (t) => { + const source = "expect(a).toReturn();"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.some\(call => call.error === undefined\)\).toBeTruthy\(\);/, + ); + }); + + it("should migrate toHaveReturnedTimes", async (t) => { + const source = "expect(a).toHaveReturnedTimes(2);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.filter\(call => call.error === undefined\)\).toHaveLength\(2\);/, + ); + }); + + it("should migrate toReturnTimes", async (t) => { + const source = "expect(a).toReturnTimes(2);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.filter\(call => call.error === undefined\)\).toHaveLength\(2\);/, + ); + }); + + it("should migrate toHaveReturnedWith", async (t) => { + const source = "expect(a).toHaveReturnedWith(2);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.map\(call => call.result\)\).toContainEqual\(2\);/, + ); + }); + + it("should migrate toReturnWith", async (t) => { + const source = "expect(a).toReturnWith(4);"; + const result = await workflow(source); + t.assert.match( + result, + /expect\(a.mock.calls.map\(call => call.result\)\).toContainEqual\(4\);/, + ); + }); + + it("should migrate toHaveLastReturnedWith", async (t) => { + const source = "expect(a).toHaveLastReturnedWith(4);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls.at\(-1\)\?.result\).toBe\(4\);/); + }); + + it("should migrate lastReturnedWith", async (t) => { + const source = "expect(a).lastReturnedWith(4);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls.at\(-1\)\?.result\).toBe\(4\);/); + }); + + it("should migrate toHaveNthReturnedWith", async (t) => { + const source = "expect(a).toHaveNthReturnedWith(1, 2);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls\[0\].result\).toBe\(2\);/); + }); + + it("should migrate nthReturnedWith", async (t) => { + const source = "expect(a).nthReturnedWith(2, 4);"; + const result = await workflow(source); + t.assert.match(result, /expect\(a.mock.calls\[1\].result\).toBe\(4\);/); + }); + + it("should migrate mock.calls", async (t) => { + const source = "a.mock.calls"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.calls\.map\(\(call\) => call\.arguments\)/); + }); + + it("should migrate mock.results", async (t) => { + const source = "a.mock.results"; + const result = await workflow(source); + t.assert.match( + result, + /a\.mock\.calls\.map\(\(call\) => \(\{\s*type: call\.error \? "throw" : "return",\s*value: call\.error \? call\.error : call\.result,\s*\}\)\)/, + ); + }); + + it("should migrate mock.lastCall", async (t) => { + const source = "a.mock.lastCall"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.calls\.at\(-1\)\?\.arguments/); + }); + + it("should migrate mockClear", async (t) => { + const source = "a.mockClear()"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.resetCalls\(\)/); + }); + + it("should migrate mockReset", async (t) => { + const source = "a.mockReset()"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.restore\(\)/); + }); + + it("should migrate mockRestore", async (t) => { + const source = "a.mockRestore()"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.restore\(\)/); + }); + + it("should migrate mockImplementation", async (t) => { + const source = "a.mockImplementation((i: number, j: number) => i * j)"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.mockImplementation\(\(i: number, j: number\) => i \* j\)/); + }); + + it("should migrate mockImplementationOnce", async (t) => { + const source = "a.mockImplementationOnce((i: number, j: number) => i - j)"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.mockImplementationOnce\(\(i: number, j: number\) => i - j\)/); + }); + + it("should migrate mockReturnValue", async (t) => { + const source = "a.mockReturnValue(42)"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.mockImplementation\(\(\) => 42\)/); + }); + + it("should migrate mockReturnValueOnce", async (t) => { + const source = "a.mockReturnValueOnce(42)"; + const result = await workflow(source); + t.assert.match(result, /a\.mock\.mockImplementationOnce\(\(\) => 42\)/); + }); + + it("should migrate mockRejectedValue", async (t) => { + const source = 'b.mockRejectedValue(new Error("Test error"))'; + const result = await workflow(source); + t.assert.match( + result, + /b\.mock\.mockImplementation\(async \(\) => \{\s*throw new Error\("Test error"\);\s*\}\)/, + ); + }); + + it("should migrate mockRejectedValueOnce", async (t) => { + const source = 'b.mockRejectedValueOnce(new Error("Test error once"))'; + const result = await workflow(source); + t.assert.match( + result, + /b\.mock\.mockImplementationOnce\(async \(\) => \{\s*throw new Error\("Test error once"\);\s*\}\)/, + ); + }); + + it("should migrate mockResolvedValue", async (t) => { + const source = "b.mockResolvedValue(42)"; + const result = await workflow(source); + t.assert.match(result, /b\.mock\.mockImplementation\(async \(\) => 42\)/); + }); + + it("should migrate mockResolvedValueOnce", async (t) => { + const source = "b.mockResolvedValueOnce(42)"; + const result = await workflow(source); + t.assert.match(result, /b\.mock\.mockImplementationOnce\(async \(\) => 42\)/); + }); + + it("should migrate toMatchSnapshot with no arguments", async (t) => { + const source = "expect({ a: 1 }).toMatchSnapshot();"; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\(\{ a: 1 \}\)/); + }); + + it("should migrate toMatchSnapshot with property matchers", async (t) => { + const source = + "expect(user).toMatchSnapshot({ id: expect.any(Number), createdAt: expect.any(Date) });"; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\(user\)/); + }); + + it("should migrate toMatchSnapshot with hint", async (t) => { + const source = 'expect(data).toMatchSnapshot("custom hint");'; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\(data\)/); + }); + + it("should migrate toMatchInlineSnapshot with just snapshot", async (t) => { + const source = `expect({ b: 2 }).toMatchInlineSnapshot(\` +{ +"b": 2, +} +\`);`; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\(\{ b: 2 \}\)/); + }); + + it("should migrate toMatchInlineSnapshot with property matchers and snapshot", async (t) => { + const source = `expect(user).toMatchInlineSnapshot({ id: expect.any(Number) }, \` +{ +"id": Any, +"name": "John" +} +\`);`; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\(user\)/); + }); + + it("should migrate toMatchInlineSnapshot with simple value", async (t) => { + const source = 'expect("hello").toMatchInlineSnapshot(\`"hello"\`);'; + const result = await workflow(source); + t.assert.match(result, /t\.assert\.snapshot\("hello"\)/); + }); + + it("should add t parameter to it with arrow function", async (t) => { + const source = `it(() => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\(\(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to it function with unnamed function", async (t) => { + const source = `it(function() { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\(function\(t\) \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to it function with named function", async (t) => { + const source = `it("test", function testFunc() { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\("test", function testFunc\(t\) \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to it function with options", async (t) => { + const source = `it({ timeout: 5000 }, () => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\(\{ timeout: 5000 \}, \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to it function with name and options", async (t) => { + const source = `it("test name", { timeout: 5000 }, () => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\("test name", \{ timeout: 5000 \}, \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to test function with name", async (t) => { + const source = `test("test name", () => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /test\("test name", \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should add t parameter to async function", async (t) => { + const source = `it("async test", async () => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + t.assert.match(result, /it\("async test", async \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should not modify test function if t parameter already exists", async (t) => { + const source = `it("test with t", (t) => { + expect(result).toMatchSnapshot(); + });`; + const result = await workflow(source); + // Should not become (t, t) + t.assert.match(result, /it\("test with t", \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should only modify direct parent test function for nested tests", async (t) => { + const source = `it("outer test", () => { + it("inner test", () => { + expect(result).toMatchSnapshot(); + }); + });`; + const result = await workflow(source); + // Only inner test should get t parameter + t.assert.match(result, /it\("outer test", \(\) => \{/); + t.assert.match(result, /it\("inner test", \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should handle multiple snapshots in same test function", async (t) => { + const source = `it("test with multiple snapshots", () => { + expect(result1).toMatchSnapshot(); + expect(result2).toMatchInlineSnapshot("inline"); + });`; + const result = await workflow(source); + // Should only add t parameter once + t.assert.match(result, /it\("test with multiple snapshots", \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result1\)/); + t.assert.match(result, /t\.assert\.snapshot\(result2\)/); + }); + + it("should not modify test functions without snapshots", async (t) => { + const source = `it("test without snapshots", () => { + expect(result).toBe(42); + });`; + const result = await workflow(source); + t.assert.match(result, /it\("test without snapshots", \(\) => \{/); + t.assert.match(result, /expect\(result\)\.toBe\(42\)/); + }); + + it("should handle deeply nested test functions", async (t) => { + const source = `describe("suite", () => { + it("outer", () => { + describe("inner suite", () => { + it("inner", () => { + expect(result).toMatchSnapshot(); + }); + }); + }); + });`; + const result = await workflow(source); + // Only the innermost test with snapshot should get t parameter + t.assert.match(result, /it\("outer", \(\) => \{/); + t.assert.match(result, /it\("inner", \(t\) => \{/); + t.assert.match(result, /t\.assert\.snapshot\(result\)/); + }); + + it("should migrate jest.useFakeTimers", async (t) => { + const source = "jest.useFakeTimers();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.enable\(\)/); + }); + + it("should migrate jest.useRealTimers", async (t) => { + const source = "jest.useRealTimers();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.reset\(\)/); + }); + + it("should migrate jest.runAllTicks", async (t) => { + const source = "jest.runAllTicks();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.runAllTimers", async (t) => { + const source = "jest.runAllTimers();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.runAllTimersAsync", async (t) => { + const source = "jest.runAllTimersAsync();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.runAllImmediates", async (t) => { + const source = "jest.runAllImmediates();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.advanceTimersByTime", async (t) => { + const source = "jest.advanceTimersByTime(1000);"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.tick\(1000\)/); + }); + + it("should migrate jest.advanceTimersByTimeAsync", async (t) => { + const source = "jest.advanceTimersByTimeAsync(1000);"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.tick\(1000\)/); + }); + + it("should migrate jest.runOnlyPendingTimers", async (t) => { + const source = "jest.runOnlyPendingTimers();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.runOnlyPendingTimersAsync", async (t) => { + const source = "jest.runOnlyPendingTimersAsync();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.runAll\(\)/); + }); + + it("should migrate jest.clearAllTimers", async (t) => { + const source = "jest.clearAllTimers();"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.reset\(\)/); + }); + + it("should migrate jest.now", async (t) => { + const source = "jest.now();"; + const result = await workflow(source); + t.assert.match(result, /Date\.now\(\)/); + }); + + it("should migrate jest.setSystemTime", async (t) => { + const source = "jest.setSystemTime(1000);"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.setTime\(Number\(1000\)\)/); + }); + + it("should migrate jest.setSystemTime with variable", async (t) => { + const source = "jest.setSystemTime(timestamp);"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.setTime\(Number\(timestamp\)\)/); + }); + + it("should migrate jest.advanceTimersByTime with variable", async (t) => { + const source = "jest.advanceTimersByTime(delay);"; + const result = await workflow(source); + t.assert.match(result, /mock\.timers\.tick\(delay\)/); + }); +}); diff --git a/recipes/jest-to-node-test/src/workflow.ts b/recipes/jest-to-node-test/src/workflow.ts new file mode 100644 index 00000000..994365d3 --- /dev/null +++ b/recipes/jest-to-node-test/src/workflow.ts @@ -0,0 +1,503 @@ +import { parse, Lang, type Edit, SgNode } from "@ast-grep/napi"; + +export async function workflow(source: string) { + const ast = parse(Lang.TypeScript, source); + const root = ast.root(); + + const imports = [ + "describe", + "it", + "test", + "beforeEach", + "afterEach", + "beforeAll", + "afterAll", + ].filter((name) => root.has(`${name}($$$_ARGS)`)); + const hasMocks = + root.has("jest.mock($$$_ARGS)") || + root.has("jest.spyOn($$$_ARGS)") || + root.has("jest.fn($$$_ARGS)"); + if (hasMocks) { + imports.push("mock"); + } + + let importStatement = `import { ${imports.join(", ").replaceAll("All", "")} } from "node:test";\n`; + + const edits: Edit[] = []; + const addImportsEdit: Edit = { startPos: 0, endPos: 0, insertedText: importStatement }; + edits.push(addImportsEdit); + + const deleteJestImportEdits = root + .findAll('import { $$$_NAME } from "@jest/globals"\n') + .map((node) => { + const edit = node.replace(""); + // FIXME: find another way to include newline + edit.endPos++; + return edit; + }); + + const expectPresent = root.has("expect($$$_ARGS)"); + if (expectPresent) { + addImportsEdit.insertedText += 'import { expect } from "expect";\n'; + } + + const moduleMockEdits = root.findAll("jest.mock($$$ARGS)").map((node) => + node.replace( + `mock.module(${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")})`, + ), + ); + + const fnMockEdits = root.findAll("jest.fn($$$ARGS)").map((node) => + node.replace( + `mock.fn(${node + .getMultipleMatches("ARGS") + .map((node) => node.text()) + .join("")})`, + ), + ); + + const jestSpyOnEdits = root.findAll("jest.spyOn($$$ARGS)").map((node) => + node.replace( + `mock.method(${node + .getMultipleMatches("ARGS") + .map((node) => node.text()) + .join("")})`, + ), + ); + + const toHaveBeenCalledEdits = root + .findAll("expect($ACTUAL).toHaveBeenCalled()") + .map((node) => + node.replace(`expect(${node.getMatch("ACTUAL")?.text()}.mock.callCount()).toBeTruthy()`), + ); + + const toBeCalledEdits = root + .findAll("expect($ACTUAL).toBeCalled()") + .map((node) => + node.replace(`expect(${node.getMatch("ACTUAL")?.text()}.mock.callCount()).toBeTruthy()`), + ); + + const toHaveBeenCalledTimesEdits = root + .findAll("expect($ACTUAL).toHaveBeenCalledTimes($TIMES)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.callCount()).toBe(${node.getMatch("TIMES")?.text()})`, + ), + ); + + const toBeCalledTimesEdits = root + .findAll("expect($ACTUAL).toBeCalledTimes($TIMES)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.callCount()).toBe(${node.getMatch("TIMES")?.text()})`, + ), + ); + + const toHaveBeenCalledWithEdits = root + .findAll("expect($ACTUAL).toHaveBeenCalledWith($$$ARGS)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.map(call => call.arguments)).toContainEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const toBeCalledWithEdits = root.findAll("expect($ACTUAL).toBeCalledWith($$$ARGS)").map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.map(call => call.arguments)).toContainEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const toHaveBeenLastCalledWithEdits = root + .findAll("expect($ACTUAL).toHaveBeenLastCalledWith($$$ARGS)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.at(-1)?.arguments).toStrictEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const lastCalledWithEdits = root.findAll("expect($ACTUAL).lastCalledWith($$$ARGS)").map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.at(-1)?.arguments).toStrictEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const toHaveBeenNthCalledWithEdits = root + .findAll("expect($ACTUAL).toHaveBeenNthCalledWith($INDEX, $$$ARGS)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls[${parseInt(node.getMatch("INDEX")?.text() || "0") - 1}].arguments).toStrictEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const nthCalledWithEdits = root + .findAll("expect($ACTUAL).nthCalledWith($INDEX, $$$ARGS)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls[${parseInt(node.getMatch("INDEX")?.text() || "0") - 1}].arguments).toStrictEqual([${node + .getMultipleMatches("ARGS") + .map((n) => n.text()) + .join("")}])`, + ), + ); + + const toHaveReturnedEdits = root + .findAll("expect($ACTUAL).toHaveReturned()") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.some(call => call.error === undefined)).toBeTruthy()`, + ), + ); + + const toReturnEdits = root + .findAll("expect($ACTUAL).toReturn()") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.some(call => call.error === undefined)).toBeTruthy()`, + ), + ); + + const toHaveReturnedTimesEdits = root + .findAll("expect($ACTUAL).toHaveReturnedTimes($TIMES)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.filter(call => call.error === undefined)).toHaveLength(${node.getMatch("TIMES")?.text()})`, + ), + ); + + const toReturnTimesEdits = root + .findAll("expect($ACTUAL).toReturnTimes($TIMES)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.filter(call => call.error === undefined)).toHaveLength(${node.getMatch("TIMES")?.text()})`, + ), + ); + + const toHaveReturnedWithEdits = root + .findAll("expect($ACTUAL).toHaveReturnedWith($VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.map(call => call.result)).toContainEqual(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const toReturnWithEdits = root + .findAll("expect($ACTUAL).toReturnWith($VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.map(call => call.result)).toContainEqual(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const toHaveLastReturnedWithEdits = root + .findAll("expect($ACTUAL).toHaveLastReturnedWith($VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.at(-1)?.result).toBe(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const lastReturnedWithEdits = root + .findAll("expect($ACTUAL).lastReturnedWith($VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls.at(-1)?.result).toBe(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const toHaveNthReturnedWithEdits = root + .findAll("expect($ACTUAL).toHaveNthReturnedWith($INDEX, $VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls[${parseInt(node.getMatch("INDEX")?.text() || "0") - 1}].result).toBe(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const nthReturnedWithEdits = root + .findAll("expect($ACTUAL).nthReturnedWith($INDEX, $VALUE)") + .map((node) => + node.replace( + `expect(${node.getMatch("ACTUAL")?.text()}.mock.calls[${parseInt(node.getMatch("INDEX")?.text() || "0") - 1}].result).toBe(${node.getMatch("VALUE")?.text()})`, + ), + ); + + const mockCallsEdits = root + .findAll("$MOCK.mock.calls") + .map((node) => + node.replace(`${node.getMatch("MOCK")?.text()}.mock.calls.map((call) => call.arguments)`), + ); + + // TODO: Consider other possible translations + const mockResultsEdits = root.findAll("$MOCK.mock.results").map((node) => + node.replace(`${node.getMatch("MOCK")?.text()}.mock.calls.map((call) => ({ + type: call.error ? "throw" : "return", + value: call.error ? call.error : call.result, +}))`), + ); + + // TODO: Consider if instances are translatable + + // TODO: Consider if contexts are translatable + + // TODO: Consider case where it wasn't called and result is undefined + const mockLastCallEdits = root + .findAll("$MOCK.mock.lastCall") + .map((node) => node.replace(`${node.getMatch("MOCK")?.text()}.mock.calls.at(-1)?.arguments`)); + + const mockClearEdits = root + .findAll("$MOCK.mockClear()") + .map((node) => node.replace(`${node.getMatch("MOCK")?.text()}.mock.resetCalls()`)); + + // TODO: consider doing something like a.mock.mockImplementation((...args: unknown[]) => {}); for consistent behavior + const mockResetEdits = root + .findAll("$MOCK.mockReset()") + .map((node) => node.replace(`${node.getMatch("MOCK")?.text()}.mock.restore()`)); + + const mockRestoreEdits = root + .findAll("$MOCK.mockRestore()") + .map((node) => node.replace(`${node.getMatch("MOCK")?.text()}.mock.restore()`)); + + // TODO: Consider deleting mockName + + // TODO: consider doing `a.mock.mockImplementation(function () { return this; });` for mockReturnThis + + const mockImplementationEdits = root + .findAll("$MOCK.mockImplementation($IMPLEMENTATION)") + .map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const implementation = node.getMatch("IMPLEMENTATION")?.text(); + return node.replace(`${mock}.mock.mockImplementation(${implementation})`); + }); + + const mockImplementationOnceEdits = root + .findAll("$MOCK.mockImplementationOnce($IMPLEMENTATION)") + .map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const implementation = node.getMatch("IMPLEMENTATION")?.text(); + return node.replace(`${mock}.mock.mockImplementationOnce(${implementation})`); + }); + + const mockReturnValueEdits = root.findAll("$MOCK.mockReturnValue($VALUE)").map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const value = node.getMatch("VALUE")?.text(); + return node.replace(`${mock}.mock.mockImplementation(() => ${value})`); + }); + + const mockReturnValueOnceEdits = root.findAll("$MOCK.mockReturnValueOnce($VALUE)").map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const value = node.getMatch("VALUE")?.text(); + return node.replace(`${mock}.mock.mockImplementationOnce(() => ${value})`); + }); + + const mockRejectedValueEdits = root.findAll("$MOCK.mockRejectedValue($ERROR)").map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const error = node.getMatch("ERROR")?.text(); + return node.replace(`${mock}.mock.mockImplementation(async () => { + throw ${error}; +})`); + }); + + const mockRejectedValueOnceEdits = root + .findAll("$MOCK.mockRejectedValueOnce($ERROR)") + .map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const error = node.getMatch("ERROR")?.text(); + return node.replace(`${mock}.mock.mockImplementationOnce(async () => { + throw ${error}; +})`); + }); + + const mockResolvedValueEdits = root.findAll("$MOCK.mockResolvedValue($VALUE)").map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const value = node.getMatch("VALUE")?.text(); + return node.replace(`${mock}.mock.mockImplementation(async () => ${value})`); + }); + + const mockResolvedValueOnceEdits = root + .findAll("$MOCK.mockResolvedValueOnce($VALUE)") + .map((node) => { + const mock = node.getMatch("MOCK")?.text(); + const value = node.getMatch("VALUE")?.text(); + return node.replace(`${mock}.mock.mockImplementationOnce(async () => ${value})`); + }); + + let snapshotNodes: SgNode[] = []; + + // TODO: Consider if translation of matchers is possible + const toMatchSnapshotEdits = root + .findAll("expect($ACTUAL).toMatchSnapshot($$$_ARGS)") + .map((node) => { + snapshotNodes.push(node); + const actual = node.getMatch("ACTUAL")?.text(); + return node.replace(`t.assert.snapshot(${actual})`); + }); + + // TODO: Consider if translation of matchers is possible + const toMatchInlineSnapshotEdits = root + .findAll("expect($ACTUAL).toMatchInlineSnapshot($$$_ARGS)") + .map((node) => { + snapshotNodes.push(node); + const actual = node.getMatch("ACTUAL")?.text(); + // For inline snapshots, we ignore the snapshot content and just use t.assert.snapshot + return node.replace(`t.assert.snapshot(${actual})`); + }); + + // TODO: Avoid changing the same node multiple times + const testArgumentEdits = snapshotNodes + .map((node) => { + const ancestor = node.ancestors().find((a) => a.kind() === "call_expression"); + const child = ancestor?.field("arguments"); + const grandChild = child + ?.children() + .find((c) => c.kind() === "arrow_function" || c.kind() === "function_expression"); + return grandChild?.field("parameters")?.replace("(t)"); + }) + .filter((edit) => edit !== undefined); + + const jestUseFakeTimersEdits = root + .findAll("jest.useFakeTimers()") + .map((node) => node.replace("mock.timers.enable()")); + + const jestUseRealTimersEdits = root + .findAll("jest.useRealTimers()") + .map((node) => node.replace("mock.timers.reset()")); + + // TODO: Check if we can do this the run all recursively to match behavior + // TODO: Check if we can run only microtasks + const jestRunAllTicksEdits = root + .findAll("jest.runAllTicks()") + .map((node) => node.replace("mock.timers.runAll()")); + + const jestRunAllTimersEdits = root + .findAll("jest.runAllTimers()") + .map((node) => node.replace("mock.timers.runAll()")); + + // FIXME: Potentially incorrect if used with await/promise chaining + const jestRunAllTimersAsyncEdits = root + .findAll("jest.runAllTimersAsync()") + .map((node) => node.replace("mock.timers.runAll()")); + + // TODO: Check if we can run only immediates + const jestRunAllImmediatesEdits = root + .findAll("jest.runAllImmediates()") + .map((node) => node.replace("mock.timers.runAll()")); + + const jestAdvanceTimersByTimeEdits = root + .findAll("jest.advanceTimersByTime($TIME)") + .map((node) => { + const time = node.getMatch("TIME")?.text(); + return node.replace(`mock.timers.tick(${time})`); + }); + + // FIXME: Potentially incorrect if used with await/promise chaining + const jestAdvanceTimersByTimeAsyncEdits = root + .findAll("jest.advanceTimersByTimeAsync($TIME)") + .map((node) => { + const time = node.getMatch("TIME")?.text(); + return node.replace(`mock.timers.tick(${time})`); + }); + + const jestRunOnlyPendingTimersEdits = root + .findAll("jest.runOnlyPendingTimers()") + .map((node) => node.replace("mock.timers.runAll()")); + + const jestRunOnlyPendingTimersAsyncEdits = root + .findAll("jest.runOnlyPendingTimersAsync()") + .map((node) => node.replace("mock.timers.runAll()")); + + // TODO: Consider if advanceToNextTimer is translatable + + // TODO: Consider if advanceToNextTimerAsync is translatable + + const jestClearAllTimersEdits = root + .findAll("jest.clearAllTimers()") + .map((node) => node.replace("mock.timers.reset()")); + + // TODO: Consider if getTimerCount is translatable" + + const jestNowEdits = root.findAll("jest.now()").map((node) => node.replace("Date.now()")); + + const jestSetSystemTimeEdits = root.findAll("jest.setSystemTime($TIME)").map((node) => { + const time = node.getMatch("TIME")?.text(); + // FIXME: Hack to work with Date and number + return node.replace(`mock.timers.setTime(Number(${time}))`); + }); + + // TODO: Consider if getRealSystemTime is translatable + + edits.push( + ...deleteJestImportEdits, + ...moduleMockEdits, + ...fnMockEdits, + ...jestSpyOnEdits, + ...toHaveBeenCalledEdits, + ...toBeCalledEdits, + ...toHaveBeenCalledTimesEdits, + ...toBeCalledTimesEdits, + ...toHaveBeenCalledWithEdits, + ...toBeCalledWithEdits, + ...toHaveBeenLastCalledWithEdits, + ...lastCalledWithEdits, + ...toHaveBeenNthCalledWithEdits, + ...nthCalledWithEdits, + ...toHaveReturnedEdits, + ...toReturnEdits, + ...toHaveReturnedTimesEdits, + ...toReturnTimesEdits, + ...toHaveReturnedWithEdits, + ...toReturnWithEdits, + ...toHaveLastReturnedWithEdits, + ...lastReturnedWithEdits, + ...toHaveNthReturnedWithEdits, + ...nthReturnedWithEdits, + ...mockCallsEdits, + ...mockResultsEdits, + ...mockLastCallEdits, + ...mockClearEdits, + ...mockResetEdits, + ...mockRestoreEdits, + ...mockImplementationEdits, + ...mockImplementationOnceEdits, + ...mockReturnValueEdits, + ...mockReturnValueOnceEdits, + ...mockRejectedValueEdits, + ...mockRejectedValueOnceEdits, + ...mockResolvedValueEdits, + ...mockResolvedValueOnceEdits, + ...jestUseFakeTimersEdits, + ...jestUseRealTimersEdits, + ...jestRunAllTicksEdits, + ...jestRunAllTimersEdits, + ...jestRunAllTimersAsyncEdits, + ...jestRunAllImmediatesEdits, + ...jestAdvanceTimersByTimeEdits, + ...jestAdvanceTimersByTimeAsyncEdits, + ...jestRunOnlyPendingTimersEdits, + ...jestRunOnlyPendingTimersAsyncEdits, + ...jestClearAllTimersEdits, + ...jestNowEdits, + ...jestSetSystemTimeEdits, + ...toMatchSnapshotEdits, + ...toMatchInlineSnapshotEdits, + ...testArgumentEdits, + ); + + return root.commitEdits(edits); +} diff --git a/recipes/jest-to-node-test/tsconfig.json b/recipes/jest-to-node-test/tsconfig.json new file mode 100644 index 00000000..3a850c68 --- /dev/null +++ b/recipes/jest-to-node-test/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "allowImportingTsExtensions": true, + "allowJs": true, + "alwaysStrict": true, + "baseUrl": "./", + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "lib": ["ESNext", "DOM"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "noImplicitThis": true, + "removeComments": true, + "strict": true, + "stripInternal": true, + "target": "esnext" + }, + "include": ["./"], + "exclude": [ + "node_modules", + "./node_modules", + "**/*.fixture.mjs", + "**/*.mock.mjs", + "**/*.test.mjs" + ] +}