Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@quilted/react-testing

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quilted/react-testing - npm Package Compare versions

Comparing version 0.1.11 to 0.2.0

13

build/cjs/environment.js

@@ -9,3 +9,3 @@ "use strict";

var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");

@@ -16,4 +16,2 @@ var _TestRenderer = require("./TestRenderer");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const IS_NODE = Symbol.for('QuiltTesting.Node');

@@ -131,3 +129,3 @@

if (currentProp == null || typeof currentProp !== 'object') {
throw new Error(`Attempted to access field keypath '${currentKeypath.join('.')}', but it was not an object.`);
throw new Error(`Attempted to access field keypath '${currentKeypath.join('.')}', but it was not an PlainObject.`);
}

@@ -165,8 +163,9 @@

act(() => {
context = env.mount( /*#__PURE__*/_react.default.createElement(_TestRenderer.TestRenderer, {
context = env.mount( /*#__PURE__*/(0, _jsxRuntime.jsx)(_TestRenderer.TestRenderer, {
ref: renderer => {
testRenderer.current = renderer;
},
render: render
}, element));
render: render,
children: element
}));
});

@@ -173,0 +172,0 @@ allMounted.add(root);

@@ -1,4 +0,5 @@

import React, { ReactElement } from 'react';
import type { ReactElement } from 'react';
import type { Node as BaseNode, Root as BaseRoot } from './types';
declare type NodeCreationOptions<T, Extensions extends object> = {
declare type PlainObject = Record<string, any>;
declare type NodeCreationOptions<T, Extensions extends PlainObject> = {
props: T;

@@ -9,3 +10,3 @@ instance: any;

} & Extensions;
export interface Environment<Context, Extensions extends object> {
export interface Environment<Context, Extensions extends PlainObject = {}> {
act<T>(action: () => T): T extends Promise<any> ? Promise<void> : void;

@@ -17,4 +18,4 @@ mount(element: ReactElement<any>): Context;

}
declare type FullRoot<Props, Context extends object | undefined, Extensions extends object> = BaseNode<Props, Extensions> & BaseRoot<Props, Context>;
declare type AfterMountOption<MountOptions extends object, Context extends object, Extensions extends object, Async extends boolean> = Async extends true ? {
declare type FullRoot<Props, Context extends PlainObject | undefined, Extensions extends PlainObject> = BaseNode<Props, Extensions> & BaseRoot<Props, Context>;
declare type AfterMountOption<MountOptions extends PlainObject, Context extends PlainObject, Extensions extends PlainObject, Async extends boolean> = Async extends true ? {
afterMount(wrapper: FullRoot<unknown, Context, Extensions>, options: MountOptions): PromiseLike<void>;

@@ -24,21 +25,21 @@ } : {

};
export interface ContextOption<MountOptions extends object, Context extends object> {
export interface ContextOption<MountOptions extends PlainObject, Context extends PlainObject> {
context?(options: MountOptions): Context;
}
declare type CustomMountOptions<MountOptions extends object = {}, CreateContext extends object = {}, Context extends object = CreateContext, Extensions extends object = {}, Async extends boolean = false> = {
declare type CustomMountOptions<MountOptions extends PlainObject = {}, CreateContext extends PlainObject = {}, Context extends PlainObject = CreateContext, Extensions extends PlainObject = {}, Async extends boolean = false> = {
render(element: ReactElement<any>, context: Context, options: MountOptions): ReactElement<any>;
} & ContextOption<MountOptions, CreateContext> & AfterMountOption<MountOptions, Context, Extensions, Async>;
export interface CustomMount<MountOptions extends object, Context extends object, Extensions extends object, Async extends boolean> {
export interface CustomMount<MountOptions extends PlainObject, Context extends PlainObject, Extensions extends PlainObject, Async extends boolean> {
<Props>(element: ReactElement<any>, options?: MountOptions): CustomMountResult<Props, Context, Extensions, Async>;
extend<AdditionalMountOptions extends object = {}, AdditionalContext extends object = {}, AdditionalAsync extends boolean = false>(options: CustomMountOptions<MountOptions & AdditionalMountOptions, AdditionalContext, Context & AdditionalContext, Extensions, AdditionalAsync>): CustomMount<MountOptions & AdditionalMountOptions, Context & AdditionalContext, Extensions, AdditionalAsync extends true ? AdditionalAsync : Async>;
extend<AdditionalMountOptions extends PlainObject = {}, AdditionalContext extends PlainObject = {}, AdditionalAsync extends boolean = false>(options: CustomMountOptions<MountOptions & AdditionalMountOptions, AdditionalContext, Context & AdditionalContext, Extensions, AdditionalAsync>): CustomMount<MountOptions & AdditionalMountOptions, Context & AdditionalContext, Extensions, AdditionalAsync extends true ? AdditionalAsync : Async>;
}
declare type CustomMountResult<Props, Context extends object, Extensions extends object, Async extends boolean> = Async extends true ? Promise<FullRoot<Props, Context, Extensions>> : FullRoot<Props, Context, Extensions>;
export declare function createEnvironment<EnvironmentContext = undefined, Extensions extends object = {}>(env: Environment<EnvironmentContext, Extensions>): {
mount: <Props>(element: React.ReactElement<Props, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>) => FullRoot<Props, undefined, Extensions>;
createMount: <MountOptions extends object = {}, Context extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: CustomMountOptions<MountOptions, Context, Context, Extensions, Async>) => CustomMount<MountOptions, Context, Extensions, Async>;
declare type CustomMountResult<Props, Context extends PlainObject, Extensions extends PlainObject, Async extends boolean> = Async extends true ? Promise<FullRoot<Props, Context, Extensions>> : FullRoot<Props, Context, Extensions>;
export declare function createEnvironment<EnvironmentContext = undefined, Extensions extends PlainObject = {}>(env: Environment<EnvironmentContext, Extensions>): {
mount: <Props>(element: ReactElement<Props, string | ((props: any) => ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => FullRoot<Props, undefined, Extensions>;
createMount: <MountOptions extends Record<string, any> = {}, Context extends Record<string, any> = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: CustomMountOptions<MountOptions, Context, Context, Extensions, Async>) => CustomMount<MountOptions, Context, Extensions, Async>;
mounted: Set<FullRoot<any, any, Extensions>>;
unmountAll: () => void;
};
export declare function isNode<Extensions extends object = {}>(maybeNode: unknown): maybeNode is BaseNode<unknown, Extensions>;
export declare function isNode<Extensions extends PlainObject = {}>(maybeNode: unknown): maybeNode is BaseNode<unknown, Extensions>;
export {};
//# sourceMappingURL=environment.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNode = exports.createEnvironment = void 0;
const react_1 = __importDefault(require("react"));
const jsx_runtime_1 = require("react/jsx-runtime");
const TestRenderer_1 = require("./TestRenderer");

@@ -73,3 +70,4 @@ const print_1 = require("./print");

isMatchingType(element.type, type) &&
(props == null || equalSubset(props, element.props))),
(props == null ||
equalSubset(props, element.props))),
findWhere: (predicate) => { var _a; return (_a = descendants.find((element) => isNode(element) && predicate(element))) !== null && _a !== void 0 ? _a : null; },

@@ -91,3 +89,3 @@ findAllWhere: (predicate) => descendants.filter((element) => isNode(element) && predicate(element)),

if (currentProp == null || typeof currentProp !== 'object') {
throw new Error(`Attempted to access field keypath '${currentKeypath.join('.')}', but it was not an object.`);
throw new Error(`Attempted to access field keypath '${currentKeypath.join('.')}', but it was not an PlainObject.`);
}

@@ -116,5 +114,5 @@ currentProp = currentProp[part];

act(() => {
context = env.mount(react_1.default.createElement(TestRenderer_1.TestRenderer, { ref: (renderer) => {
context = env.mount(jsx_runtime_1.jsx(TestRenderer_1.TestRenderer, Object.assign({ ref: (renderer) => {
testRenderer.current = renderer;
}, render: render }, element));
}, render: render }, { children: element }), void 0));
});

@@ -121,0 +119,0 @@ allMounted.add(root);

@@ -8,9 +8,9 @@ /// <reference types="react" />

export type { Node, HtmlNodeExtensions, CustomMount };
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "isDom" | "domNodes" | "domNode" | "text"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends Record<string, any> = {}, Context_1 extends Record<string, any> = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
render(element: import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>, context: Context_1, options: MountOptions): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>;
} & import("../environment").ContextOption<MountOptions, Context_1> & (Async extends true ? {
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "isDom" | "domNodes" | "domNode" | "text"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>;
afterMount(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): PromiseLike<void>;
} : {
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "isDom" | "domNodes" | "domNode" | "text"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void;
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "data" | "html" | "isDom" | "domNodes" | "domNode" | "text"> & import("../types").Root<any, any>>, unmountAll: () => void;
afterMount?(wrapper: import("../types").NodeApi<unknown, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<unknown, Context_1>, options: MountOptions): void;
})) => CustomMount<MountOptions, Context_1, HtmlNodeExtensions, Async>, mounted: Set<import("../types").NodeApi<any, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<any, any>>, unmountAll: () => void;
export { mount, createMount, mounted, unmountAll };

@@ -17,0 +17,0 @@ /**

@@ -7,3 +7,3 @@ /// <reference types="react" />

export type { Node, HtmlNodeExtensions, CustomMount };
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, HtmlNodeExtensions> & Pick<HtmlNodeExtensions, "text" | "data" | "html" | "isDom" | "domNodes" | "domNode"> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends Record<string, any> = {}, Context_1 extends Record<string, any> = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
render(element: import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>, context: Context_1, options: MountOptions): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>;

@@ -10,0 +10,0 @@ } & import("../environment").ContextOption<MountOptions, Context_1> & (Async extends true ? {

/// <reference types="react" />
import { Environment } from '../../environment';
import type { Environment } from '../../environment';
export declare enum Tag {

@@ -42,3 +42,3 @@ FunctionComponent = 0,

}
declare type Create = Parameters<Environment<any, {}>['update']>[1];
declare type Create = Parameters<Environment<any>['update']>[1];
declare type Child = ReturnType<Create> | string;

@@ -45,0 +45,0 @@ export declare function createNodeFromFiber(element: any, create: Create): Child;

@@ -7,3 +7,3 @@ /// <reference types="react" />

export type { Node, CustomMount };
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, {}> & Pick<{}, never> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends object = {}, Context_1 extends object = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
declare const mount: <Props>(element: import("react").ReactElement<Props, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>) => import("../types").NodeApi<Props, {}> & Pick<{}, never> & import("../types").Root<Props, undefined>, createMount: <MountOptions extends Record<string, any> = {}, Context_1 extends Record<string, any> = {}, Async extends boolean = false>({ render, context: createContext, afterMount, }: {
render(element: import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>, context: Context_1, options: MountOptions): import("react").ReactElement<any, string | ((props: any) => import("react").ReactElement<any, string | any | (new (props: any) => import("react").Component<any, any, any>)> | null) | (new (props: any) => import("react").Component<any, any, any>)>;

@@ -10,0 +10,0 @@ } & import("../environment").ContextOption<MountOptions, Context_1> & (Async extends true ? {

@@ -10,5 +10,5 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./implementations/test-renderer"), exports);
/// <reference types="jest" />
import type { ComponentType } from 'react';
import { Node, PropsFor } from '../types';
export declare function toContainReactComponent<Type extends string | ComponentType<any>, Extensions extends object = {}>(this: jest.MatcherUtils, node: Node<unknown, Extensions>, type: Type, props?: Partial<PropsFor<Type>>): {
export declare function toContainReactComponent<Type extends string | ComponentType<any>>(this: jest.MatcherUtils, node: Node<any, any>, type: Type, props?: Partial<PropsFor<Type>>): {
pass: boolean;

@@ -6,0 +6,0 @@ message: () => string;

/// <reference types="jest" />
import { Context } from 'react';
import { Node } from '../types';
export declare function toProvideReactContext<Type, Extensions extends object = {}>(this: jest.MatcherUtils, node: Node<unknown, Extensions>, Context: Context<Type>, value?: Type): {
export declare function toProvideReactContext<Type>(this: jest.MatcherUtils, node: Node<any, any>, Context: Context<Type>, value?: Type): {
pass: boolean;

@@ -6,0 +6,0 @@ message: () => string;

import type { ComponentType, Context as ReactContext } from 'react';
import type { Node, PropsFor } from '../types';
declare type PropsFromNode<T> = NonNullable<T> extends Node<infer U, {}> ? U : never;
declare type PropsFromNode<T> = NonNullable<T> extends Node<infer U, any> ? U : never;
declare global {

@@ -5,0 +5,0 @@ namespace jest {

/// <reference types="jest" />
import type { Node } from '../types';
export declare function toHaveReactProps<Props, Extensions extends object = {}>(this: jest.MatcherUtils, node: Node<Props, Extensions>, props: Partial<Props>): {
export declare function toHaveReactProps<Props>(this: jest.MatcherUtils, node: Node<Props, any>, props: Partial<Props>): {
pass: boolean;

@@ -5,0 +5,0 @@ message: () => string;

/// <reference types="jest" />
import type { Node } from '../types';
export declare function toContainReactText<Props, Extensions extends object = {}>(this: jest.MatcherUtils, node: Node<Props, Extensions>, text: string): {
export declare function toContainReactText<Props>(this: jest.MatcherUtils, node: Node<Props, any>, text: string): {
pass: boolean;

@@ -5,0 +5,0 @@ message: () => string;

@@ -11,5 +11,5 @@ /// <reference types="react" />

}): void;
export declare function diffs<Extensions extends object = {}>(element: Node<any, Extensions>[], props: object, expand?: boolean): string;
export declare function diffs(element: Node<any, any>[], props: Record<string, any>, expand?: boolean): string;
export declare function printType(type: string | React.ComponentType<any>): string;
export declare function diffPropsForNode<Extensions extends object = {}>(node: Node<any, Extensions>, props: object, { expand }: {
export declare function diffPropsForNode(node: Node<any, any>, props: Record<string, any>, { expand }: {
expand?: boolean | undefined;

@@ -16,0 +16,0 @@ }): string | null;

import type { DebugOptions, Node } from './types';
export declare function toReactString<Props>(node: Node<Props, {}> | string, options?: DebugOptions, level?: number): string;
export declare function toReactString<Props>(node: Node<Props, any> | string, options?: DebugOptions, level?: number): string;
export declare function toPropString(key: string, value: unknown, verbosity?: number): string;
export declare function nodeName<Props>({ type }: Node<Props>): string;
//# sourceMappingURL=print.d.ts.map

@@ -6,8 +6,8 @@ import type { ComponentType, ComponentPropsWithoutRef, HTMLAttributes, Context } from 'react';

}[keyof T];
export declare type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends readonly (infer U)[] ? readonly DeepPartial<U>[] : T extends object ? {
export declare type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends readonly (infer U)[] ? readonly DeepPartial<U>[] : T extends Record<string, any> ? {
[K in keyof T]?: DeepPartial<T[K]>;
} : T;
export declare type Predicate<Extensions extends object> = (node: Node<unknown, Extensions>) => boolean;
export declare type Predicate<Extensions extends Record<string, any>> = (node: Node<unknown, Extensions>) => boolean;
declare type MaybeFunctionReturnType<T> = T extends (...args: any[]) => any ? ReturnType<T> : unknown;
export interface Root<Props, Context extends object | undefined = undefined> {
export interface Root<Props, Context extends Record<string, any> | undefined = undefined> {
readonly context: Context;

@@ -21,3 +21,3 @@ mount(): void;

}
export interface NodeApi<Props, Extensions extends object> {
export interface NodeApi<Props, Extensions extends Record<string, any>> {
readonly props: Props;

@@ -41,3 +41,3 @@ readonly type: string | ComponentType<any> | null;

}
export declare type Node<Props, Extensions extends object = {}> = NodeApi<Props, Extensions> & Omit<Extensions, keyof Root<any>>;
export declare type Node<Props, Extensions extends Record<string, any> = {}> = NodeApi<Props, Extensions> & Omit<Extensions, keyof Root<any>>;
export interface DebugOptions {

@@ -44,0 +44,0 @@ all?: boolean;

{
"name": "@quilted/react-testing",
"version": "0.1.11",
"version": "0.2.0",
"description": "",

@@ -49,4 +49,4 @@ "publishConfig": {

"peerDependencies": {
"react": ">=16.8.0 <17.0.0",
"react-dom": ">=16.8.0 <17.0.0"
"react": ">=17.0.0 <18.0.0",
"react-dom": ">=17.0.0 <18.0.0"
},

@@ -66,3 +66,3 @@ "optionalDependencies": {

},
"gitHead": "16557e56c511c31e3bb7a4921a1e9ac16755bb1c"
"gitHead": "31f9f36883db9cdfc4304f7c3f6a06095200c88b"
}

@@ -1,2 +0,2 @@

import {Environment} from '../../environment';
import type {Environment} from '../../environment';

@@ -49,3 +49,3 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires

type Create = Parameters<Environment<any, {}>['update']>[1];
type Create = Parameters<Environment<any>['update']>[1];
type Child = ReturnType<Create> | string;

@@ -52,0 +52,0 @@

@@ -33,3 +33,3 @@ import {

type Create = Parameters<Environment<any, {}>['update']>[1];
type Create = Parameters<Environment<any>['update']>[1];

@@ -36,0 +36,0 @@ function createNodeFromTestInstance(

@@ -20,7 +20,6 @@ import type {ComponentType} from 'react';

export function toContainReactComponent<
Type extends string | ComponentType<any>,
Extensions extends object = {}
Type extends string | ComponentType<any>
>(
this: jest.MatcherUtils,
node: Node<unknown, Extensions>,
node: Node<any, any>,
type: Type,

@@ -27,0 +26,0 @@ props?: Partial<PropsFor<Type>>,

@@ -13,5 +13,5 @@ import {Context} from 'react';

export function toProvideReactContext<Type, Extensions extends object = {}>(
export function toProvideReactContext<Type>(
this: jest.MatcherUtils,
node: Node<unknown, Extensions>,
node: Node<any, any>,
Context: Context<Type>,

@@ -18,0 +18,0 @@ value?: Type,

@@ -16,2 +16,3 @@ import {

namespace jest {
// eslint-disable-next-line @typescript-eslint/ban-types
interface Matchers<R, T = {}> {

@@ -18,0 +19,0 @@ toContainReactHtml(text: string): void;

@@ -13,3 +13,3 @@ import type {ComponentType, Context as ReactContext} from 'react';

type PropsFromNode<T> = NonNullable<T> extends Node<infer U, {}> ? U : never;
type PropsFromNode<T> = NonNullable<T> extends Node<infer U, any> ? U : never;

@@ -19,2 +19,3 @@ declare global {

namespace jest {
// eslint-disable-next-line @typescript-eslint/ban-types
interface Matchers<R, T = {}> {

@@ -21,0 +22,0 @@ toHaveReactProps(props: Partial<PropsFromNode<T>>): void;

@@ -12,5 +12,5 @@ import {

export function toHaveReactProps<Props, Extensions extends object = {}>(
export function toHaveReactProps<Props>(
this: jest.MatcherUtils,
node: Node<Props, Extensions>,
node: Node<Props, any>,
props: Partial<Props>,

@@ -17,0 +17,0 @@ ) {

@@ -12,5 +12,5 @@ import {

export function toContainReactText<Props, Extensions extends object = {}>(
export function toContainReactText<Props>(
this: jest.MatcherUtils,
node: Node<Props, Extensions>,
node: Node<Props, any>,
text: string,

@@ -17,0 +17,0 @@ ) {

@@ -77,5 +77,5 @@ import {

export function diffs<Extensions extends object = {}>(
element: Node<any, Extensions>[],
props: object,
export function diffs(
element: Node<any, any>[],
props: Record<string, any>,
expand?: boolean,

@@ -93,5 +93,5 @@ ) {

function normalizedDiff<Extensions extends object = {}>(
element: Node<any, Extensions>,
props: object,
function normalizedDiff(
element: Node<any, any>,
props: Record<string, any>,
{expand = false, showLegend = false},

@@ -123,5 +123,5 @@ ) {

export function diffPropsForNode<Extensions extends object = {}>(
node: Node<any, Extensions>,
props: object,
export function diffPropsForNode(
node: Node<any, any>,
props: Record<string, any>,
{expand = false},

@@ -128,0 +128,0 @@ ) {

@@ -8,3 +8,3 @@ import {stringify} from 'jest-matcher-utils';

export function toReactString<Props>(
node: Node<Props, {}> | string,
node: Node<Props, any> | string,
options: DebugOptions = {},

@@ -11,0 +11,0 @@ level = 0,

@@ -28,3 +28,3 @@ import type {

? readonly DeepPartial<U>[]
: T extends object
: T extends Record<string, any>
? {

@@ -35,3 +35,3 @@ [K in keyof T]?: DeepPartial<T[K]>;

export type Predicate<Extensions extends object> = (
export type Predicate<Extensions extends Record<string, any>> = (
node: Node<unknown, Extensions>,

@@ -44,3 +44,6 @@ ) => boolean;

export interface Root<Props, Context extends object | undefined = undefined> {
export interface Root<
Props,
Context extends Record<string, any> | undefined = undefined
> {
readonly context: Context;

@@ -55,3 +58,3 @@ mount(): void;

export interface NodeApi<Props, Extensions extends object> {
export interface NodeApi<Props, Extensions extends Record<string, any>> {
readonly props: Props;

@@ -96,3 +99,4 @@ readonly type: string | ComponentType<any> | null;

export type Node<Props, Extensions extends object = {}> = NodeApi<
// eslint-disable-next-line @typescript-eslint/ban-types
export type Node<Props, Extensions extends Record<string, any> = {}> = NodeApi<
Props,

@@ -99,0 +103,0 @@ Extensions

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc