Optional
callbacks?: {And object whose values is tupples of keys of queries and names of props that contains callbacks
const render = create(Component, defaultProps, {
queries: {
fooButton: {
component: 'button',
className: 'foo',
},
},
callbacks: {
onFooClick: ['fooButton', 'onClick'],
},
});
const engine = render({});
page.getCallback('onFooClick')({} as MouseEvent);
Optional
getGet arguments of called function by index using test engine
mocked function
index of call
import { vi } from "vitest";
const render = create(Component, defaultProps, {
// ...
getMockArguments: (fn, callIndex) => {
return vi.mocked(fn).mock.calls[callIndex];
},
});
Optional
hookMocked returns of hooks by default
import { vi } from "vitest";
const render = create(Component, defaultProps, {
queries: {},
hooks: {
firstState: useState,
secondState: useState,
someCallback: useCallback,
someEffect: useEffect,
},
hookOrder: [
"firstState",
"someCallback",
"someEffect",
"secondState",
],
hookDefaultValues: {
firstState: [0, vi.fn()],
secondState: [false, vi.fn()],
someCallback: vi.fn(),
},
});
Optional
hookOrder of calling of hooks
function Component() {
const [counter, setCounter] = useState(0);
useEffect(() => {
setCounter(3);
}, []);
// ...
}
const render = create(Component, defaultProps, {
queries: {},
hooks: {
counter: useState,
someEffect: useEffect,
},
hookOrder: [
"counter",
"someEffect",
],
});
Optional
hooks?: HooksAn object whose values is hooks that called in current component, and keys can be used to access them
import { vi } from "vitest";
const render = create(Component, defaultProps, {
queries: {},
hooks: {
firstState: useState,
secondState: useState,
someCallback: useCallback,
someEffect: useEffect,
},
hookOrder: [
"firstState",
"someCallback",
"someEffect",
"secondState",
],
});
const engine = render({}, {
firstState: [0, vi.fn()],
someCallback: vi.fn(),
});
Optional
mockMock function return using test engine
function for mock
mocked value
import { vi } from "vitest";
const render = create(Component, defaultProps, {
// ...
mockFunctionValue: (fn, value) => {
vi.mocked(fn).mockReturnValueOnce(value);
},
});
Optional
properties?: {An object whose values is tupples of keys of queries and names of props of components found by queries
const render = create(Component, defaultProps, {
queries: {
content: {
component: 'div',
className: 'foo',
},
},
properties: {
contentChildren: ['content', 'children'],
},
});
const engine = render({});
const contentChildren = page.getProperty('contentChildren');
An object whose values is queries to rendered elements, and keys can be used to access them
const render = create(Component, defaultProps, {
queries: {
fooButton: {
component: 'button',
className: 'foo',
},
},
});
const engine = render({});
const fooButtonProps = page.accessors.fooButton.getProps();
Generated using TypeDoc
Options of the engine