@metamask/snaps-jest 4.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/README.md +66 -179
- package/dist/chunk-2KLZ7GOW.js +15 -0
- package/dist/chunk-2KLZ7GOW.js.map +1 -0
- package/dist/chunk-2M7WQ26F.js +28 -0
- package/dist/chunk-2M7WQ26F.js.map +1 -0
- package/dist/chunk-34GS3AHA.js +33 -0
- package/dist/chunk-34GS3AHA.js.map +1 -0
- package/dist/chunk-3CC2NI7R.js +80 -0
- package/dist/chunk-3CC2NI7R.js.map +1 -0
- package/dist/chunk-3IUQA6YL.mjs +1 -0
- package/dist/chunk-3IUQA6YL.mjs.map +1 -0
- package/dist/chunk-3KCEPGJA.js +39 -0
- package/dist/chunk-3KCEPGJA.js.map +1 -0
- package/dist/chunk-3KQYPQZY.js +20 -0
- package/dist/chunk-3KQYPQZY.js.map +1 -0
- package/dist/chunk-3O5OISLU.js +16 -0
- package/dist/chunk-3O5OISLU.js.map +1 -0
- package/dist/chunk-3ZW2EE3B.js +1 -0
- package/dist/chunk-3ZW2EE3B.js.map +1 -0
- package/dist/chunk-4FCRZDOX.js +134 -0
- package/dist/chunk-4FCRZDOX.js.map +1 -0
- package/dist/chunk-4HY4SM3A.js +1 -0
- package/dist/chunk-4HY4SM3A.js.map +1 -0
- package/dist/chunk-4JUUFDTC.js +104 -0
- package/dist/chunk-4JUUFDTC.js.map +1 -0
- package/dist/chunk-4VCE3DRR.mjs +34 -0
- package/dist/chunk-4VCE3DRR.mjs.map +1 -0
- package/dist/chunk-4WCFXE73.js +48 -0
- package/dist/chunk-4WCFXE73.js.map +1 -0
- package/dist/chunk-5IUHGC5S.js +153 -0
- package/dist/chunk-5IUHGC5S.js.map +1 -0
- package/dist/chunk-5O6VBW42.js +42 -0
- package/dist/chunk-5O6VBW42.js.map +1 -0
- package/dist/chunk-6IMEYERE.js +137 -0
- package/dist/chunk-6IMEYERE.js.map +1 -0
- package/dist/chunk-6KNT4UMX.mjs +35 -0
- package/dist/chunk-6KNT4UMX.mjs.map +1 -0
- package/dist/chunk-6RDNSELT.mjs +39 -0
- package/dist/chunk-6RDNSELT.mjs.map +1 -0
- package/dist/chunk-72YN2D26.mjs +60 -0
- package/dist/chunk-72YN2D26.mjs.map +1 -0
- package/dist/chunk-7JLVQJK7.js +14 -0
- package/dist/chunk-7JLVQJK7.js.map +1 -0
- package/dist/chunk-AH7YNG6N.js +22 -0
- package/dist/chunk-AH7YNG6N.js.map +1 -0
- package/dist/chunk-AIZADBRK.mjs +36 -0
- package/dist/chunk-AIZADBRK.mjs.map +1 -0
- package/dist/chunk-AKFRQ5EJ.mjs +42 -0
- package/dist/chunk-AKFRQ5EJ.mjs.map +1 -0
- package/dist/chunk-AUB7XPDH.mjs +28 -0
- package/dist/chunk-AUB7XPDH.mjs.map +1 -0
- package/dist/chunk-BJMTD7H2.mjs +20 -0
- package/dist/chunk-BJMTD7H2.mjs.map +1 -0
- package/dist/chunk-BN5VBVT3.mjs +233 -0
- package/dist/chunk-BN5VBVT3.mjs.map +1 -0
- package/dist/chunk-CKOGTHM4.mjs +22 -0
- package/dist/chunk-CKOGTHM4.mjs.map +1 -0
- package/dist/chunk-CZQKOZLR.js +11 -0
- package/dist/chunk-CZQKOZLR.js.map +1 -0
- package/dist/chunk-D36QBJ35.js +24 -0
- package/dist/chunk-D36QBJ35.js.map +1 -0
- package/dist/chunk-DEFFA5IJ.mjs +24 -0
- package/dist/chunk-DEFFA5IJ.mjs.map +1 -0
- package/dist/chunk-EFB6AQPB.js +36 -0
- package/dist/chunk-EFB6AQPB.js.map +1 -0
- package/dist/chunk-EOCDSPT7.mjs +97 -0
- package/dist/chunk-EOCDSPT7.mjs.map +1 -0
- package/dist/chunk-FPFX5AKR.mjs +36 -0
- package/dist/chunk-FPFX5AKR.mjs.map +1 -0
- package/dist/chunk-HBT34TJ2.mjs +1 -0
- package/dist/chunk-HBT34TJ2.mjs.map +1 -0
- package/dist/chunk-HBVDXIVN.mjs +80 -0
- package/dist/chunk-HBVDXIVN.mjs.map +1 -0
- package/dist/chunk-HMF2CKYT.mjs +39 -0
- package/dist/chunk-HMF2CKYT.mjs.map +1 -0
- package/dist/chunk-HP56MLQ3.js +1 -0
- package/dist/chunk-HP56MLQ3.js.map +1 -0
- package/dist/chunk-I5LVU57H.mjs +69 -0
- package/dist/chunk-I5LVU57H.mjs.map +1 -0
- package/dist/chunk-I7FLOZU7.mjs +1 -0
- package/dist/chunk-I7FLOZU7.mjs.map +1 -0
- package/dist/chunk-J2ID3DS7.mjs +33 -0
- package/dist/chunk-J2ID3DS7.mjs.map +1 -0
- package/dist/chunk-JA7RJLI7.js +34 -0
- package/dist/chunk-JA7RJLI7.js.map +1 -0
- package/dist/chunk-JB2H2XEL.mjs +1 -0
- package/dist/chunk-JB2H2XEL.mjs.map +1 -0
- package/dist/chunk-JDN3VGMO.js +21 -0
- package/dist/chunk-JDN3VGMO.js.map +1 -0
- package/dist/chunk-JGQJFYU4.js +57 -0
- package/dist/chunk-JGQJFYU4.js.map +1 -0
- package/dist/chunk-JJCX335U.mjs +91 -0
- package/dist/chunk-JJCX335U.mjs.map +1 -0
- package/dist/chunk-JMDSN227.mjs +25 -0
- package/dist/chunk-JMDSN227.mjs.map +1 -0
- package/dist/chunk-JXOKRTEH.mjs +11 -0
- package/dist/chunk-JXOKRTEH.mjs.map +1 -0
- package/dist/chunk-JZJWUVD7.mjs +1 -0
- package/dist/chunk-JZJWUVD7.mjs.map +1 -0
- package/dist/chunk-K2KTKFLP.js +76 -0
- package/dist/chunk-K2KTKFLP.js.map +1 -0
- package/dist/chunk-KGIWSGTT.js +91 -0
- package/dist/chunk-KGIWSGTT.js.map +1 -0
- package/dist/chunk-KPXLJ6RH.js +60 -0
- package/dist/chunk-KPXLJ6RH.js.map +1 -0
- package/dist/chunk-LD5PSHHT.mjs +57 -0
- package/dist/chunk-LD5PSHHT.mjs.map +1 -0
- package/dist/chunk-LNNKGOHQ.mjs +16 -0
- package/dist/chunk-LNNKGOHQ.mjs.map +1 -0
- package/dist/chunk-MNDF32ZV.js +8 -0
- package/dist/chunk-MNDF32ZV.js.map +1 -0
- package/dist/chunk-MSQ7Q2VJ.mjs +13 -0
- package/dist/chunk-MSQ7Q2VJ.mjs.map +1 -0
- package/dist/chunk-O3VJYBFN.mjs +15 -0
- package/dist/chunk-O3VJYBFN.mjs.map +1 -0
- package/dist/chunk-O4MJRHZD.js +69 -0
- package/dist/chunk-O4MJRHZD.js.map +1 -0
- package/dist/chunk-OC64PNDU.mjs +21 -0
- package/dist/chunk-OC64PNDU.mjs.map +1 -0
- package/dist/chunk-ON6M4WG5.js +36 -0
- package/dist/chunk-ON6M4WG5.js.map +1 -0
- package/dist/chunk-P7JA42ZC.mjs +153 -0
- package/dist/chunk-P7JA42ZC.mjs.map +1 -0
- package/dist/chunk-PHUTP7NB.js +25 -0
- package/dist/chunk-PHUTP7NB.js.map +1 -0
- package/dist/chunk-QFPRGU5L.mjs +104 -0
- package/dist/chunk-QFPRGU5L.mjs.map +1 -0
- package/dist/chunk-QMHWGASM.js +1 -0
- package/dist/chunk-QMHWGASM.js.map +1 -0
- package/dist/chunk-QNDLJ2W7.js +1 -0
- package/dist/chunk-QNDLJ2W7.js.map +1 -0
- package/dist/chunk-QUUILTDY.mjs +137 -0
- package/dist/chunk-QUUILTDY.mjs.map +1 -0
- package/dist/chunk-R7ORBTUD.js +1 -0
- package/dist/chunk-R7ORBTUD.js.map +1 -0
- package/dist/chunk-RQBZLDXL.js +233 -0
- package/dist/chunk-RQBZLDXL.js.map +1 -0
- package/dist/chunk-S3DHQTXB.js +1 -0
- package/dist/chunk-S3DHQTXB.js.map +1 -0
- package/dist/chunk-SWSSV3LK.js +35 -0
- package/dist/chunk-SWSSV3LK.js.map +1 -0
- package/dist/chunk-T4TRX3ZR.js +22 -0
- package/dist/chunk-T4TRX3ZR.js.map +1 -0
- package/dist/chunk-UXHKMILA.mjs +1 -0
- package/dist/chunk-UXHKMILA.mjs.map +1 -0
- package/dist/chunk-VCXM6FKU.mjs +1 -0
- package/dist/chunk-VCXM6FKU.mjs.map +1 -0
- package/dist/chunk-VHTVUQWR.mjs +14 -0
- package/dist/chunk-VHTVUQWR.mjs.map +1 -0
- package/dist/chunk-VNQIROKZ.js +97 -0
- package/dist/chunk-VNQIROKZ.js.map +1 -0
- package/dist/chunk-VXQOXWRO.mjs +48 -0
- package/dist/chunk-VXQOXWRO.mjs.map +1 -0
- package/dist/chunk-VYKYQSUI.mjs +22 -0
- package/dist/chunk-VYKYQSUI.mjs.map +1 -0
- package/dist/chunk-WEI35OIM.mjs +8 -0
- package/dist/chunk-WEI35OIM.mjs.map +1 -0
- package/dist/chunk-WL2GRM5E.mjs +76 -0
- package/dist/chunk-WL2GRM5E.mjs.map +1 -0
- package/dist/chunk-XDZPH5WD.js +39 -0
- package/dist/chunk-XDZPH5WD.js.map +1 -0
- package/dist/chunk-Y5NWZU43.js +13 -0
- package/dist/chunk-Y5NWZU43.js.map +1 -0
- package/dist/chunk-YZFWCFMG.js +1 -0
- package/dist/chunk-YZFWCFMG.js.map +1 -0
- package/dist/chunk-ZCE26WZM.mjs +1 -0
- package/dist/chunk-ZCE26WZM.mjs.map +1 -0
- package/dist/chunk-ZZPKZRJQ.mjs +134 -0
- package/dist/chunk-ZZPKZRJQ.mjs.map +1 -0
- package/dist/environment.js +47 -0
- package/dist/environment.js.map +1 -0
- package/dist/environment.mjs +47 -0
- package/dist/environment.mjs.map +1 -0
- package/dist/helpers.js +44 -0
- package/dist/helpers.js.map +1 -0
- package/dist/helpers.mjs +44 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +54 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internals/environment.js +8 -0
- package/dist/internals/environment.js.map +1 -0
- package/dist/internals/environment.mjs +8 -0
- package/dist/internals/environment.mjs.map +1 -0
- package/dist/internals/index.js +123 -0
- package/dist/internals/index.js.map +1 -0
- package/dist/internals/index.mjs +123 -0
- package/dist/internals/index.mjs.map +1 -0
- package/dist/internals/logger.js +8 -0
- package/dist/internals/logger.js.map +1 -0
- package/dist/internals/logger.mjs +8 -0
- package/dist/internals/logger.mjs.map +1 -0
- package/dist/internals/request.js +40 -0
- package/dist/internals/request.js.map +1 -0
- package/dist/internals/request.mjs +40 -0
- package/dist/internals/request.mjs.map +1 -0
- package/dist/internals/server.js +9 -0
- package/dist/internals/server.js.map +1 -0
- package/dist/internals/server.mjs +9 -0
- package/dist/internals/server.mjs.map +1 -0
- package/dist/internals/simulation/constants.js +12 -0
- package/dist/internals/simulation/constants.js.map +1 -0
- package/dist/internals/simulation/constants.mjs +12 -0
- package/dist/internals/simulation/constants.mjs.map +1 -0
- package/dist/internals/simulation/controllers.js +26 -0
- package/dist/internals/simulation/controllers.js.map +1 -0
- package/dist/internals/simulation/controllers.mjs +26 -0
- package/dist/internals/simulation/controllers.mjs.map +1 -0
- package/dist/internals/simulation/files.js +8 -0
- package/dist/internals/simulation/files.js.map +1 -0
- package/dist/internals/simulation/files.mjs +8 -0
- package/dist/internals/simulation/files.mjs.map +1 -0
- package/dist/internals/simulation/index.js +90 -0
- package/dist/internals/simulation/index.js.map +1 -0
- package/dist/internals/simulation/index.mjs +90 -0
- package/dist/internals/simulation/index.mjs.map +1 -0
- package/dist/internals/simulation/interface.js +16 -0
- package/dist/internals/simulation/interface.js.map +1 -0
- package/dist/internals/simulation/interface.mjs +16 -0
- package/dist/internals/simulation/interface.mjs.map +1 -0
- package/dist/internals/simulation/methods/constants.js +12 -0
- package/dist/internals/simulation/methods/constants.js.map +1 -0
- package/dist/internals/simulation/methods/constants.mjs +12 -0
- package/dist/internals/simulation/methods/constants.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/encryption.js +10 -0
- package/dist/internals/simulation/methods/hooks/encryption.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/encryption.mjs +10 -0
- package/dist/internals/simulation/methods/hooks/encryption.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-locale.js +8 -0
- package/dist/internals/simulation/methods/hooks/get-locale.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/get-locale.mjs +8 -0
- package/dist/internals/simulation/methods/hooks/get-locale.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.js +45 -0
- package/dist/internals/simulation/methods/hooks/index.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/index.mjs +45 -0
- package/dist/internals/simulation/methods/hooks/index.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.js +10 -0
- package/dist/internals/simulation/methods/hooks/interface.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/interface.mjs +10 -0
- package/dist/internals/simulation/methods/hooks/interface.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.js +16 -0
- package/dist/internals/simulation/methods/hooks/notifications.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/notifications.mjs +16 -0
- package/dist/internals/simulation/methods/hooks/notifications.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.js +14 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs +14 -0
- package/dist/internals/simulation/methods/hooks/show-dialog.mjs.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.js +18 -0
- package/dist/internals/simulation/methods/hooks/state.js.map +1 -0
- package/dist/internals/simulation/methods/hooks/state.mjs +18 -0
- package/dist/internals/simulation/methods/hooks/state.mjs.map +1 -0
- package/dist/internals/simulation/methods/index.js +29 -0
- package/dist/internals/simulation/methods/index.js.map +1 -0
- package/dist/internals/simulation/methods/index.mjs +29 -0
- package/dist/internals/simulation/methods/index.mjs.map +1 -0
- package/dist/internals/simulation/methods/specifications.js +28 -0
- package/dist/internals/simulation/methods/specifications.js.map +1 -0
- package/dist/internals/simulation/methods/specifications.mjs +28 -0
- package/dist/internals/simulation/methods/specifications.mjs.map +1 -0
- package/dist/internals/simulation/middleware/engine.js +15 -0
- package/dist/internals/simulation/middleware/engine.js.map +1 -0
- package/dist/internals/simulation/middleware/engine.mjs +15 -0
- package/dist/internals/simulation/middleware/engine.mjs.map +1 -0
- package/dist/internals/simulation/middleware/index.js +16 -0
- package/dist/internals/simulation/middleware/index.js.map +1 -0
- package/dist/internals/simulation/middleware/index.mjs +16 -0
- package/dist/internals/simulation/middleware/index.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.js +8 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs +8 -0
- package/dist/internals/simulation/middleware/internal-methods/accounts.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.js +11 -0
- package/dist/internals/simulation/middleware/internal-methods/index.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/index.mjs +11 -0
- package/dist/internals/simulation/middleware/internal-methods/index.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.js +10 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs +10 -0
- package/dist/internals/simulation/middleware/internal-methods/middleware.mjs.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js +8 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.js.map +1 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs +8 -0
- package/dist/internals/simulation/middleware/internal-methods/provider-state.mjs.map +1 -0
- package/dist/internals/simulation/middleware/mock.js +9 -0
- package/dist/internals/simulation/middleware/mock.js.map +1 -0
- package/dist/internals/simulation/middleware/mock.mjs +9 -0
- package/dist/internals/simulation/middleware/mock.mjs.map +1 -0
- package/dist/internals/simulation/options.js +9 -0
- package/dist/internals/simulation/options.js.map +1 -0
- package/dist/internals/simulation/options.mjs +9 -0
- package/dist/internals/simulation/options.mjs.map +1 -0
- package/dist/internals/simulation/simulation.js +39 -0
- package/dist/internals/simulation/simulation.js.map +1 -0
- package/dist/internals/simulation/simulation.mjs +39 -0
- package/dist/internals/simulation/simulation.mjs.map +1 -0
- package/dist/internals/simulation/store/index.js +44 -0
- package/dist/internals/simulation/store/index.js.map +1 -0
- package/dist/internals/simulation/store/index.mjs +44 -0
- package/dist/internals/simulation/store/index.mjs.map +1 -0
- package/dist/internals/simulation/store/mocks.js +16 -0
- package/dist/internals/simulation/store/mocks.js.map +1 -0
- package/dist/internals/simulation/store/mocks.mjs +16 -0
- package/dist/internals/simulation/store/mocks.mjs.map +1 -0
- package/dist/internals/simulation/store/notifications.js +16 -0
- package/dist/internals/simulation/store/notifications.js.map +1 -0
- package/dist/internals/simulation/store/notifications.mjs +16 -0
- package/dist/internals/simulation/store/notifications.mjs.map +1 -0
- package/dist/internals/simulation/store/state.js +14 -0
- package/dist/internals/simulation/store/state.js.map +1 -0
- package/dist/internals/simulation/store/state.mjs +14 -0
- package/dist/internals/simulation/store/state.mjs.map +1 -0
- package/dist/internals/simulation/store/store.js +12 -0
- package/dist/internals/simulation/store/store.js.map +1 -0
- package/dist/internals/simulation/store/store.mjs +12 -0
- package/dist/internals/simulation/store/store.mjs.map +1 -0
- package/dist/internals/simulation/store/ui.js +16 -0
- package/dist/internals/simulation/store/ui.js.map +1 -0
- package/dist/internals/simulation/store/ui.mjs +16 -0
- package/dist/internals/simulation/store/ui.mjs.map +1 -0
- package/dist/internals/structs.js +18 -0
- package/dist/internals/structs.js.map +1 -0
- package/dist/internals/structs.mjs +18 -0
- package/dist/internals/structs.mjs.map +1 -0
- package/dist/matchers.js +50 -0
- package/dist/matchers.js.map +1 -0
- package/dist/matchers.mjs +50 -0
- package/dist/matchers.mjs.map +1 -0
- package/dist/options.js +8 -0
- package/dist/options.js.map +1 -0
- package/dist/options.mjs +8 -0
- package/dist/options.mjs.map +1 -0
- package/dist/setup.js +39 -0
- package/dist/setup.js.map +1 -0
- package/dist/setup.mjs +39 -0
- package/dist/setup.mjs.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/environment.d.ts +14 -15
- package/dist/types/helpers.d.ts +64 -3
- package/dist/types/internals/index.d.ts +1 -4
- package/dist/types/internals/request.d.ts +38 -74
- package/dist/types/internals/simulation/constants.d.ts +13 -0
- package/dist/types/internals/simulation/controllers.d.ts +40 -0
- package/dist/types/internals/simulation/files.d.ts +11 -0
- package/dist/types/internals/simulation/index.d.ts +5 -0
- package/dist/types/internals/simulation/interface.d.ts +25 -0
- package/dist/types/internals/simulation/methods/constants.d.ts +10 -0
- package/dist/types/internals/simulation/methods/hooks/encryption.d.ts +29 -0
- package/dist/types/internals/simulation/methods/hooks/get-locale.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/index.d.ts +6 -0
- package/dist/types/internals/simulation/methods/hooks/interface.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/notifications.d.ts +16 -0
- package/dist/types/internals/simulation/methods/hooks/show-dialog.d.ts +9 -0
- package/dist/types/internals/simulation/methods/hooks/state.d.ts +22 -0
- package/dist/types/internals/simulation/methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/methods/specifications.d.ts +56 -0
- package/dist/types/internals/simulation/middleware/engine.d.ts +26 -0
- package/dist/types/internals/simulation/middleware/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/accounts.d.ts +18 -0
- package/dist/types/internals/simulation/middleware/internal-methods/index.d.ts +1 -0
- package/dist/types/internals/simulation/middleware/internal-methods/middleware.d.ts +22 -0
- package/dist/types/internals/simulation/middleware/internal-methods/provider-state.d.ts +14 -0
- package/dist/types/internals/simulation/middleware/mock.d.ts +10 -0
- package/dist/types/internals/simulation/options.d.ts +37 -0
- package/dist/types/internals/simulation/simulation.d.ts +98 -0
- package/dist/types/internals/simulation/store/index.d.ts +4 -0
- package/dist/types/internals/simulation/store/mocks.d.ts +35 -0
- package/dist/types/internals/simulation/store/notifications.d.ts +44 -0
- package/dist/types/internals/simulation/store/state.d.ts +55 -0
- package/dist/types/internals/simulation/store/store.d.ts +22 -0
- package/dist/types/internals/simulation/store/ui.d.ts +25 -0
- package/dist/types/internals/structs.d.ts +153 -0
- package/dist/types/options.d.ts +3 -35
- package/dist/types/types.d.ts +88 -41
- package/dist/types/vendor/readable-stream.d.js +1 -0
- package/dist/types/vendor/readable-stream.d.js.map +1 -0
- package/dist/types/vendor/readable-stream.d.mjs +1 -0
- package/dist/types/vendor/readable-stream.d.mjs.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/jest-preset.js +1 -1
- package/package.json +37 -24
- package/dist/cjs/environment.js +0 -205
- package/dist/cjs/environment.js.map +0 -1
- package/dist/cjs/helpers.js +0 -67
- package/dist/cjs/helpers.js.map +0 -1
- package/dist/cjs/index.js +0 -42
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internals/environment.js +0 -19
- package/dist/cjs/internals/environment.js.map +0 -1
- package/dist/cjs/internals/index.js +0 -28
- package/dist/cjs/internals/index.js.map +0 -1
- package/dist/cjs/internals/interface.js +0 -103
- package/dist/cjs/internals/interface.js.map +0 -1
- package/dist/cjs/internals/logger.js +0 -14
- package/dist/cjs/internals/logger.js.map +0 -1
- package/dist/cjs/internals/network.js +0 -148
- package/dist/cjs/internals/network.js.map +0 -1
- package/dist/cjs/internals/request.js +0 -121
- package/dist/cjs/internals/request.js.map +0 -1
- package/dist/cjs/internals/server.js +0 -75
- package/dist/cjs/internals/server.js.map +0 -1
- package/dist/cjs/internals/structs.js +0 -122
- package/dist/cjs/internals/structs.js.map +0 -1
- package/dist/cjs/internals/types.js +0 -6
- package/dist/cjs/internals/types.js.map +0 -1
- package/dist/cjs/internals/wait-for.js +0 -63
- package/dist/cjs/internals/wait-for.js.map +0 -1
- package/dist/cjs/matchers.js +0 -117
- package/dist/cjs/matchers.js.map +0 -1
- package/dist/cjs/options.js +0 -29
- package/dist/cjs/options.js.map +0 -1
- package/dist/cjs/setup.js +0 -10
- package/dist/cjs/setup.js.map +0 -1
- package/dist/cjs/types.js +0 -6
- package/dist/cjs/types.js.map +0 -1
- package/dist/esm/environment.js +0 -182
- package/dist/esm/environment.js.map +0 -1
- package/dist/esm/helpers.js +0 -82
- package/dist/esm/helpers.js.map +0 -1
- package/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internals/environment.js +0 -14
- package/dist/esm/internals/environment.js.map +0 -1
- package/dist/esm/internals/index.js +0 -12
- package/dist/esm/internals/index.js.map +0 -1
- package/dist/esm/internals/interface.js +0 -100
- package/dist/esm/internals/interface.js.map +0 -1
- package/dist/esm/internals/logger.js +0 -4
- package/dist/esm/internals/logger.js.map +0 -1
- package/dist/esm/internals/network.js +0 -143
- package/dist/esm/internals/network.js.map +0 -1
- package/dist/esm/internals/request.js +0 -120
- package/dist/esm/internals/request.js.map +0 -1
- package/dist/esm/internals/server.js +0 -68
- package/dist/esm/internals/server.js.map +0 -1
- package/dist/esm/internals/structs.js +0 -98
- package/dist/esm/internals/structs.js.map +0 -1
- package/dist/esm/internals/types.js +0 -3
- package/dist/esm/internals/types.js.map +0 -1
- package/dist/esm/internals/wait-for.js +0 -63
- package/dist/esm/internals/wait-for.js.map +0 -1
- package/dist/esm/matchers.js +0 -108
- package/dist/esm/matchers.js.map +0 -1
- package/dist/esm/options.js +0 -26
- package/dist/esm/options.js.map +0 -1
- package/dist/esm/setup.js +0 -6
- package/dist/esm/setup.js.map +0 -1
- package/dist/esm/types.js +0 -3
- package/dist/esm/types.js.map +0 -1
- package/dist/types/internals/interface.d.ts +0 -25
- package/dist/types/internals/network.d.ts +0 -87
- package/dist/types/internals/types.d.ts +0 -18
- package/dist/types/internals/wait-for.d.ts +0 -38
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NotificationType, EnumToUnion, Component } from '@metamask/snaps-sdk';
|
|
2
|
-
import type { JsonRpcId, JsonRpcParams } from '@metamask/utils';
|
|
2
|
+
import type { Json, JsonRpcId, JsonRpcParams } from '@metamask/utils';
|
|
3
3
|
import type { Infer } from 'superstruct';
|
|
4
|
-
import type {
|
|
4
|
+
import type { SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from './internals';
|
|
5
5
|
declare module 'expect' {
|
|
6
6
|
interface AsymmetricMatchers {
|
|
7
7
|
toRespondWith(response: unknown): void;
|
|
@@ -16,27 +16,6 @@ declare module 'expect' {
|
|
|
16
16
|
toRender(component: Component): R;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Deeply partialize a type.
|
|
21
|
-
*
|
|
22
|
-
* @template Type - The type to partialize.
|
|
23
|
-
* @returns The deeply partialized type.
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* type Foo = {
|
|
27
|
-
* bar: {
|
|
28
|
-
* baz: string;
|
|
29
|
-
* };
|
|
30
|
-
* qux: number;
|
|
31
|
-
* };
|
|
32
|
-
*
|
|
33
|
-
* type PartialFoo = DeepPartial<Foo>;
|
|
34
|
-
* // { bar?: { baz?: string; }; qux?: number; }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare type DeepPartial<Type> = {
|
|
38
|
-
[Key in keyof Type]?: Type[Key] extends Record<string, unknown> ? DeepPartial<Type[Key]> : Type[Key];
|
|
39
|
-
};
|
|
40
19
|
export declare type RequestOptions = {
|
|
41
20
|
/**
|
|
42
21
|
* The JSON-RPC request ID.
|
|
@@ -82,6 +61,17 @@ export declare type CronjobOptions = Omit<RequestOptions, 'origin'>;
|
|
|
82
61
|
* @property nonce - The nonce to use for the transaction. Defaults to `0`.
|
|
83
62
|
*/
|
|
84
63
|
export declare type TransactionOptions = Infer<typeof TransactionOptionsStruct>;
|
|
64
|
+
/**
|
|
65
|
+
* The options to use for signature requests.
|
|
66
|
+
*
|
|
67
|
+
* @property origin - The origin to send the signature request from. Defaults to
|
|
68
|
+
* `metamask.io`.
|
|
69
|
+
* @property from - The address to send the signature from. Defaults to a
|
|
70
|
+
* randomly generated address.
|
|
71
|
+
* @property data - The data to sign. Defaults to `0x`.
|
|
72
|
+
* @property signatureMethod - The signature method.
|
|
73
|
+
*/
|
|
74
|
+
export declare type SignatureOptions = Infer<typeof SignatureOptionsStruct>;
|
|
85
75
|
/**
|
|
86
76
|
* The options to use for requests to the snap.
|
|
87
77
|
*
|
|
@@ -167,19 +157,31 @@ export declare type SnapRequestObject = {
|
|
|
167
157
|
* {@link SnapRequestObject} fields.
|
|
168
158
|
*/
|
|
169
159
|
export declare type SnapRequest = Promise<SnapResponse> & SnapRequestObject;
|
|
160
|
+
/**
|
|
161
|
+
* The options to use for mocking a JSON-RPC request.
|
|
162
|
+
*/
|
|
163
|
+
export declare type JsonRpcMockOptions = {
|
|
164
|
+
/**
|
|
165
|
+
* The JSON-RPC request method.
|
|
166
|
+
*/
|
|
167
|
+
method: string;
|
|
168
|
+
/**
|
|
169
|
+
* The JSON-RPC response, which will be returned when a request with the
|
|
170
|
+
* specified method is sent.
|
|
171
|
+
*/
|
|
172
|
+
result: Json;
|
|
173
|
+
};
|
|
170
174
|
/**
|
|
171
175
|
* This is the main entry point to interact with the snap. It is returned by
|
|
172
176
|
* {@link installSnap}, and has methods to send requests to the snap.
|
|
173
177
|
*
|
|
174
178
|
* @example
|
|
175
|
-
* ```ts
|
|
176
179
|
* import { installSnap } from '@metamask/snaps-jest';
|
|
177
180
|
*
|
|
178
181
|
* const snap = await installSnap();
|
|
179
182
|
* const response = await snap.request({ method: 'hello' });
|
|
180
183
|
*
|
|
181
184
|
* expect(response).toRespondWith('Hello, world!');
|
|
182
|
-
* ```
|
|
183
185
|
*/
|
|
184
186
|
export declare type Snap = {
|
|
185
187
|
/**
|
|
@@ -198,7 +200,26 @@ export declare type Snap = {
|
|
|
198
200
|
* will be filled in with default values.
|
|
199
201
|
* @returns The response.
|
|
200
202
|
*/
|
|
203
|
+
onTransaction(transaction?: Partial<TransactionOptions>): Promise<SnapResponse>;
|
|
204
|
+
/**
|
|
205
|
+
* Send a transaction to the snap.
|
|
206
|
+
*
|
|
207
|
+
* @param transaction - The transaction. This is similar to an Ethereum
|
|
208
|
+
* transaction object, but has an extra `origin` field. Any missing fields
|
|
209
|
+
* will be filled in with default values.
|
|
210
|
+
* @returns The response.
|
|
211
|
+
* @deprecated Use {@link onTransaction} instead.
|
|
212
|
+
*/
|
|
201
213
|
sendTransaction(transaction?: Partial<TransactionOptions>): Promise<SnapResponse>;
|
|
214
|
+
/**
|
|
215
|
+
* Send a signature request to the snap.
|
|
216
|
+
*
|
|
217
|
+
* @param signature - The signature request object. Contains the params from
|
|
218
|
+
* the various signature methods, but has an extra `origin` and `signatureMethod` field.
|
|
219
|
+
* Any missing fields will be filled in with default values.
|
|
220
|
+
* @returns The response.
|
|
221
|
+
*/
|
|
222
|
+
onSignature(signature?: Partial<SignatureOptions>): Promise<SnapResponse>;
|
|
202
223
|
/**
|
|
203
224
|
* Run a cronjob in the snap. This is similar to {@link request}, but the
|
|
204
225
|
* request will be sent to the `onCronjob` method of the snap.
|
|
@@ -208,31 +229,57 @@ export declare type Snap = {
|
|
|
208
229
|
* `endowment:cronjob` permission.
|
|
209
230
|
* @returns The response promise, with extra {@link SnapRequestObject} fields.
|
|
210
231
|
*/
|
|
232
|
+
onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;
|
|
233
|
+
/**
|
|
234
|
+
* Run a cronjob in the snap. This is similar to {@link request}, but the
|
|
235
|
+
* request will be sent to the `onCronjob` method of the snap.
|
|
236
|
+
*
|
|
237
|
+
* @param cronjob - The cronjob request. This is similar to a JSON-RPC
|
|
238
|
+
* request, and is normally specified in the snap manifest, under the
|
|
239
|
+
* `endowment:cronjob` permission.
|
|
240
|
+
* @returns The response promise, with extra {@link SnapRequestObject} fields.
|
|
241
|
+
* @deprecated Use {@link onCronjob} instead.
|
|
242
|
+
*/
|
|
211
243
|
runCronjob(cronjob: CronjobOptions): SnapRequest;
|
|
212
244
|
/**
|
|
213
|
-
*
|
|
214
|
-
* the test environment, and calling it is not strictly necessary.
|
|
245
|
+
* Get the response from the snap's `onHomePage` method.
|
|
215
246
|
*
|
|
216
|
-
* @returns
|
|
247
|
+
* @returns The response.
|
|
217
248
|
*/
|
|
218
|
-
|
|
249
|
+
onHomePage(): Promise<SnapResponse>;
|
|
219
250
|
/**
|
|
220
|
-
*
|
|
251
|
+
* Mock a JSON-RPC request. This will cause the snap to respond with the
|
|
252
|
+
* specified response when a request with the specified method is sent.
|
|
221
253
|
*
|
|
222
|
-
* @param
|
|
223
|
-
* @
|
|
254
|
+
* @param mock - The mock options.
|
|
255
|
+
* @param mock.method - The JSON-RPC request method.
|
|
256
|
+
* @param mock.result - The JSON-RPC response, which will be returned when a
|
|
257
|
+
* request with the specified method is sent.
|
|
258
|
+
* @example
|
|
259
|
+
* import { installSnap } from '@metamask/snaps-jest';
|
|
260
|
+
*
|
|
261
|
+
* // In the test
|
|
262
|
+
* const snap = await installSnap();
|
|
263
|
+
* snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });
|
|
264
|
+
*
|
|
265
|
+
* // In the Snap
|
|
266
|
+
* const response =
|
|
267
|
+
* await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
|
|
224
268
|
*/
|
|
225
|
-
mock
|
|
269
|
+
mockJsonRpc(mock: JsonRpcMockOptions): {
|
|
270
|
+
/**
|
|
271
|
+
* Remove the mock.
|
|
272
|
+
*/
|
|
273
|
+
unmock(): void;
|
|
274
|
+
};
|
|
226
275
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
276
|
+
* Close the page running the snap. This is mainly useful for cleaning up
|
|
277
|
+
* the test environment, and calling it is not strictly necessary.
|
|
229
278
|
*
|
|
230
|
-
* @
|
|
231
|
-
* @
|
|
232
|
-
*
|
|
233
|
-
* @param options.result - The JSON value to return.
|
|
234
|
-
* @returns A {@link Mock} object, with an `unmock` function.
|
|
279
|
+
* @returns A promise that resolves when the page is closed.
|
|
280
|
+
* @deprecated Snaps are now automatically closed when the test ends. This
|
|
281
|
+
* method will be removed in a future release.
|
|
235
282
|
*/
|
|
236
|
-
|
|
283
|
+
close(): Promise<void>;
|
|
237
284
|
};
|
|
238
285
|
export declare type SnapResponse = Infer<typeof SnapResponseStruct>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=readable-stream.d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=readable-stream.d.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":""}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/jest-preset.js
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-jest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "A Jest preset for end-to-end testing MetaMask Snaps, including a Jest environment, and a set of Jest matchers.",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.js",
|
|
10
|
+
"types": "./dist/types/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./jest-preset": "./jest-preset.js",
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
8
17
|
"types": "./dist/types/index.d.ts",
|
|
9
18
|
"files": [
|
|
10
|
-
"dist
|
|
11
|
-
"dist/esm/**",
|
|
12
|
-
"dist/types/**",
|
|
19
|
+
"dist",
|
|
13
20
|
"jest-preset.js"
|
|
14
21
|
],
|
|
15
22
|
"scripts": {
|
|
@@ -22,41 +29,46 @@
|
|
|
22
29
|
"lint:ci": "yarn lint",
|
|
23
30
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
|
|
24
31
|
"lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-jest",
|
|
25
|
-
"build": "
|
|
26
|
-
"build:source": "yarn build:esm && yarn build:cjs",
|
|
32
|
+
"build": "tsup --clean && yarn build:types",
|
|
27
33
|
"build:types": "tsc --project tsconfig.build.json",
|
|
28
|
-
"build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
|
|
29
|
-
"build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
|
|
30
|
-
"build:clean": "yarn clean && yarn build",
|
|
31
34
|
"clean": "rimraf '*.tsbuildinfo' 'dist'",
|
|
32
35
|
"publish:preview": "yarn npm publish --tag preview",
|
|
33
|
-
"lint:dependencies": "depcheck"
|
|
36
|
+
"lint:dependencies": "depcheck",
|
|
37
|
+
"build:ci": "tsup --clean"
|
|
34
38
|
},
|
|
35
39
|
"dependencies": {
|
|
36
40
|
"@jest/environment": "^29.5.0",
|
|
37
41
|
"@jest/expect": "^29.5.0",
|
|
38
42
|
"@jest/globals": "^29.5.0",
|
|
39
|
-
"@metamask/
|
|
40
|
-
"@metamask/
|
|
41
|
-
"@metamask/
|
|
42
|
-
"@metamask/
|
|
43
|
-
"@metamask/
|
|
43
|
+
"@metamask/base-controller": "^4.1.0",
|
|
44
|
+
"@metamask/eth-json-rpc-middleware": "^12.1.0",
|
|
45
|
+
"@metamask/json-rpc-engine": "^7.3.2",
|
|
46
|
+
"@metamask/json-rpc-middleware-stream": "^6.0.2",
|
|
47
|
+
"@metamask/key-tree": "^9.0.0",
|
|
48
|
+
"@metamask/permission-controller": "^8.0.1",
|
|
49
|
+
"@metamask/snaps-controllers": "^6.0.0",
|
|
50
|
+
"@metamask/snaps-execution-environments": "^5.0.0",
|
|
51
|
+
"@metamask/snaps-rpc-methods": "^7.0.0",
|
|
52
|
+
"@metamask/snaps-sdk": "^3.0.0",
|
|
53
|
+
"@metamask/snaps-utils": "^7.0.0",
|
|
54
|
+
"@metamask/utils": "^8.3.0",
|
|
55
|
+
"@reduxjs/toolkit": "^1.9.5",
|
|
44
56
|
"express": "^4.18.2",
|
|
45
57
|
"jest-environment-node": "^29.5.0",
|
|
46
58
|
"jest-matcher-utils": "^29.5.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
59
|
+
"readable-stream": "^3.6.2",
|
|
60
|
+
"redux": "^4.2.1",
|
|
61
|
+
"redux-saga": "^1.2.3",
|
|
62
|
+
"superstruct": "^1.0.3"
|
|
51
63
|
},
|
|
52
64
|
"devDependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
65
|
+
"@jest/types": "^29.6.3",
|
|
66
|
+
"@lavamoat/allow-scripts": "^3.0.2",
|
|
67
|
+
"@metamask/auto-changelog": "^3.4.4",
|
|
55
68
|
"@metamask/eslint-config": "^12.1.0",
|
|
56
69
|
"@metamask/eslint-config-jest": "^12.1.0",
|
|
57
70
|
"@metamask/eslint-config-nodejs": "^12.1.0",
|
|
58
71
|
"@metamask/eslint-config-typescript": "^12.1.0",
|
|
59
|
-
"@swc/cli": "^0.1.62",
|
|
60
72
|
"@swc/core": "1.3.78",
|
|
61
73
|
"@swc/jest": "^0.2.26",
|
|
62
74
|
"@types/jest": "^27.5.1",
|
|
@@ -78,6 +90,7 @@
|
|
|
78
90
|
"prettier": "^2.7.1",
|
|
79
91
|
"prettier-plugin-packagejson": "^2.2.11",
|
|
80
92
|
"rimraf": "^4.1.2",
|
|
93
|
+
"tsup": "^8.0.1",
|
|
81
94
|
"typescript": "~4.8.4"
|
|
82
95
|
},
|
|
83
96
|
"engines": {
|
package/dist/cjs/environment.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
SnapsEnvironment: function() {
|
|
13
|
-
return SnapsEnvironment;
|
|
14
|
-
},
|
|
15
|
-
default: function() {
|
|
16
|
-
return _default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _utils = require("@metamask/utils");
|
|
20
|
-
const _jestenvironmentnode = /*#__PURE__*/ _interop_require_default(require("jest-environment-node"));
|
|
21
|
-
const _webdriverio = require("webdriverio");
|
|
22
|
-
const _internals = require("./internals");
|
|
23
|
-
const _options = require("./options");
|
|
24
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
25
|
-
if (privateCollection.has(obj)) {
|
|
26
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
30
|
-
if (descriptor.get) {
|
|
31
|
-
return descriptor.get.call(receiver);
|
|
32
|
-
}
|
|
33
|
-
return descriptor.value;
|
|
34
|
-
}
|
|
35
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
36
|
-
if (descriptor.set) {
|
|
37
|
-
descriptor.set.call(receiver, value);
|
|
38
|
-
} else {
|
|
39
|
-
if (!descriptor.writable) {
|
|
40
|
-
throw new TypeError("attempted to set read only private field");
|
|
41
|
-
}
|
|
42
|
-
descriptor.value = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
46
|
-
if (!privateMap.has(receiver)) {
|
|
47
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
48
|
-
}
|
|
49
|
-
return privateMap.get(receiver);
|
|
50
|
-
}
|
|
51
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
52
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
53
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
54
|
-
}
|
|
55
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
56
|
-
_check_private_redeclaration(obj, privateMap);
|
|
57
|
-
privateMap.set(obj, value);
|
|
58
|
-
}
|
|
59
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
60
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
61
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
62
|
-
return value;
|
|
63
|
-
}
|
|
64
|
-
function _define_property(obj, key, value) {
|
|
65
|
-
if (key in obj) {
|
|
66
|
-
Object.defineProperty(obj, key, {
|
|
67
|
-
value: value,
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
obj[key] = value;
|
|
74
|
-
}
|
|
75
|
-
return obj;
|
|
76
|
-
}
|
|
77
|
-
function _interop_require_default(obj) {
|
|
78
|
-
return obj && obj.__esModule ? obj : {
|
|
79
|
-
default: obj
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/* eslint-enable */ const log = (0, _utils.createModuleLogger)(_internals.rootLogger, 'environment');
|
|
83
|
-
var _options1 = /*#__PURE__*/ new WeakMap(), _server = /*#__PURE__*/ new WeakMap();
|
|
84
|
-
class SnapsEnvironment extends _jestenvironmentnode.default {
|
|
85
|
-
/**
|
|
86
|
-
* Set up the environment. This starts the built-in HTTP server, and creates a
|
|
87
|
-
* new browser instance.
|
|
88
|
-
*/ async setup() {
|
|
89
|
-
await super.setup();
|
|
90
|
-
if (_class_private_field_get(this, _options1).server.enabled) {
|
|
91
|
-
log('Starting server.');
|
|
92
|
-
_class_private_field_set(this, _server, await (0, _internals.startServer)(_class_private_field_get(this, _options1).server));
|
|
93
|
-
}
|
|
94
|
-
const args = [];
|
|
95
|
-
if (_class_private_field_get(this, _options1).browser.headless) {
|
|
96
|
-
args.push('--headless', '--disable-gpu');
|
|
97
|
-
}
|
|
98
|
-
log('Starting browser.');
|
|
99
|
-
this.browser = await (0, _webdriverio.remote)({
|
|
100
|
-
logLevel: 'error',
|
|
101
|
-
capabilities: {
|
|
102
|
-
browserName: 'chrome',
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
104
|
-
'goog:chromeOptions': {
|
|
105
|
-
args
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
this.global.browser = this.browser;
|
|
110
|
-
this.global.snapsEnvironment = this;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Tear down the environment. This closes the browser, and stops the built-in
|
|
114
|
-
* HTTP server.
|
|
115
|
-
*/ async teardown() {
|
|
116
|
-
if (_class_private_field_get(this, _options1).keepAlive) {
|
|
117
|
-
log('Not tearing down environment because keepAlive is enabled.');
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
log('Closing browser, and stopping server.');
|
|
121
|
-
await this.browser?.deleteSession();
|
|
122
|
-
_class_private_field_get(this, _server)?.close();
|
|
123
|
-
await super.teardown();
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get the URL to the simulator, including the environment URL.
|
|
127
|
-
*
|
|
128
|
-
* @returns The simulator URL.
|
|
129
|
-
* @throws If the server is not running.
|
|
130
|
-
*/ get url() {
|
|
131
|
-
(0, _utils.assert)(_class_private_field_get(this, _server), 'Server is not running.');
|
|
132
|
-
const { port } = _class_private_field_get(this, _server).address();
|
|
133
|
-
const simulatorUrl = _class_private_field_get(this, _options1).simulatorUrl ?? `http://localhost:${port}/simulator/`;
|
|
134
|
-
const executionEnvironmentUrl = _class_private_field_get(this, _options1).executionEnvironmentUrl ?? `http://localhost:${port}/environment/`;
|
|
135
|
-
return `${simulatorUrl}?environment=${encodeURIComponent(executionEnvironmentUrl)}`;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Get the snap ID for the current environment, which is used if no snap ID is
|
|
139
|
-
* passed to {@link installSnap}. This assumes that the built-in server is
|
|
140
|
-
* running.
|
|
141
|
-
*
|
|
142
|
-
* @returns The snap ID.
|
|
143
|
-
* @throws If the server is not running.
|
|
144
|
-
*/ get snapId() {
|
|
145
|
-
(0, _utils.assert)(_class_private_field_get(this, _server), 'You must specify a snap ID, because the built-in server is not running.');
|
|
146
|
-
const { port } = _class_private_field_get(this, _server).address();
|
|
147
|
-
return `local:http://localhost:${port}`;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Create a new page, and attach logging handlers.
|
|
151
|
-
*
|
|
152
|
-
* @param url - The page URL. Defaults to the specified Snaps Simulator URL,
|
|
153
|
-
* or the default simulator URL if none is specified.
|
|
154
|
-
* @param timeout - The page timeout, in milliseconds.
|
|
155
|
-
* @returns The new page.
|
|
156
|
-
*/ async createPage(url = this.url, timeout = 10000) {
|
|
157
|
-
const puppeteer = await this.browser.getPuppeteer();
|
|
158
|
-
const page = await puppeteer.newPage();
|
|
159
|
-
page.setDefaultTimeout(timeout);
|
|
160
|
-
page.setDefaultNavigationTimeout(timeout);
|
|
161
|
-
// Give the page permission to show notifications. This is required for
|
|
162
|
-
// testing `snap_notify`.
|
|
163
|
-
await page.browserContext().overridePermissions(url, [
|
|
164
|
-
'notifications'
|
|
165
|
-
]);
|
|
166
|
-
// `networkidle0` is used to ensure that the page is fully loaded. This
|
|
167
|
-
// makes it wait for no requests to be made, which guarantees that the page
|
|
168
|
-
// is ready.
|
|
169
|
-
await page.goto(url, {
|
|
170
|
-
waitUntil: 'networkidle0'
|
|
171
|
-
});
|
|
172
|
-
const browserLog = (0, _utils.createModuleLogger)(_internals.rootLogger, 'browser');
|
|
173
|
-
page// This is fired when the page calls `console.log` or similar.
|
|
174
|
-
.on('console', (message)=>{
|
|
175
|
-
browserLog(`[${message.type()}] ${message.text()}`);
|
|
176
|
-
})// This is fired when the page throws an error.
|
|
177
|
-
.on('pageerror', ({ message })=>{
|
|
178
|
-
browserLog(`[page error] ${message}`);
|
|
179
|
-
});
|
|
180
|
-
return page;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Constructor.
|
|
184
|
-
*
|
|
185
|
-
* @param options - The environment options.
|
|
186
|
-
* @param context - The environment context.
|
|
187
|
-
*/ constructor(options, context){
|
|
188
|
-
super(options, context);
|
|
189
|
-
// `browser` is always set in the environment setup function. To avoid needing
|
|
190
|
-
// to check for `undefined` everywhere, we use a type assertion here.
|
|
191
|
-
_define_property(this, "browser", void 0);
|
|
192
|
-
_class_private_field_init(this, _options1, {
|
|
193
|
-
writable: true,
|
|
194
|
-
value: void 0
|
|
195
|
-
});
|
|
196
|
-
_class_private_field_init(this, _server, {
|
|
197
|
-
writable: true,
|
|
198
|
-
value: void 0
|
|
199
|
-
});
|
|
200
|
-
_class_private_field_set(this, _options1, (0, _options.getOptions)(options.projectConfig.testEnvironmentOptions));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
const _default = SnapsEnvironment;
|
|
204
|
-
|
|
205
|
-
//# sourceMappingURL=environment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/environment.ts"],"sourcesContent":["import type {\n EnvironmentContext,\n JestEnvironmentConfig,\n} from '@jest/environment';\nimport { assert, createModuleLogger } from '@metamask/utils';\nimport type { Server } from 'http';\nimport NodeEnvironment from 'jest-environment-node';\nimport type { AddressInfo } from 'net';\nimport type { Browser } from 'puppeteer';\nimport { remote } from 'webdriverio';\n\nimport { rootLogger, startServer } from './internals';\nimport type { SnapsEnvironmentOptions } from './options';\nimport { getOptions } from './options';\n\n/* eslint-disable */\ndeclare global {\n const browser: WebdriverIO.Browser;\n const snapsEnvironment: SnapsEnvironment;\n}\n/* eslint-enable */\n\nconst log = createModuleLogger(rootLogger, 'environment');\n\nexport class SnapsEnvironment extends NodeEnvironment {\n // `browser` is always set in the environment setup function. To avoid needing\n // to check for `undefined` everywhere, we use a type assertion here.\n browser!: WebdriverIO.Browser;\n\n #options: SnapsEnvironmentOptions;\n\n #server: Server | undefined;\n\n /**\n * Constructor.\n *\n * @param options - The environment options.\n * @param context - The environment context.\n */\n constructor(options: JestEnvironmentConfig, context: EnvironmentContext) {\n super(options, context);\n this.#options = getOptions(options.projectConfig.testEnvironmentOptions);\n }\n\n /**\n * Set up the environment. This starts the built-in HTTP server, and creates a\n * new browser instance.\n */\n async setup() {\n await super.setup();\n\n if (this.#options.server.enabled) {\n log('Starting server.');\n this.#server = await startServer(this.#options.server);\n }\n\n const args = [];\n if (this.#options.browser.headless) {\n args.push('--headless', '--disable-gpu');\n }\n\n log('Starting browser.');\n this.browser = await remote({\n logLevel: 'error',\n capabilities: {\n browserName: 'chrome',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n 'goog:chromeOptions': {\n args,\n },\n },\n });\n\n this.global.browser = this.browser;\n this.global.snapsEnvironment = this;\n }\n\n /**\n * Tear down the environment. This closes the browser, and stops the built-in\n * HTTP server.\n */\n async teardown() {\n if (this.#options.keepAlive) {\n log('Not tearing down environment because keepAlive is enabled.');\n return;\n }\n\n log('Closing browser, and stopping server.');\n await this.browser?.deleteSession();\n this.#server?.close();\n\n await super.teardown();\n }\n\n /**\n * Get the URL to the simulator, including the environment URL.\n *\n * @returns The simulator URL.\n * @throws If the server is not running.\n */\n get url() {\n assert(this.#server, 'Server is not running.');\n\n const { port } = this.#server.address() as AddressInfo;\n const simulatorUrl =\n this.#options.simulatorUrl ?? `http://localhost:${port}/simulator/`;\n\n const executionEnvironmentUrl =\n this.#options.executionEnvironmentUrl ??\n `http://localhost:${port}/environment/`;\n\n return `${simulatorUrl}?environment=${encodeURIComponent(\n executionEnvironmentUrl,\n )}`;\n }\n\n /**\n * Get the snap ID for the current environment, which is used if no snap ID is\n * passed to {@link installSnap}. This assumes that the built-in server is\n * running.\n *\n * @returns The snap ID.\n * @throws If the server is not running.\n */\n get snapId() {\n assert(\n this.#server,\n 'You must specify a snap ID, because the built-in server is not running.',\n );\n\n const { port } = this.#server.address() as AddressInfo;\n return `local:http://localhost:${port}`;\n }\n\n /**\n * Create a new page, and attach logging handlers.\n *\n * @param url - The page URL. Defaults to the specified Snaps Simulator URL,\n * or the default simulator URL if none is specified.\n * @param timeout - The page timeout, in milliseconds.\n * @returns The new page.\n */\n async createPage(url: string = this.url, timeout = 10000) {\n const puppeteer = (await this.browser.getPuppeteer()) as unknown as Browser;\n const page = await puppeteer.newPage();\n\n page.setDefaultTimeout(timeout);\n page.setDefaultNavigationTimeout(timeout);\n\n // Give the page permission to show notifications. This is required for\n // testing `snap_notify`.\n await page.browserContext().overridePermissions(url, ['notifications']);\n\n // `networkidle0` is used to ensure that the page is fully loaded. This\n // makes it wait for no requests to be made, which guarantees that the page\n // is ready.\n await page.goto(url, { waitUntil: 'networkidle0' });\n\n const browserLog = createModuleLogger(rootLogger, 'browser');\n\n page\n // This is fired when the page calls `console.log` or similar.\n .on('console', (message) => {\n browserLog(`[${message.type()}] ${message.text()}`);\n })\n\n // This is fired when the page throws an error.\n .on('pageerror', ({ message }) => {\n browserLog(`[page error] ${message}`);\n });\n\n return page;\n }\n}\n\nexport default SnapsEnvironment;\n"],"names":["SnapsEnvironment","log","createModuleLogger","rootLogger","NodeEnvironment","setup","options","server","enabled","startServer","args","browser","headless","push","remote","logLevel","capabilities","browserName","global","snapsEnvironment","teardown","keepAlive","deleteSession","close","url","assert","port","address","simulatorUrl","executionEnvironmentUrl","encodeURIComponent","snapId","createPage","timeout","puppeteer","getPuppeteer","page","newPage","setDefaultTimeout","setDefaultNavigationTimeout","browserContext","overridePermissions","goto","waitUntil","browserLog","on","message","type","text","constructor","context","getOptions","projectConfig","testEnvironmentOptions"],"mappings":";;;;;;;;;;;IAwBaA,gBAAgB;eAAhBA;;IAuJb,OAAgC;eAAhC;;;uBA3K2C;4EAEf;6BAGL;2BAEiB;yBAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO3B,iBAAiB,GAEjB,MAAMC,MAAMC,IAAAA,yBAAkB,EAACC,qBAAU,EAAE;IAOzC,yCAEA;AAPK,MAAMH,yBAAyBI,4BAAe;IAoBnD;;;GAGC,GACD,MAAMC,QAAQ;QACZ,MAAM,KAAK,CAACA;QAEZ,IAAI,yBAAA,IAAI,EAAEC,WAAQC,MAAM,CAACC,OAAO,EAAE;YAChCP,IAAI;2CACEM,SAAS,MAAME,IAAAA,sBAAW,EAAC,yBAAA,IAAI,EAAEH,WAAQC,MAAM;QACvD;QAEA,MAAMG,OAAO,EAAE;QACf,IAAI,yBAAA,IAAI,EAAEJ,WAAQK,OAAO,CAACC,QAAQ,EAAE;YAClCF,KAAKG,IAAI,CAAC,cAAc;QAC1B;QAEAZ,IAAI;QACJ,IAAI,CAACU,OAAO,GAAG,MAAMG,IAAAA,mBAAM,EAAC;YAC1BC,UAAU;YACVC,cAAc;gBACZC,aAAa;gBACb,gEAAgE;gBAChE,sBAAsB;oBACpBP;gBACF;YACF;QACF;QAEA,IAAI,CAACQ,MAAM,CAACP,OAAO,GAAG,IAAI,CAACA,OAAO;QAClC,IAAI,CAACO,MAAM,CAACC,gBAAgB,GAAG,IAAI;IACrC;IAEA;;;GAGC,GACD,MAAMC,WAAW;QACf,IAAI,yBAAA,IAAI,EAAEd,WAAQe,SAAS,EAAE;YAC3BpB,IAAI;YACJ;QACF;QAEAA,IAAI;QACJ,MAAM,IAAI,CAACU,OAAO,EAAEW;iCACpB,IAAI,EAAEf,UAAQgB;QAEd,MAAM,KAAK,CAACH;IACd;IAEA;;;;;GAKC,GACD,IAAII,MAAM;QACRC,IAAAA,aAAM,2BAAC,IAAI,EAAElB,UAAQ;QAErB,MAAM,EAAEmB,IAAI,EAAE,GAAG,yBAAA,IAAI,EAAEnB,SAAOoB,OAAO;QACrC,MAAMC,eACJ,yBAAA,IAAI,EAAEtB,WAAQsB,YAAY,IAAI,CAAC,iBAAiB,EAAEF,KAAK,WAAW,CAAC;QAErE,MAAMG,0BACJ,yBAAA,IAAI,EAAEvB,WAAQuB,uBAAuB,IACrC,CAAC,iBAAiB,EAAEH,KAAK,aAAa,CAAC;QAEzC,OAAO,CAAC,EAAEE,aAAa,aAAa,EAAEE,mBACpCD,yBACA,CAAC;IACL;IAEA;;;;;;;GAOC,GACD,IAAIE,SAAS;QACXN,IAAAA,aAAM,2BACJ,IAAI,EAAElB,UACN;QAGF,MAAM,EAAEmB,IAAI,EAAE,GAAG,yBAAA,IAAI,EAAEnB,SAAOoB,OAAO;QACrC,OAAO,CAAC,uBAAuB,EAAED,KAAK,CAAC;IACzC;IAEA;;;;;;;GAOC,GACD,MAAMM,WAAWR,MAAc,IAAI,CAACA,GAAG,EAAES,UAAU,KAAK,EAAE;QACxD,MAAMC,YAAa,MAAM,IAAI,CAACvB,OAAO,CAACwB,YAAY;QAClD,MAAMC,OAAO,MAAMF,UAAUG,OAAO;QAEpCD,KAAKE,iBAAiB,CAACL;QACvBG,KAAKG,2BAA2B,CAACN;QAEjC,uEAAuE;QACvE,yBAAyB;QACzB,MAAMG,KAAKI,cAAc,GAAGC,mBAAmB,CAACjB,KAAK;YAAC;SAAgB;QAEtE,uEAAuE;QACvE,2EAA2E;QAC3E,YAAY;QACZ,MAAMY,KAAKM,IAAI,CAAClB,KAAK;YAAEmB,WAAW;QAAe;QAEjD,MAAMC,aAAa1C,IAAAA,yBAAkB,EAACC,qBAAU,EAAE;QAElDiC,IACE,8DAA8D;SAC7DS,EAAE,CAAC,WAAW,CAACC;YACdF,WAAW,CAAC,CAAC,EAAEE,QAAQC,IAAI,GAAG,EAAE,EAAED,QAAQE,IAAI,GAAG,CAAC;QACpD,EAEA,+CAA+C;SAC9CH,EAAE,CAAC,aAAa,CAAC,EAAEC,OAAO,EAAE;YAC3BF,WAAW,CAAC,aAAa,EAAEE,QAAQ,CAAC;QACtC;QAEF,OAAOV;IACT;IA3IA;;;;;GAKC,GACDa,YAAY3C,OAA8B,EAAE4C,OAA2B,CAAE;QACvE,KAAK,CAAC5C,SAAS4C;QAfjB,8EAA8E;QAC9E,qEAAqE;QACrEvC,uBAAAA,WAAAA,KAAAA;QAEA,gCAAA;;mBAAA,KAAA;;QAEA,gCAAA;;mBAAA,KAAA;;uCAUQL,WAAU6C,IAAAA,mBAAU,EAAC7C,QAAQ8C,aAAa,CAACC,sBAAsB;IACzE;AAmIF;MAEA,WAAerD"}
|
package/dist/cjs/helpers.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "installSnap", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return installSnap;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _utils = require("@metamask/utils");
|
|
12
|
-
const _pptrtestinglibrary = require("pptr-testing-library");
|
|
13
|
-
const _internals = require("./internals");
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
15
|
-
const { getByTestId } = _pptrtestinglibrary.queries;
|
|
16
|
-
const log = (0, _utils.createModuleLogger)(_internals.rootLogger, 'helpers');
|
|
17
|
-
async function installSnap(snapId = (0, _internals.getEnvironment)().snapId) {
|
|
18
|
-
const environment = (0, _internals.getEnvironment)();
|
|
19
|
-
log('Installing snap %s.', snapId);
|
|
20
|
-
const page = await environment.createPage();
|
|
21
|
-
const document = await (0, _pptrtestinglibrary.getDocument)(page);
|
|
22
|
-
log('Setting snap ID to %s.', snapId);
|
|
23
|
-
await page.evaluate((payload)=>{
|
|
24
|
-
window.__SIMULATOR_API__.dispatch({
|
|
25
|
-
type: 'configuration/setSnapId',
|
|
26
|
-
payload
|
|
27
|
-
});
|
|
28
|
-
}, snapId);
|
|
29
|
-
log('Waiting for snap to install.');
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
31
|
-
await (0, _internals.waitFor)(async ()=>await getByTestId(document, 'status-ok'), {
|
|
32
|
-
timeout: 10000,
|
|
33
|
-
message: `Timed out waiting for snap to install. Make sure the snap ID ("${snapId}") is correct, and the server is running.`
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
request: (options)=>{
|
|
37
|
-
log('Sending request %o.', options);
|
|
38
|
-
// Note: This function is intentionally not async, so that we can access
|
|
39
|
-
// the `getInterface` method on the response.
|
|
40
|
-
return (0, _internals.request)(page, options);
|
|
41
|
-
},
|
|
42
|
-
sendTransaction: async (options = {})=>{
|
|
43
|
-
log('Sending transaction %o.', options);
|
|
44
|
-
return await (0, _internals.sendTransaction)(page, options);
|
|
45
|
-
},
|
|
46
|
-
runCronjob: (options)=>{
|
|
47
|
-
log('Running cronjob %o.', options);
|
|
48
|
-
// Note: This function is intentionally not async, so that we can access
|
|
49
|
-
// the `getInterface` method on the response.
|
|
50
|
-
return (0, _internals.runCronjob)(page, options);
|
|
51
|
-
},
|
|
52
|
-
close: async ()=>{
|
|
53
|
-
log('Closing page.');
|
|
54
|
-
await page.close();
|
|
55
|
-
},
|
|
56
|
-
mock: async (options)=>{
|
|
57
|
-
log('Mocking %o.', options);
|
|
58
|
-
return await (0, _internals.mock)(page, options);
|
|
59
|
-
},
|
|
60
|
-
mockJsonRpc: async (options)=>{
|
|
61
|
-
log('Mocking JSON-RPC %o.', options);
|
|
62
|
-
return await (0, _internals.mockJsonRpc)(page, options);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=helpers.js.map
|
package/dist/cjs/helpers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/helpers.ts"],"sourcesContent":["import { createModuleLogger } from '@metamask/utils';\nimport { getDocument, queries } from 'pptr-testing-library';\n\nimport {\n getEnvironment,\n mock,\n waitFor,\n request,\n sendTransaction,\n runCronjob,\n mockJsonRpc,\n rootLogger,\n} from './internals';\nimport type { Snap, SnapResponse } from './types';\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { getByTestId } = queries;\n\nconst log = createModuleLogger(rootLogger, 'helpers');\n\n/**\n * Load a snap into the environment. This is the main entry point for testing\n * snaps: It returns a {@link Snap} object that can be used to interact with the\n * snap.\n *\n * @example\n * ```ts\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * describe('My Snap', () => {\n * it('should do something', async () => {\n * const { request } = await installSnap('local:my-snap');\n * const response = await request({\n * method: 'foo',\n * params: ['bar'],\n * });\n * expect(response).toRespondWith('bar');\n * });\n * });\n * ```\n * @param snapId - The ID of the snap, including the prefix (`local:`). Defaults\n * to the URL of the built-in server, if it is running. This supports both\n * local snap IDs and NPM snap IDs.\n * @returns The snap.\n * @throws If the built-in server is not running, and no snap ID is provided.\n */\nexport async function installSnap(\n snapId: string = getEnvironment().snapId,\n): Promise<Snap> {\n const environment = getEnvironment();\n\n log('Installing snap %s.', snapId);\n\n const page = await environment.createPage();\n const document = await getDocument(page);\n\n log('Setting snap ID to %s.', snapId);\n await page.evaluate((payload) => {\n window.__SIMULATOR_API__.dispatch({\n type: 'configuration/setSnapId',\n payload,\n });\n }, snapId);\n\n log('Waiting for snap to install.');\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n await waitFor(async () => await getByTestId(document, 'status-ok'), {\n timeout: 10000,\n message: `Timed out waiting for snap to install. Make sure the snap ID (\"${snapId}\") is correct, and the server is running.`,\n });\n\n return {\n request: (options) => {\n log('Sending request %o.', options);\n\n // Note: This function is intentionally not async, so that we can access\n // the `getInterface` method on the response.\n return request(page, options);\n },\n\n sendTransaction: async (options = {}): Promise<SnapResponse> => {\n log('Sending transaction %o.', options);\n\n return await sendTransaction(page, options);\n },\n\n runCronjob: (options) => {\n log('Running cronjob %o.', options);\n\n // Note: This function is intentionally not async, so that we can access\n // the `getInterface` method on the response.\n return runCronjob(page, options);\n },\n\n close: async () => {\n log('Closing page.');\n\n await page.close();\n },\n\n mock: async (options) => {\n log('Mocking %o.', options);\n\n return await mock(page, options);\n },\n\n mockJsonRpc: async (options) => {\n log('Mocking JSON-RPC %o.', options);\n\n return await mockJsonRpc(page, options);\n },\n };\n}\n"],"names":["installSnap","getByTestId","queries","log","createModuleLogger","rootLogger","snapId","getEnvironment","environment","page","createPage","document","getDocument","evaluate","payload","window","__SIMULATOR_API__","dispatch","type","waitFor","timeout","message","request","options","sendTransaction","runCronjob","close","mock","mockJsonRpc"],"mappings":";;;;+BA8CsBA;;;eAAAA;;;uBA9Ca;oCACE;2BAW9B;AAGP,6DAA6D;AAC7D,MAAM,EAAEC,WAAW,EAAE,GAAGC,2BAAO;AAE/B,MAAMC,MAAMC,IAAAA,yBAAkB,EAACC,qBAAU,EAAE;AA4BpC,eAAeL,YACpBM,SAAiBC,IAAAA,yBAAc,IAAGD,MAAM;IAExC,MAAME,cAAcD,IAAAA,yBAAc;IAElCJ,IAAI,uBAAuBG;IAE3B,MAAMG,OAAO,MAAMD,YAAYE,UAAU;IACzC,MAAMC,WAAW,MAAMC,IAAAA,+BAAW,EAACH;IAEnCN,IAAI,0BAA0BG;IAC9B,MAAMG,KAAKI,QAAQ,CAAC,CAACC;QACnBC,OAAOC,iBAAiB,CAACC,QAAQ,CAAC;YAChCC,MAAM;YACNJ;QACF;IACF,GAAGR;IAEHH,IAAI;IACJ,kEAAkE;IAClE,MAAMgB,IAAAA,kBAAO,EAAC,UAAY,MAAMlB,YAAYU,UAAU,cAAc;QAClES,SAAS;QACTC,SAAS,CAAC,+DAA+D,EAAEf,OAAO,yCAAyC,CAAC;IAC9H;IAEA,OAAO;QACLgB,SAAS,CAACC;YACRpB,IAAI,uBAAuBoB;YAE3B,wEAAwE;YACxE,6CAA6C;YAC7C,OAAOD,IAAAA,kBAAO,EAACb,MAAMc;QACvB;QAEAC,iBAAiB,OAAOD,UAAU,CAAC,CAAC;YAClCpB,IAAI,2BAA2BoB;YAE/B,OAAO,MAAMC,IAAAA,0BAAe,EAACf,MAAMc;QACrC;QAEAE,YAAY,CAACF;YACXpB,IAAI,uBAAuBoB;YAE3B,wEAAwE;YACxE,6CAA6C;YAC7C,OAAOE,IAAAA,qBAAU,EAAChB,MAAMc;QAC1B;QAEAG,OAAO;YACLvB,IAAI;YAEJ,MAAMM,KAAKiB,KAAK;QAClB;QAEAC,MAAM,OAAOJ;YACXpB,IAAI,eAAeoB;YAEnB,OAAO,MAAMI,IAAAA,eAAI,EAAClB,MAAMc;QAC1B;QAEAK,aAAa,OAAOL;YAClBpB,IAAI,wBAAwBoB;YAE5B,OAAO,MAAMK,IAAAA,sBAAW,EAACnB,MAAMc;QACjC;IACF;AACF"}
|