@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
|
@@ -1,122 +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
|
-
TransactionOptionsStruct: function() {
|
|
13
|
-
return TransactionOptionsStruct;
|
|
14
|
-
},
|
|
15
|
-
SnapOptionsStruct: function() {
|
|
16
|
-
return SnapOptionsStruct;
|
|
17
|
-
},
|
|
18
|
-
InterfaceStruct: function() {
|
|
19
|
-
return InterfaceStruct;
|
|
20
|
-
},
|
|
21
|
-
SnapResponseStruct: function() {
|
|
22
|
-
return SnapResponseStruct;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const _snapssdk = require("@metamask/snaps-sdk");
|
|
26
|
-
const _utils = require("@metamask/utils");
|
|
27
|
-
const _crypto = require("crypto");
|
|
28
|
-
const _superstruct = require("superstruct");
|
|
29
|
-
// TODO: Export this from `@metamask/utils` instead.
|
|
30
|
-
const BytesLikeStruct = (0, _superstruct.union)([
|
|
31
|
-
(0, _superstruct.bigint)(),
|
|
32
|
-
(0, _superstruct.number)(),
|
|
33
|
-
(0, _superstruct.string)(),
|
|
34
|
-
(0, _superstruct.instance)(Uint8Array)
|
|
35
|
-
]);
|
|
36
|
-
const TransactionOptionsStruct = (0, _superstruct.object)({
|
|
37
|
-
/**
|
|
38
|
-
* The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.
|
|
39
|
-
*/ chainId: (0, _superstruct.defaulted)((0, _superstruct.string)(), 'eip155:1'),
|
|
40
|
-
/**
|
|
41
|
-
* The origin to send the transaction from. Defaults to `metamask.io`.
|
|
42
|
-
*/ origin: (0, _superstruct.defaulted)((0, _superstruct.string)(), 'metamask.io'),
|
|
43
|
-
/**
|
|
44
|
-
* The address to send the transaction from. Defaults to a randomly generated
|
|
45
|
-
* address.
|
|
46
|
-
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
47
|
-
from: (0, _superstruct.coerce)(_utils.StrictHexStruct, (0, _superstruct.optional)(BytesLikeStruct), (value)=>{
|
|
48
|
-
if (value) {
|
|
49
|
-
return (0, _utils.bytesToHex)((0, _utils.valueToBytes)(value));
|
|
50
|
-
}
|
|
51
|
-
return (0, _utils.bytesToHex)((0, _crypto.randomBytes)(20));
|
|
52
|
-
}),
|
|
53
|
-
/**
|
|
54
|
-
* The address to send the transaction to. Defaults to a randomly generated
|
|
55
|
-
* address.
|
|
56
|
-
*/ // TODO: Move this coercer to `@metamask/utils`.
|
|
57
|
-
to: (0, _superstruct.coerce)(_utils.StrictHexStruct, (0, _superstruct.optional)(BytesLikeStruct), (value)=>{
|
|
58
|
-
if (value) {
|
|
59
|
-
return (0, _utils.bytesToHex)((0, _utils.valueToBytes)(value));
|
|
60
|
-
}
|
|
61
|
-
return (0, _utils.bytesToHex)((0, _crypto.randomBytes)(20));
|
|
62
|
-
}),
|
|
63
|
-
/**
|
|
64
|
-
* The value to send with the transaction. The value may be specified as a
|
|
65
|
-
* `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
|
|
66
|
-
*/ value: (0, _superstruct.defaulted)((0, _superstruct.coerce)(_utils.StrictHexStruct, BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), '0x0'),
|
|
67
|
-
/**
|
|
68
|
-
* The gas limit to use for the transaction. The gas limit may be specified
|
|
69
|
-
* as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.
|
|
70
|
-
*/ gasLimit: (0, _superstruct.defaulted)((0, _superstruct.coerce)(_utils.StrictHexStruct, BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), (0, _utils.valueToBytes)(21000)),
|
|
71
|
-
/**
|
|
72
|
-
* The max fee per gas (in Wei) to use for the transaction. The max fee per
|
|
73
|
-
* gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.
|
|
74
|
-
* Defaults to `1`.
|
|
75
|
-
*/ maxFeePerGas: (0, _superstruct.defaulted)((0, _superstruct.coerce)(_utils.StrictHexStruct, BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), (0, _utils.valueToBytes)(1)),
|
|
76
|
-
/**
|
|
77
|
-
* The max priority fee per gas (in Wei) to use for the transaction. The max
|
|
78
|
-
* priority fee per gas may be specified as a `number`, `bigint`, `string`,
|
|
79
|
-
* or `Uint8Array`. Defaults to `1`.
|
|
80
|
-
*/ maxPriorityFeePerGas: (0, _superstruct.defaulted)((0, _superstruct.coerce)(_utils.StrictHexStruct, BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), (0, _utils.valueToBytes)(1)),
|
|
81
|
-
/**
|
|
82
|
-
* The nonce to use for the transaction. The nonce may be specified as a
|
|
83
|
-
* `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.
|
|
84
|
-
*/ nonce: (0, _superstruct.defaulted)((0, _superstruct.coerce)(_utils.StrictHexStruct, BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), (0, _utils.valueToBytes)(0)),
|
|
85
|
-
/**
|
|
86
|
-
* The data to send with the transaction. The data may be specified as a
|
|
87
|
-
* `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.
|
|
88
|
-
*/ data: (0, _superstruct.defaulted)((0, _superstruct.coerce)((0, _superstruct.union)([
|
|
89
|
-
_utils.StrictHexStruct,
|
|
90
|
-
(0, _superstruct.literal)('0x')
|
|
91
|
-
]), BytesLikeStruct, (value)=>(0, _utils.bytesToHex)((0, _utils.valueToBytes)(value))), '0x')
|
|
92
|
-
});
|
|
93
|
-
const SnapOptionsStruct = (0, _superstruct.object)({
|
|
94
|
-
/**
|
|
95
|
-
* The timeout in milliseconds to use for requests to the snap. Defaults to
|
|
96
|
-
* `1000`.
|
|
97
|
-
*/ timeout: (0, _superstruct.defaulted)((0, _superstruct.optional)((0, _superstruct.number)()), 1000)
|
|
98
|
-
});
|
|
99
|
-
const InterfaceStruct = (0, _superstruct.type)({
|
|
100
|
-
content: (0, _superstruct.optional)(_snapssdk.ComponentStruct)
|
|
101
|
-
});
|
|
102
|
-
const SnapResponseStruct = (0, _superstruct.assign)(InterfaceStruct, (0, _superstruct.object)({
|
|
103
|
-
id: (0, _superstruct.string)(),
|
|
104
|
-
response: (0, _superstruct.union)([
|
|
105
|
-
(0, _superstruct.object)({
|
|
106
|
-
result: _utils.JsonStruct
|
|
107
|
-
}),
|
|
108
|
-
(0, _superstruct.object)({
|
|
109
|
-
error: _utils.JsonStruct
|
|
110
|
-
})
|
|
111
|
-
]),
|
|
112
|
-
notifications: (0, _superstruct.array)((0, _superstruct.object)({
|
|
113
|
-
id: (0, _superstruct.string)(),
|
|
114
|
-
message: (0, _superstruct.string)(),
|
|
115
|
-
type: (0, _superstruct.union)([
|
|
116
|
-
(0, _snapssdk.enumValue)(_snapssdk.NotificationType.InApp),
|
|
117
|
-
(0, _snapssdk.enumValue)(_snapssdk.NotificationType.Native)
|
|
118
|
-
])
|
|
119
|
-
}))
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=structs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/structs.ts"],"sourcesContent":["import {\n NotificationType,\n ComponentStruct,\n enumValue,\n} from '@metamask/snaps-sdk';\nimport {\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n type,\n union,\n} from 'superstruct';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const InterfaceStruct = type({\n content: optional(ComponentStruct),\n});\n\nexport const SnapResponseStruct = assign(\n InterfaceStruct,\n object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n }),\n ),\n }),\n);\n"],"names":["TransactionOptionsStruct","SnapOptionsStruct","InterfaceStruct","SnapResponseStruct","BytesLikeStruct","union","bigint","number","string","instance","Uint8Array","object","chainId","defaulted","origin","from","coerce","StrictHexStruct","optional","value","bytesToHex","valueToBytes","randomBytes","to","gasLimit","maxFeePerGas","maxPriorityFeePerGas","nonce","data","literal","timeout","type","content","ComponentStruct","assign","id","response","result","JsonStruct","error","notifications","array","message","enumValue","NotificationType","InApp","Native"],"mappings":";;;;;;;;;;;IAoCaA,wBAAwB;eAAxBA;;IA0GAC,iBAAiB;eAAjBA;;IAQAC,eAAe;eAAfA;;IAIAC,kBAAkB;eAAlBA;;;0BAtJN;uBAMA;wBACqB;6BAerB;AAEP,oDAAoD;AACpD,MAAMC,kBAAkBC,IAAAA,kBAAK,EAAC;IAC5BC,IAAAA,mBAA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AAAA,kBAAK,EAAC;YACVsC,IAAAA,mBAAS,EAACC,0BAAgB,CAACC,KAAK;YAChCF,IAAAA,mBAAS,EAACC,0BAAgB,CAACE,MAAM;SAClC;IACH;AAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,63 +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
|
-
waitFor: function() {
|
|
13
|
-
return waitFor;
|
|
14
|
-
},
|
|
15
|
-
waitForResponse: function() {
|
|
16
|
-
return waitForResponse;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _utils = require("@metamask/utils");
|
|
20
|
-
const _pptrtestinglibrary = require("pptr-testing-library");
|
|
21
|
-
const _logger = require("./logger");
|
|
22
|
-
const log = (0, _utils.createModuleLogger)(_logger.rootLogger, 'wait-for');
|
|
23
|
-
async function waitFor(fn, { timeout = 3000, message } = {}) {
|
|
24
|
-
try {
|
|
25
|
-
let result;
|
|
26
|
-
await (0, _pptrtestinglibrary.waitFor)(// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
27
|
-
async ()=>{
|
|
28
|
-
// Puppeteer's `waitFor` function does not support returning a value
|
|
29
|
-
// from the condition function, so we need to use a variable outside
|
|
30
|
-
// the scope of the function.
|
|
31
|
-
result = await fn();
|
|
32
|
-
}, {
|
|
33
|
-
timeout
|
|
34
|
-
});
|
|
35
|
-
(0, _utils.assert)(result !== undefined);
|
|
36
|
-
return result;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (message) {
|
|
39
|
-
throw new Error(message);
|
|
40
|
-
}
|
|
41
|
-
throw error;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function waitForResponse(page, type) {
|
|
45
|
-
log('Waiting for response of type %s.', type);
|
|
46
|
-
return await page.evaluate(async (_type)=>{
|
|
47
|
-
return new Promise((resolve)=>{
|
|
48
|
-
window.__SIMULATOR_API__.dispatch({
|
|
49
|
-
type: `${_type}/clearResponse`
|
|
50
|
-
});
|
|
51
|
-
const unsubscribe = window.__SIMULATOR_API__.subscribe(()=>{
|
|
52
|
-
const state = window.__SIMULATOR_API__.getState();
|
|
53
|
-
const { pending, response } = state[_type];
|
|
54
|
-
if (!pending && response) {
|
|
55
|
-
unsubscribe();
|
|
56
|
-
resolve(response);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}, type);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=wait-for.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/internals/wait-for.ts"],"sourcesContent":["import type { HandlerType } from '@metamask/snaps-utils';\nimport { assert, createModuleLogger } from '@metamask/utils';\nimport { waitFor as waitForPuppeteer } from 'pptr-testing-library';\nimport type { Page } from 'puppeteer';\n\nimport type { SnapResponse } from '../types';\nimport { rootLogger } from './logger';\n\nexport type WaitForOptions = {\n /**\n * The timeout in milliseconds.\n */\n timeout?: number;\n\n /**\n * The error message to throw if the condition is not met.\n */\n message?: string;\n};\n\nconst log = createModuleLogger(rootLogger, 'wait-for');\n\n/**\n * Wait for a condition to be true. This is a wrapper around\n * `pptr-testing-library`'s `waitFor` function, with the addition of a custom\n * error message.\n *\n * @param fn - The condition to wait for.\n * @param options - The options.\n * @param options.timeout - The timeout in milliseconds.\n * @param options.message - The error message to throw if the condition is not\n * met.\n * @returns A promise that resolves when the condition is met. The promise\n * resolves to the return value of the condition function.\n */\nexport async function waitFor<Result>(\n fn: () => Promise<Result>,\n { timeout = 3000, message }: WaitForOptions = {},\n) {\n try {\n let result: Result | undefined;\n\n await waitForPuppeteer(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async () => {\n // Puppeteer's `waitFor` function does not support returning a value\n // from the condition function, so we need to use a variable outside\n // the scope of the function.\n result = await fn();\n },\n {\n timeout,\n },\n );\n\n assert(result !== undefined);\n return result;\n } catch (error) {\n if (message) {\n throw new Error(message);\n }\n\n throw error;\n }\n}\n\n/**\n * Wait for a JSON-RPC response.\n *\n * @param page - The page to wait for the response on.\n * @param type - The type of response to wait for.\n * @returns The JSON-RPC response.\n */\nexport async function waitForResponse(\n page: Page,\n type:\n | HandlerType.OnTransaction\n | HandlerType.OnRpcRequest\n | HandlerType.OnCronjob,\n) {\n log('Waiting for response of type %s.', type);\n\n return await page.evaluate(async (_type) => {\n return new Promise<SnapResponse['response']>((resolve) => {\n window.__SIMULATOR_API__.dispatch({\n type: `${_type}/clearResponse`,\n });\n\n const unsubscribe = window.__SIMULATOR_API__.subscribe(() => {\n const state = window.__SIMULATOR_API__.getState();\n const { pending, response } = state[_type];\n\n if (!pending && response) {\n unsubscribe();\n\n resolve(response);\n }\n });\n });\n }, type);\n}\n"],"names":["waitFor","waitForResponse","log","createModuleLogger","rootLogger","fn","timeout","message","result","waitForPuppeteer","assert","undefined","error","Error","page","type","evaluate","_type","Promise","resolve","window","__SIMULATOR_API__","dispatch","unsubscribe","subscribe","state","getState","pending","response"],"mappings":";;;;;;;;;;;IAmCsBA,OAAO;eAAPA;;IAsCAC,eAAe;eAAfA;;;uBAxEqB;oCACC;wBAIjB;AAc3B,MAAMC,MAAMC,IAAAA,yBAAkB,EAACC,kBAAU,EAAE;AAepC,eAAeJ,QACpBK,EAAyB,EACzB,EAAEC,UAAU,IAAI,EAAEC,OAAO,EAAkB,GAAG,CAAC,CAAC;IAEhD,IAAI;QACF,IAAIC;QAEJ,MAAMC,IAAAA,2BAAgB,EACpB,kEAAkE;QAClE;YACE,oEAAoE;YACpE,oEAAoE;YACpE,6BAA6B;YAC7BD,SAAS,MAAMH;QACjB,GACA;YACEC;QACF;QAGFI,IAAAA,aAAM,EAACF,WAAWG;QAClB,OAAOH;IACT,EAAE,OAAOI,OAAO;QACd,IAAIL,SAAS;YACX,MAAM,IAAIM,MAAMN;QAClB;QAEA,MAAMK;IACR;AACF;AASO,eAAeX,gBACpBa,IAAU,EACVC,IAGyB;IAEzBb,IAAI,oCAAoCa;IAExC,OAAO,MAAMD,KAAKE,QAAQ,CAAC,OAAOC;QAChC,OAAO,IAAIC,QAAkC,CAACC;YAC5CC,OAAOC,iBAAiB,CAACC,QAAQ,CAAC;gBAChCP,MAAM,CAAC,EAAEE,MAAM,cAAc,CAAC;YAChC;YAEA,MAAMM,cAAcH,OAAOC,iBAAiB,CAACG,SAAS,CAAC;gBACrD,MAAMC,QAAQL,OAAOC,iBAAiB,CAACK,QAAQ;gBAC/C,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGH,KAAK,CAACR,MAAM;gBAE1C,IAAI,CAACU,WAAWC,UAAU;oBACxBL;oBAEAJ,QAAQS;gBACV;YACF;QACF;IACF,GAAGb;AACL"}
|
package/dist/cjs/matchers.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-invalid-this */ // Note: Because this file imports from `@jest/globals`, it can only be used in
|
|
2
|
-
// a Jest environment. This is why it's not exported from the index file.
|
|
3
|
-
"use strict";
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
function _export(target, all) {
|
|
8
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: all[name]
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
_export(exports, {
|
|
14
|
-
toRespondWith: function() {
|
|
15
|
-
return toRespondWith;
|
|
16
|
-
},
|
|
17
|
-
toRespondWithError: function() {
|
|
18
|
-
return toRespondWithError;
|
|
19
|
-
},
|
|
20
|
-
toSendNotification: function() {
|
|
21
|
-
return toSendNotification;
|
|
22
|
-
},
|
|
23
|
-
toRender: function() {
|
|
24
|
-
return toRender;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const _globals = require("@jest/globals");
|
|
28
|
-
const _utils = require("@metamask/utils");
|
|
29
|
-
const _jestmatcherutils = require("jest-matcher-utils");
|
|
30
|
-
const _superstruct = require("superstruct");
|
|
31
|
-
const _internals = require("./internals");
|
|
32
|
-
/**
|
|
33
|
-
* Ensure that the actual value is a response from the `request` function.
|
|
34
|
-
*
|
|
35
|
-
* @param actual - The actual value.
|
|
36
|
-
* @param matcherName - The name of the matcher.
|
|
37
|
-
* @param options - The matcher options.
|
|
38
|
-
*/ function assertActualIsSnapResponse(actual, matcherName, options) {
|
|
39
|
-
if (!(0, _superstruct.is)(actual, _internals.SnapResponseStruct)) {
|
|
40
|
-
throw new Error((0, _jestmatcherutils.matcherErrorMessage)((0, _jestmatcherutils.matcherHint)(matcherName, undefined, undefined, options), `${(0, _jestmatcherutils.RECEIVED_COLOR)('received')} value must be a response from the \`request\` function`, (0, _jestmatcherutils.printWithType)('Received', actual, _jestmatcherutils.printReceived)));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Ensure that the actual value is a response from the `request` function, and
|
|
45
|
-
* that it has a `ui` property.
|
|
46
|
-
*
|
|
47
|
-
* @param actual - The actual value.
|
|
48
|
-
* @param matcherName - The name of the matcher.
|
|
49
|
-
* @param options - The matcher options.
|
|
50
|
-
*/ function assertHasInterface(actual, matcherName, options) {
|
|
51
|
-
if (!(0, _superstruct.is)(actual, _internals.InterfaceStruct) || !actual.content) {
|
|
52
|
-
throw new Error((0, _jestmatcherutils.matcherErrorMessage)((0, _jestmatcherutils.matcherHint)(matcherName, undefined, undefined, options), `${(0, _jestmatcherutils.RECEIVED_COLOR)('received')} value must have a \`content\` property`, (0, _jestmatcherutils.printWithType)('Received', actual, _jestmatcherutils.printReceived)));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const toRespondWith = function(actual, expected) {
|
|
56
|
-
assertActualIsSnapResponse(actual, 'toRespondWith');
|
|
57
|
-
const { response } = actual;
|
|
58
|
-
if ((0, _utils.hasProperty)(response, 'error')) {
|
|
59
|
-
const message = ()=>`${this.utils.matcherHint('.toRespondWith')}\n\n` + `Expected response: ${this.utils.printExpected(expected)}\n` + `Received error: ${this.utils.printReceived(response.error)}`;
|
|
60
|
-
return {
|
|
61
|
-
message,
|
|
62
|
-
pass: false
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const pass = this.equals(response.result, expected);
|
|
66
|
-
const message = pass ? ()=>`${this.utils.matcherHint('.not.toRespondWith')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.result)}` : ()=>`${this.utils.matcherHint('.toRespondWith')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.result)}`;
|
|
67
|
-
return {
|
|
68
|
-
message,
|
|
69
|
-
pass
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
const toRespondWithError = function(actual, expected) {
|
|
73
|
-
assertActualIsSnapResponse(actual, 'toRespondWithError');
|
|
74
|
-
const { response } = actual;
|
|
75
|
-
if ((0, _utils.hasProperty)(response, 'result')) {
|
|
76
|
-
const message = ()=>`${this.utils.matcherHint('.toRespondWithError')}\n\n` + `Expected error: ${this.utils.printExpected(expected)}\n` + `Received result: ${this.utils.printReceived(response.result)}`;
|
|
77
|
-
return {
|
|
78
|
-
message,
|
|
79
|
-
pass: false
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const pass = this.equals(response.error, expected);
|
|
83
|
-
const message = pass ? ()=>`${this.utils.matcherHint('.not.toRespondWithError')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.error)}` : ()=>`${this.utils.matcherHint('.toRespondWithError')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(response.error)}`;
|
|
84
|
-
return {
|
|
85
|
-
message,
|
|
86
|
-
pass
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
const toSendNotification = async function(actual, expected, type) {
|
|
90
|
-
assertActualIsSnapResponse(actual, 'toSendNotification');
|
|
91
|
-
const { notifications } = actual;
|
|
92
|
-
const pass = notifications.some((notification)=>this.equals(notification.message, expected) && (type === undefined || notification.type === type));
|
|
93
|
-
const message = pass ? ()=>`${this.utils.matcherHint('.not.toSendNotification')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Expected type: ${this.utils.printExpected(type)}\n` + `Received: ${this.utils.printReceived(notifications)}` : ()=>`${this.utils.matcherHint('.toSendNotification')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Expected type: ${this.utils.printExpected(type)}\n` + `Received: ${this.utils.printReceived(notifications)}`;
|
|
94
|
-
return {
|
|
95
|
-
message,
|
|
96
|
-
pass
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
const toRender = function(actual, expected) {
|
|
100
|
-
assertHasInterface(actual, 'toRender');
|
|
101
|
-
const { content } = actual;
|
|
102
|
-
const pass = this.equals(content, expected);
|
|
103
|
-
const difference = (0, _jestmatcherutils.diff)(expected, content);
|
|
104
|
-
const message = pass ? ()=>`${this.utils.matcherHint('.not.toShowInterface')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(content)}` + `${difference ? `\n\nDifference:\n\n${difference}` : ''}` : ()=>`${this.utils.matcherHint('.toShowInterface')}\n\n` + `Expected: ${this.utils.printExpected(expected)}\n` + `Received: ${this.utils.printReceived(content)}` + `${difference ? `\n\nDifference:\n\n${difference}` : ''}`;
|
|
105
|
-
return {
|
|
106
|
-
message,
|
|
107
|
-
pass
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
_globals.expect.extend({
|
|
111
|
-
toRespondWith,
|
|
112
|
-
toRespondWithError,
|
|
113
|
-
toSendNotification,
|
|
114
|
-
toRender
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
//# sourceMappingURL=matchers.js.map
|
package/dist/cjs/matchers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/matchers.ts"],"sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type {\n NotificationType,\n EnumToUnion,\n Component,\n} from '@metamask/snaps-sdk';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: Component } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = async function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n const difference = diff(expected, content);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`\n : () =>\n `${this.utils.matcherHint('.toShowInterface')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(content)}` +\n `${difference ? `\\n\\nDifference:\\n\\n${difference}` : ''}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"],"names":["toRespondWith","toRespondWithError","toSendNotification","toRender","assertActualIsSnapResponse","actual","matcherName","options","is","SnapResponseStruct","Error","matcherErrorMessage","matcherHint","undefined","RECEIVED_COLOR","printWithType","printReceived","assertHasInterface","InterfaceStruct","content","expected","response","hasProperty","message","utils","printExpected","error","pass","equals","result","type","notifications","some","notification","difference","diff","expect","extend"],"mappings":"AAAA,kCAAkC,GAElC,+EAA+E;AAC/E,yEAAyE;;;;;;;;;;;;IAkF5DA,aAAa;eAAbA;;IA8BAC,kBAAkB;eAAlBA;;IAuCAC,kBAAkB;eAAlBA;;IA2BAC,QAAQ;eAARA;;;yBA/KU;uBAOK;kCASrB;6BACY;2BAEiC;AAGpD;;;;;;CAMC,GACD,SAASC,2BACPC,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQI,6BAAkB,GAAG;QACnC,MAAM,IAAIC,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EACf,YACA,uDAAuD,CAAC,EAC1DC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAEA;;;;;;;CAOC,GACD,SAASC,mBACPZ,MAAe,EACfC,WAAmB,EACnBC,OAA4B;IAE5B,IAAI,CAACC,IAAAA,eAAE,EAACH,QAAQa,0BAAe,KAAK,CAACb,OAAOc,OAAO,EAAE;QACnD,MAAM,IAAIT,MACRC,IAAAA,qCAAmB,EACjBC,IAAAA,6BAAW,EAACN,aAAaO,WAAWA,WAAWN,UAC/C,CAAC,EAAEO,IAAAA,gCAAc,EAAC,YAAY,uCAAuC,CAAC,EACtEC,IAAAA,+BAAa,EAAC,YAAYV,QAAQW,+BAAa;IAGrD;AACF;AAUO,MAAMhB,gBAAmD,SAC9DK,MAAM,EACNe,QAAQ;IAERhB,2BAA2BC,QAAQ;IAEnC,MAAM,EAAEgB,QAAQ,EAAE,GAAGhB;IACrB,IAAIiB,I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,CAAC,UAAU,EAAE,IAAI,CAACI,KAAK,CAACR,aAAa,CAACG,SAAS,CAAC,GAChD,CAAC,EAAEe,aAAa,CAAC,mBAAmB,EAAEA,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QAAEX;QAASI;IAAK;AACzB;AAEAS,eAAM,CAACC,MAAM,CAAC;IACZrC;IACAC;IACAC;IACAC;AACF"}
|
package/dist/cjs/options.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getOptions", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getOptions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _superstruct = require("superstruct");
|
|
12
|
-
const SnapsEnvironmentOptionsStruct = (0, _superstruct.type)({
|
|
13
|
-
executionEnvironmentUrl: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
14
|
-
simulatorUrl: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
15
|
-
keepAlive: (0, _superstruct.defaulted)((0, _superstruct.boolean)(), false),
|
|
16
|
-
server: (0, _superstruct.defaulted)((0, _superstruct.object)({
|
|
17
|
-
enabled: (0, _superstruct.defaulted)((0, _superstruct.boolean)(), true),
|
|
18
|
-
port: (0, _superstruct.defaulted)((0, _superstruct.number)(), 0),
|
|
19
|
-
root: (0, _superstruct.defaulted)((0, _superstruct.string)(), process.cwd())
|
|
20
|
-
}), {}),
|
|
21
|
-
browser: (0, _superstruct.defaulted)((0, _superstruct.object)({
|
|
22
|
-
headless: (0, _superstruct.defaulted)((0, _superstruct.boolean)(), true)
|
|
23
|
-
}), {})
|
|
24
|
-
});
|
|
25
|
-
function getOptions(testEnvironmentOptions) {
|
|
26
|
-
return (0, _superstruct.create)(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=options.js.map
|
package/dist/cjs/options.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/options.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n boolean,\n create,\n defaulted,\n number,\n object,\n optional,\n string,\n type,\n} from 'superstruct';\n\nconst SnapsEnvironmentOptionsStruct = type({\n executionEnvironmentUrl: optional(string()),\n simulatorUrl: optional(string()),\n keepAlive: defaulted(boolean(), false),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n port: defaulted(number(), 0),\n root: defaulted(string(), process.cwd()),\n }),\n {},\n ),\n\n browser: defaulted(\n object({\n headless: defaulted(boolean(), true),\n }),\n {},\n ),\n});\n\n/**\n * The options for the environment. These can be specified in the Jest\n * configuration under `testEnvironmentOptions`.\n *\n * @example\n * ```json\n * {\n * \"testEnvironment\": \"@metamask/snaps-jest\",\n * \"testEnvironmentOptions\": {\n * \"executionEnvironmentUrl\": \"http://localhost:8080\",\n * \"server\": {\n * \"port\": 8080,\n * /* ... *\\/\n * }\n * }\n * }\n * ```\n * @property executionEnvironmentUrl - The URL of the execution environment. If\n * this is not provided, the execution environment will be served from the\n * built-in HTTP server.\n * @property simulatorUrl - The URL of the simulator. If this is not provided,\n * the simulator will be served from the built-in HTTP server.\n * @property keepAlive - Whether to keep the browser open after the tests have\n * finished. This is useful for debugging. Defaults to `false`.\n * @property server - The options for the built-in HTTP server.\n * @property server.enabled - Whether to run the built-in HTTP server. Defaults\n * to `true`.\n * @property server.port - The port to use for the built-in HTTP server. If this\n * is not provided, a random available port will be used.\n * @property server.root - The root directory to serve from the built-in HTTP\n * server. Defaults to the current working directory. This is assumed to be the\n * directory containing the snap manifest and `dist` files. If this is a\n * relative path, it will be resolved relative to the current working directory.\n * @property browser - The options for the browser.\n * @property browser.headless - Whether to run the browser in headless mode.\n * Defaults to `true`.\n */\nexport type SnapsEnvironmentOptions = Infer<\n typeof SnapsEnvironmentOptionsStruct\n>;\n\n/**\n * Get the environment options. This validates the options, and returns the\n * default options if none are provided.\n *\n * @param testEnvironmentOptions - The test environment options as defined in\n * the Jest configuration.\n * @returns The environment options.\n */\nexport function getOptions(testEnvironmentOptions: Record<string, unknown>) {\n return create(testEnvironmentOptions, SnapsEnvironmentOptionsStruct);\n}\n"],"names":["getOptions","SnapsEnvironmentOptionsStruct","type","executionEnvironmentUrl","optional","string","simulatorUrl","keepAlive","defaulted","boolean","server","object","enabled","port","number","root","process","cwd","browser","headless","testEnvironmentOptions","create"],"mappings":";;;;+BAmFgBA;;;eAAAA;;;6BAzET;AAEP,MAAMC,gCAAgCC,IAAAA,iBAAI,EAAC;IACzCC,yBAAyBC,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IACxCC,cAAcF,IAAAA,qBAAQ,EAACC,IAAAA,mBAAM;IAC7BE,WAAWC,IAAAA,sBAAS,EAACC,IAAAA,oBAAO,KAAI;IAEhCC,QAAQF,IAAAA,sBAAS,EACfG,IAAAA,mBAAM,EAAC;QACLC,SAASJ,IAAAA,sBAAS,EAACC,IAAAA,oBAAO,KAAI;QAC9BI,MAAML,IAAAA,sBAAS,EAACM,IAAAA,mBAAM,KAAI;QAC1BC,MAAMP,IAAAA,sBAAS,EAACH,IAAAA,mBAAM,KAAIW,QAAQC,GAAG;IACvC,IACA,CAAC;IAGHC,SAASV,IAAAA,sBAAS,EAChBG,IAAAA,mBAAM,EAAC;QACLQ,UAAUX,IAAAA,sBAAS,EAACC,IAAAA,oBAAO,KAAI;IACjC,IACA,CAAC;AAEL;AAmDO,SAAST,WAAWoB,sBAA+C;IACxE,OAAOC,IAAAA,mBAAM,EAACD,wBAAwBnB;AACxC"}
|
package/dist/cjs/setup.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Setup file for Jest. This file is used in the Jest preset configuration, and
|
|
2
|
-
// not intended to be exported or used directly.
|
|
3
|
-
// eslint-disable-next-line import/no-unassigned-import
|
|
4
|
-
"use strict";
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
require("./matchers");
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=setup.js.map
|
package/dist/cjs/setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/setup.ts"],"sourcesContent":["// Setup file for Jest. This file is used in the Jest preset configuration, and\n// not intended to be exported or used directly.\n\n// eslint-disable-next-line import/no-unassigned-import\nimport './matchers';\n"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gDAAgD;AAEhD,uDAAuD;;;;;QAChD"}
|
package/dist/cjs/types.js
DELETED
package/dist/cjs/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/esm/environment.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
2
|
-
if (privateCollection.has(obj)) {
|
|
3
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
7
|
-
if (descriptor.get) {
|
|
8
|
-
return descriptor.get.call(receiver);
|
|
9
|
-
}
|
|
10
|
-
return descriptor.value;
|
|
11
|
-
}
|
|
12
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
13
|
-
if (descriptor.set) {
|
|
14
|
-
descriptor.set.call(receiver, value);
|
|
15
|
-
} else {
|
|
16
|
-
if (!descriptor.writable) {
|
|
17
|
-
throw new TypeError("attempted to set read only private field");
|
|
18
|
-
}
|
|
19
|
-
descriptor.value = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
23
|
-
if (!privateMap.has(receiver)) {
|
|
24
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
}
|
|
26
|
-
return privateMap.get(receiver);
|
|
27
|
-
}
|
|
28
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
29
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
30
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
31
|
-
}
|
|
32
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
33
|
-
_check_private_redeclaration(obj, privateMap);
|
|
34
|
-
privateMap.set(obj, value);
|
|
35
|
-
}
|
|
36
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
37
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
38
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
function _define_property(obj, key, value) {
|
|
42
|
-
if (key in obj) {
|
|
43
|
-
Object.defineProperty(obj, key, {
|
|
44
|
-
value: value,
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
obj[key] = value;
|
|
51
|
-
}
|
|
52
|
-
return obj;
|
|
53
|
-
}
|
|
54
|
-
import { assert, createModuleLogger } from '@metamask/utils';
|
|
55
|
-
import NodeEnvironment from 'jest-environment-node';
|
|
56
|
-
import { remote } from 'webdriverio';
|
|
57
|
-
import { rootLogger, startServer } from './internals';
|
|
58
|
-
import { getOptions } from './options';
|
|
59
|
-
/* eslint-enable */ const log = createModuleLogger(rootLogger, 'environment');
|
|
60
|
-
var _options = /*#__PURE__*/ new WeakMap(), _server = /*#__PURE__*/ new WeakMap();
|
|
61
|
-
export class SnapsEnvironment extends NodeEnvironment {
|
|
62
|
-
/**
|
|
63
|
-
* Set up the environment. This starts the built-in HTTP server, and creates a
|
|
64
|
-
* new browser instance.
|
|
65
|
-
*/ async setup() {
|
|
66
|
-
await super.setup();
|
|
67
|
-
if (_class_private_field_get(this, _options).server.enabled) {
|
|
68
|
-
log('Starting server.');
|
|
69
|
-
_class_private_field_set(this, _server, await startServer(_class_private_field_get(this, _options).server));
|
|
70
|
-
}
|
|
71
|
-
const args = [];
|
|
72
|
-
if (_class_private_field_get(this, _options).browser.headless) {
|
|
73
|
-
args.push('--headless', '--disable-gpu');
|
|
74
|
-
}
|
|
75
|
-
log('Starting browser.');
|
|
76
|
-
this.browser = await remote({
|
|
77
|
-
logLevel: 'error',
|
|
78
|
-
capabilities: {
|
|
79
|
-
browserName: 'chrome',
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
81
|
-
'goog:chromeOptions': {
|
|
82
|
-
args
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
this.global.browser = this.browser;
|
|
87
|
-
this.global.snapsEnvironment = this;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Tear down the environment. This closes the browser, and stops the built-in
|
|
91
|
-
* HTTP server.
|
|
92
|
-
*/ async teardown() {
|
|
93
|
-
if (_class_private_field_get(this, _options).keepAlive) {
|
|
94
|
-
log('Not tearing down environment because keepAlive is enabled.');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
log('Closing browser, and stopping server.');
|
|
98
|
-
await this.browser?.deleteSession();
|
|
99
|
-
_class_private_field_get(this, _server)?.close();
|
|
100
|
-
await super.teardown();
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get the URL to the simulator, including the environment URL.
|
|
104
|
-
*
|
|
105
|
-
* @returns The simulator URL.
|
|
106
|
-
* @throws If the server is not running.
|
|
107
|
-
*/ get url() {
|
|
108
|
-
assert(_class_private_field_get(this, _server), 'Server is not running.');
|
|
109
|
-
const { port } = _class_private_field_get(this, _server).address();
|
|
110
|
-
const simulatorUrl = _class_private_field_get(this, _options).simulatorUrl ?? `http://localhost:${port}/simulator/`;
|
|
111
|
-
const executionEnvironmentUrl = _class_private_field_get(this, _options).executionEnvironmentUrl ?? `http://localhost:${port}/environment/`;
|
|
112
|
-
return `${simulatorUrl}?environment=${encodeURIComponent(executionEnvironmentUrl)}`;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the snap ID for the current environment, which is used if no snap ID is
|
|
116
|
-
* passed to {@link installSnap}. This assumes that the built-in server is
|
|
117
|
-
* running.
|
|
118
|
-
*
|
|
119
|
-
* @returns The snap ID.
|
|
120
|
-
* @throws If the server is not running.
|
|
121
|
-
*/ get snapId() {
|
|
122
|
-
assert(_class_private_field_get(this, _server), 'You must specify a snap ID, because the built-in server is not running.');
|
|
123
|
-
const { port } = _class_private_field_get(this, _server).address();
|
|
124
|
-
return `local:http://localhost:${port}`;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Create a new page, and attach logging handlers.
|
|
128
|
-
*
|
|
129
|
-
* @param url - The page URL. Defaults to the specified Snaps Simulator URL,
|
|
130
|
-
* or the default simulator URL if none is specified.
|
|
131
|
-
* @param timeout - The page timeout, in milliseconds.
|
|
132
|
-
* @returns The new page.
|
|
133
|
-
*/ async createPage(url = this.url, timeout = 10000) {
|
|
134
|
-
const puppeteer = await this.browser.getPuppeteer();
|
|
135
|
-
const page = await puppeteer.newPage();
|
|
136
|
-
page.setDefaultTimeout(timeout);
|
|
137
|
-
page.setDefaultNavigationTimeout(timeout);
|
|
138
|
-
// Give the page permission to show notifications. This is required for
|
|
139
|
-
// testing `snap_notify`.
|
|
140
|
-
await page.browserContext().overridePermissions(url, [
|
|
141
|
-
'notifications'
|
|
142
|
-
]);
|
|
143
|
-
// `networkidle0` is used to ensure that the page is fully loaded. This
|
|
144
|
-
// makes it wait for no requests to be made, which guarantees that the page
|
|
145
|
-
// is ready.
|
|
146
|
-
await page.goto(url, {
|
|
147
|
-
waitUntil: 'networkidle0'
|
|
148
|
-
});
|
|
149
|
-
const browserLog = createModuleLogger(rootLogger, 'browser');
|
|
150
|
-
page// This is fired when the page calls `console.log` or similar.
|
|
151
|
-
.on('console', (message)=>{
|
|
152
|
-
browserLog(`[${message.type()}] ${message.text()}`);
|
|
153
|
-
})// This is fired when the page throws an error.
|
|
154
|
-
.on('pageerror', ({ message })=>{
|
|
155
|
-
browserLog(`[page error] ${message}`);
|
|
156
|
-
});
|
|
157
|
-
return page;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Constructor.
|
|
161
|
-
*
|
|
162
|
-
* @param options - The environment options.
|
|
163
|
-
* @param context - The environment context.
|
|
164
|
-
*/ constructor(options, context){
|
|
165
|
-
super(options, context);
|
|
166
|
-
// `browser` is always set in the environment setup function. To avoid needing
|
|
167
|
-
// to check for `undefined` everywhere, we use a type assertion here.
|
|
168
|
-
_define_property(this, "browser", void 0);
|
|
169
|
-
_class_private_field_init(this, _options, {
|
|
170
|
-
writable: true,
|
|
171
|
-
value: void 0
|
|
172
|
-
});
|
|
173
|
-
_class_private_field_init(this, _server, {
|
|
174
|
-
writable: true,
|
|
175
|
-
value: void 0
|
|
176
|
-
});
|
|
177
|
-
_class_private_field_set(this, _options, getOptions(options.projectConfig.testEnvironmentOptions));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
export default SnapsEnvironment;
|
|
181
|
-
|
|
182
|
-
//# 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":["assert","createModuleLogger","NodeEnvironment","remote","rootLogger","startServer","getOptions","log","SnapsEnvironment","setup","options","server","enabled","args","browser","headless","push","logLevel","capabilities","browserName","global","snapsEnvironment","teardown","keepAlive","deleteSession","close","url","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","projectConfig","testEnvironmentOptions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,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