Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use jest-matcher-utils in @types/jest #58784

Merged
merged 2 commits into from Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 1 addition & 64 deletions types/jest/index.d.ts
Expand Up @@ -485,35 +485,6 @@ declare namespace jest {
each: Each;
}

type PrintLabel = (string: string) => string;

type MatcherHintColor = (arg: string) => string;

interface MatcherHintOptions {
comment?: string | undefined;
expectedColor?: MatcherHintColor | undefined;
isDirectExpectCall?: boolean | undefined;
isNot?: boolean | undefined;
promise?: string | undefined;
receivedColor?: MatcherHintColor | undefined;
secondArgument?: string | undefined;
secondArgumentColor?: MatcherHintColor | undefined;
}

interface ChalkFunction {
(text: TemplateStringsArray, ...placeholders: any[]): string;
(...text: any[]): string;
}

interface ChalkColorSupport {
level: 0 | 1 | 2 | 3;
hasBasic: boolean;
has256: boolean;
has16m: boolean;
}

type MatcherColorFn = ChalkFunction & { supportsColor: ChalkColorSupport };

type EqualityTester = (a: any, b: any) => boolean | undefined;

interface MatcherUtils {
Expand All @@ -527,41 +498,7 @@ declare namespace jest {
readonly expand: boolean;
readonly testPath: string;
readonly currentTestName: string;
utils: {
readonly EXPECTED_COLOR: MatcherColorFn;
readonly RECEIVED_COLOR: MatcherColorFn;
readonly INVERTED_COLOR: MatcherColorFn;
readonly BOLD_WEIGHT: MatcherColorFn;
readonly DIM_COLOR: MatcherColorFn;
readonly SUGGEST_TO_CONTAIN_EQUAL: string;
diff(a: any, b: any, options?: import("jest-diff").DiffOptions): string | null;
ensureActualIsNumber(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureExpectedIsNumber(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureNoExpected(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureNumbers(actual: any, expected: any, matcherName: string, options?: MatcherHintOptions): void;
ensureExpectedIsNonNegativeInteger(expected: any, matcherName: string, options?: MatcherHintOptions): void;
matcherHint(
matcherName: string,
received?: string,
expected?: string,
options?: MatcherHintOptions
): string;
matcherErrorMessage(
hint: string,
generic: string,
specific: string
): string;
pluralize(word: string, count: number): string;
printReceived(object: any): string;
printExpected(value: any): string;
printWithType(name: string, value: any, print: (value: any) => string): string;
stringify(object: {}, maxDepth?: number): string;
highlightTrailingWhitespace(text: string): string;

printDiffOrStringify(expected: any, received: any, expectedLabel: string, receivedLabel: string, expand: boolean): string;

getLabelPrinter(...strings: string[]): PrintLabel;

utils: typeof import('jest-matcher-utils') & {
iterableEquality: EqualityTester;
subsetEquality: EqualityTester;
};
Expand Down
2 changes: 1 addition & 1 deletion types/jest/jest-tests.ts
Expand Up @@ -858,7 +858,7 @@ expect.extend({

const receivedPrinted: string = this.utils.printReceived({});

const printedWithType: string = this.utils.printWithType('name', {}, (value: {}) => '');
const printedWithType: string = this.utils.printWithType('name', {}, (value) => '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type in jest is unknown, not any

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in jestjs/jest#12405, but I think this change is fine anyways


const stringified: string = this.utils.stringify({});
const stringifiedWithMaxDepth: string = this.utils.stringify({}, 3);
Expand Down
2 changes: 1 addition & 1 deletion types/jest/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"jest-diff": "^27.0.0",
"jest-matcher-utils": "^27.0.0",
"pretty-format": "^27.0.0"
},
"exports": {
Expand Down