本文整理汇总了TypeScript中jest-matcher-utils.stringify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stringify函数的具体用法?TypeScript stringify怎么用?TypeScript stringify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringify函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: matcherHint
? () =>
matcherHint(matcherName, undefined, undefined, options) +
'\n\n' +
`Expected: not ${printExpected(expected)}\n` +
(stringify(expected) !== stringify(received)
? `Received: ${printReceived(received)}`
: '')
示例2: Error
const _validateResult = (result: any) => {
if (
typeof result !== 'object' ||
typeof result.pass !== 'boolean' ||
(result.message &&
(typeof result.message !== 'string' &&
typeof result.message !== 'function'))
) {
throw new Error(
'Unexpected return from a matcher function.\n' +
'Matcher functions should ' +
'return an object in the following format:\n' +
' {message?: string | function, pass: boolean}\n' +
`'${matcherUtils.stringify(result)}' was returned`,
);
}
};
示例3:
import * as chalk from 'chalk';
import * as utils from 'jest-matcher-utils';
utils.EXPECTED_COLOR; // $ExpectType ChalkChain
utils.RECEIVED_COLOR; // $ExpectType ChalkChain
utils.SUGGEST_TO_EQUAL; // $ExpectType string
utils.stringify({}); // $ExpectType string
utils.stringify({}, 44);
utils.stringify({}, '44'); // $ExpectError
utils.stringify({}, false); // $ExpectError
utils.highlightTrailingWhitespace('', chalk.red); // $ExpectType string
utils.highlightTrailingWhitespace(44, chalk.blue); // $ExpectError
utils.highlightTrailingWhitespace(false, chalk.green); // $ExpectError
utils.printReceived({}); // $ExpectType string
utils.printExpected({}); // $ExpectType string
utils.printWithType('obj', {}, () => ''); // $ExpectType string
utils.ensureNoExpected(null, ''); // $ExpectType void
utils.ensureNoExpected('', '');
utils.ensureActualIsNumber(66); // $ExpectType void
utils.ensureActualIsNumber(66, 'highwayRouteMatcher');
utils.ensureActualIsNumber('66', 'highwayRouteMatcher');
utils.ensureExpectedIsNumber(66); // $ExpectType void
utils.ensureExpectedIsNumber(66, 'highwayRouteMatcher');
utils.ensureExpectedIsNumber('66', 'highwayRouteMatcher');
示例4: stringify
.map((item, i) => {
const stringified = stringify(item);
return i === index ? INVERTED_COLOR(stringified) : stringified;
})