Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
matcherErrorMessage(
matcherHint(`.${expectation}`, undefined, undefined, {isNot}),
`${receivedColor(
'received',
)} value must be an @shopify/react-testing Root or Element object`,
`Received an ${receivedColor(
'array of Root or Element objects',
)}.\nThis usually means that you passed in the result of \`.findAllX\`. Pass the result of \`.findX\` instead.`,
),
);
}
if (!(node instanceof Root) && !(node instanceof Element)) {
throw new Error(
matcherErrorMessage(
matcherHint(`.${expectation}`, undefined, undefined, {isNot}),
`${receivedColor(
'received',
)} value must be an @shopify/react-testing Root or Element object`,
printWithType('Received', node, printReceived),
),
);
}
}
? () =>
`${matcherHint('.not.toProvideReactContext')}\n\n` +
`Expected the React element:\n ${receivedColor(node.toString())}\n` +
`Not to contain context provider:\n ${expectedColor(
printType(Context.Provider),
)}\n${
value ? `With value matching:\n ${printExpected(value)}\n` : ''
}` +
`But ${foundByValue.length} matching ${printType(Context.Provider)}${
foundByValue.length === 1 ? 's were' : ' was'
} found.\n`
: () =>
) => () =>
matcherHint('.not.transformsNode') + '\n\n' + shouldChange
? chalk`Expected the node {bold not} to be:\n` +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node to be different from:\n' +
`${printExpected(expected.toString())}\n\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
: () => {
const diffString = diffPropsForNode(node, props, {
expand: this.expand,
});
return (
`${matcherHint('.toHaveReactProps', node.toString())}\n\n` +
`Expected the React element:\n ${receivedColor(node.toString())}\n` +
`To have props:\n ${printExpected(props)}\n` +
`Received:\n ${printReceived(node.props)}\n${
diffString ? `Difference:\n${diffString}\n` : ''
}`
);
};
const passMessage = (object, entries) => () =>
matcherHint('.not.toContainAnyEntries') +
'\n\n' +
'Expected object to not contain any of the provided entries:\n' +
` ${printExpected(entries)}\n` +
'Received:\n' +
` ${printReceived(object)}`;
const failMessage = (object, entries) => () =>
matcherHint('.toContainAnyEntries') +
'\n\n' +
'Expected object to contain any of the provided entries:\n' +
` ${printExpected(entries)}\n` +
'Received:\n' +
` ${printReceived(object)}`;
const failMessage = (firstInvocationCallOrder, secondInvocationCallOrder) => () =>
matcherHint('.toHaveBeenCalledBefore') +
'\n\n' +
'Expected first mock to have been called before, invocationCallOrder:\n' +
` ${printExpected(firstInvocationCallOrder)}\n` +
'Received second mock with invocationCallOrder:\n' +
` ${printReceived(secondInvocationCallOrder)}`;
message: () =>
`${matcherHint(".toBeFiggyPudding", "received", "", {
isNot: this.isNot,
})}\n\nReceived: ${printReceived(received)}`,
};
const passMessage = received => () =>
matcherHint('.not.toBeNaN', 'received', '') +
'\n\n' +
'Expected value to be a number received:\n' +
` ${printReceived(received)}`;
const failMessage = received => () =>
matcherHint('.toBeNaN', 'received', '') +
'\n\n' +
'Expected value to not be a number received:\n' +
` ${printReceived(received)}`;