@graphql-inspector/action
Version:
GraphQL Inspector functionality for GitHub Actions
24 lines (23 loc) • 727 B
JavaScript
import jsesc from 'jsesc';
import stripAnsi from 'strip-ansi';
function nonTTY(msg) {
return stripAnsi(jsesc(stripAnsi(msg)));
}
expect.extend({
toHaveBeenCalledNormalized(spy, expected) {
const normalizedExpected = nonTTY(expected);
const calls = spy.mock.calls;
const contain = calls.some(args => nonTTY(args.join(' ')).includes(normalizedExpected));
if (contain) {
return {
message: () => `expected not to be a called with ${expected}`,
pass: true,
};
}
const message = `expected to be called with ${expected}`;
return {
message: () => message,
pass: false,
};
},
});