Skip to content

Commit 7acec0c

Browse files
fix: matcher Jest extensions (#1537)
* fix: matcher Jest extensions * docs: add typedocs
1 parent 067462f commit 7acec0c

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

src/matchers/__tests__/to-have-text-content.test.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path="../extend-expect.d.ts" />
2-
31
import * as React from 'react';
42
import { View, Text } from 'react-native';
53
import { render, screen } from '../..';

src/matchers/extend-expect.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference path="./extend-expect.d.ts" />
2-
31
import { toBeOnTheScreen } from './to-be-on-the-screen';
42
import { toBeChecked } from './to-be-checked';
53
import { toBeCollapsed } from './to-be-collapsed';
@@ -18,6 +16,8 @@ import { toHaveProp } from './to-have-prop';
1816
import { toHaveStyle } from './to-have-style';
1917
import { toHaveTextContent } from './to-have-text-content';
2018

19+
export type * from './types';
20+
2121
expect.extend({
2222
toBeOnTheScreen,
2323
toBeChecked,

src/matchers/extend-expect.d.ts renamed to src/matchers/types.ts

+8-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import type { StyleProp } from 'react-native';
22
import type { ReactTestInstance } from 'react-test-renderer';
3+
import { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
4+
import { TextMatch, TextMatchOptions } from '../matches';
5+
import { Style } from './to-have-style';
36

47
export interface JestNativeMatchers<R> {
8+
/**
9+
* Assert whether an element is present in the element tree or not.
10+
*/
511
toBeOnTheScreen(): R;
12+
613
toBeChecked(): R;
714
toBeCollapsed(): R;
815
toBeDisabled(): R;
@@ -31,26 +38,8 @@ declare global {
3138
}
3239

3340
// Explicit `@jest/globals` `expect` matchers.
41+
// @ts-ignore
3442
declare module '@jest/expect' {
3543
interface Matchers<R extends void | Promise<void>>
3644
extends JestNativeMatchers<R> {}
3745
}
38-
39-
// Used types
40-
41-
export type Style = ViewStyle | TextStyle | ImageStyle;
42-
43-
export interface AccessibilityValueMatcher {
44-
min?: number;
45-
max?: number;
46-
now?: number;
47-
text?: TextMatch;
48-
}
49-
50-
export type TextMatch = string | RegExp;
51-
export type TextMatchOptions = {
52-
exact?: boolean;
53-
normalizer?: NormalizerFn;
54-
};
55-
56-
export type NormalizerFn = (textToNormalize: string) => string;

0 commit comments

Comments
 (0)