UNPKG

@metamask/snaps-jest

Version:

A Jest preset for end-to-end testing MetaMask Snaps, including a Jest environment, and a set of Jest matchers

1 lines 26.1 kB
{"version":3,"file":"matchers.cjs","sourceRoot":"","sources":["../src/matchers.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,yEAAyE;;;AAGzE,2CAAuC;AAUvC,iDAA+E;AAE/E,iEAGoC;AACpC,uDAG+B;AAC/B,uDAA2C;AAE3C,2CAA8C;AAE9C,2DAQ4B;AAE5B;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,MAAe,EACf,WAAmB,EACnB,OAA4B;IAE5B,IAAI,CAAC,IAAA,gBAAE,EAAC,MAAM,EAAE,qCAAkB,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,IAAA,wCAAmB,EACjB,IAAA,gCAAW,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EACvD,GAAG,IAAA,mCAAc,EACf,UAAU,CACX,yDAAyD,EAC1D,IAAA,kCAAa,EAAC,UAAU,EAAE,MAAM,EAAE,kCAAa,CAAC,CACjD,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,kBAAkB,CACzB,MAAe,EACf,WAAmB,EACnB,OAA4B;IAE5B,IAAI,CAAC,IAAA,gBAAE,EAAC,MAAM,EAAE,kCAAe,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,IAAA,wCAAmB,EACjB,IAAA,gCAAW,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EACvD,GAAG,IAAA,mCAAc,EAAC,UAAU,CAAC,yCAAyC,EACtE,IAAA,kCAAa,EAAC,UAAU,EAAE,MAAM,EAAE,kCAAa,CAAC,CACjD,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,aAAa,GAAsC,UAC9D,MAAM,EACN,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AK,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;IAE7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC,CAAC;AAlCW,QAAA,OAAO,WAkClB;AAEF,gBAAM,CAAC,MAAM,CAAC;IACZ,aAAa,EAAb,qBAAa;IACb,kBAAkB,EAAlB,0BAAkB;IAClB,kBAAkB,EAAlB,0BAAkB;IAClB,QAAQ,EAAR,gBAAQ;IACR,YAAY,EAAZ,oBAAY;IACZ,YAAY,EAAZ,oBAAY;IACZ,OAAO,EAAP,eAAO;CACR,CAAC,CAAC","sourcesContent":["// 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 EnumToUnion,\n ComponentOrElement,\n Component,\n NotificationType,\n TrackableError,\n TraceRequest,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement, SnapNode } from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe, JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport type { SnapResponse } from '@metamask/snaps-simulation';\nimport {\n InterfaceStruct,\n SnapResponseStruct,\n} from '@metamask/snaps-simulation';\nimport {\n getJsxElementFromComponent,\n serialiseJsx,\n} from '@metamask/snaps-utils';\nimport { is } from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\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: JSXElement } {\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 expectedMessage - The expected notification message.\n * @param expectedType - The expected notification type.\n * @param expectedTitle - The expected notification title.\n * @param expectedContent - The expected notification JSX content.\n * @param expectedFooterLink - The expected footer link object.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [\n expectedMessage: string,\n expectedType?: EnumToUnion<NotificationType> | undefined,\n expectedTitle?: string | undefined,\n expectedContent?: JSXElement | undefined,\n expectedFooterLink?: { text: string; href: string } | undefined,\n ]\n> = function (\n actual,\n expectedMessage,\n expectedType,\n expectedTitle,\n expectedContent,\n expectedFooterLink,\n) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n let jsxContent: JSXElement | undefined;\n\n if ('getInterface' in actual) {\n jsxContent = actual.getInterface().content;\n }\n\n const notificationValidator = (\n notification: SnapResponse['notifications'][number],\n ) => {\n const { type, message, title, footerLink } = notification as Record<\n string,\n unknown\n >;\n\n if (!this.equals(message, expectedMessage)) {\n return false;\n }\n\n if (expectedType && type !== expectedType) {\n return false;\n }\n\n if (title && !this.equals(title, expectedTitle)) {\n return false;\n }\n\n if (jsxContent && !this.equals(jsxContent, expectedContent)) {\n return false;\n }\n\n if (footerLink && !this.equals(footerLink, expectedFooterLink)) {\n return false;\n }\n\n return true;\n };\n\n const pass = notifications.some(notificationValidator);\n\n const transformedNotifications = notifications.map((notification) => {\n return {\n ...notification,\n // Ok to cast here as the function returns if the param is falsy\n content: serialiseJsx(jsxContent as SnapNode),\n };\n });\n\n const message = () => {\n let testMessage = pass\n ? `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n`\n : `${this.utils.matcherHint('.toSendNotification')}\\n\\n`;\n\n const {\n title,\n type,\n message: notifMessage,\n footerLink,\n content,\n } = transformedNotifications[0];\n\n testMessage += `Expected message: ${this.utils.printExpected(\n expectedMessage,\n )}\\n`;\n\n if (expectedType) {\n testMessage += `Expected type: ${this.utils.printExpected(\n expectedType,\n )}\\n`;\n }\n\n if (title) {\n testMessage += `Expected title: ${this.utils.printExpected(\n expectedTitle,\n )}\\n`;\n\n // We want to check if the expected content is actually JSX content, otherwise `serialiseJsx` won't return something useful.\n if (is(expectedContent, JSXElementStruct)) {\n testMessage += `Expected content: ${this.utils.printExpected(\n serialiseJsx(expectedContent),\n )}\\n`;\n } else {\n testMessage += `Expected content: ${this.utils.printExpected(\n expectedContent,\n )}\\n`;\n }\n }\n\n if (footerLink) {\n testMessage += `Expected footer link: ${this.utils.printExpected(\n expectedFooterLink,\n )}\\n`;\n }\n\n testMessage += `Received message: ${this.utils.printExpected(\n notifMessage,\n )}\\n`;\n\n if (expectedType) {\n testMessage += `Received type: ${this.utils.printReceived(type)}\\n`;\n }\n\n if (title) {\n testMessage += `Received title: ${this.utils.printReceived(title)}\\n`;\n testMessage += `Received content: ${this.utils.printReceived(\n serialiseJsx(content),\n )}\\n`;\n }\n\n if (footerLink) {\n testMessage += `Received footer link: ${this.utils.printReceived(\n footerLink,\n )}\\n`;\n }\n\n return testMessage;\n };\n\n return { message, pass };\n};\n\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n // This should not return a promise.\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexport const toTrackError: MatcherFunction<\n [errorData?: Partial<TrackableError>]\n> = function (actual, errorData) {\n assertActualIsSnapResponse(actual, 'toTrackError');\n\n const errorValidator = (error: SnapResponse['tracked']['errors'][number]) => {\n if (!errorData) {\n // If no error data is provided, we just check for the existence of an\n // error.\n return true;\n }\n\n return this.equals(error, errorData);\n };\n\n const { errors } = actual.tracked;\n const pass = errors.some(errorValidator);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toTrackError')}\\n\\n` +\n `Expected not to track error with data: ${this.utils.printExpected(\n errorData,\n )}\\n` +\n `Received errors: ${this.utils.printReceived(errors)}`\n : () =>\n `${this.utils.matcherHint('.toTrackError')}\\n\\n` +\n `Expected to track error with data: ${this.utils.printExpected(\n errorData,\n )}\\n` +\n `Received errors: ${this.utils.printReceived(errors)}`;\n\n return { message, pass };\n};\n\nexport const toTrackEvent: MatcherFunction<[eventData?: Json | undefined]> =\n function (actual, eventData) {\n assertActualIsSnapResponse(actual, 'toTrackEvent');\n\n const eventValidator = (\n event: SnapResponse['tracked']['events'][number],\n ) => {\n if (!eventData) {\n // If no event data is provided, we just check for the existence of an\n // event.\n return true;\n }\n\n return this.equals(event, eventData);\n };\n\n const { events } = actual.tracked;\n const pass = events.some(eventValidator);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toTrackEvent')}\\n\\n` +\n `Expected not to track event with data: ${this.utils.printExpected(\n eventData,\n )}\\n` +\n `Received events: ${this.utils.printReceived(events)}`\n : () =>\n `${this.utils.matcherHint('.toTrackEvent')}\\n\\n` +\n `Expected to track event with data: ${this.utils.printExpected(\n eventData,\n )}\\n` +\n `Received events: ${this.utils.printReceived(events)}`;\n\n return { message, pass };\n };\n\nexport const toTrace: MatcherFunction<[traceData?: TraceRequest]> = function (\n actual,\n traceData,\n) {\n assertActualIsSnapResponse(actual, 'toTrace');\n\n const traceValidator = (trace: SnapResponse['tracked']['traces'][number]) => {\n if (!traceData) {\n // If no trace data is provided, we just check for the existence of a\n // trace.\n return true;\n }\n\n return this.equals(trace, traceData);\n };\n\n const { traces } = actual.tracked;\n const pass = traces.some(traceValidator);\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toTrace')}\\n\\n` +\n `Expected not to trace with data: ${this.utils.printExpected(\n traceData,\n )}\\n` +\n `Received traces: ${this.utils.printReceived(traces)}`\n : () =>\n `${this.utils.matcherHint('.toTrace')}\\n\\n` +\n `Expected to trace with data: ${this.utils.printExpected(\n traceData,\n )}\\n` +\n `Received traces: ${this.utils.printReceived(traces)}`;\n\n return { message, pass };\n};\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n toTrackError,\n toTrackEvent,\n toTrace,\n});\n"]}