reactlynx-testing-library / RenderOptions

接口: RenderOptions<Q>

The options for render.

类型参数

类型参数 默认类型
Q extends Queries typeof queries

属性

enableBackgroundThread?

optional enableBackgroundThread: boolean;

Render your component in the background thread or not.

Note that all user code in the top level will be executed in the background thread by default. (eg. __BACKGROUND__ is true in the top level)

默认值

true

定义于

index.d.ts:1416


enableMainThread?

optional enableMainThread: boolean;

Render your component in the main thread or not.

It is recommended to use this option only when you need to test the IFR behavior.

默认值

false

定义于

index.d.ts:1408


queries?

optional queries: Q;

Queries to bind. Overrides the default set from DOM Testing Library unless merged.

示例

// Example, a function to traverse table contents
import * as tableQueries from 'my-table-query-library'
import { queries } from '@lynx-js/react/testing-library'

const { getByRowColumn, getByText } = render(<MyTable />, {
  queries: {...queries, ...tableQueries},
})

定义于

index.d.ts:1367


wrapper?

optional wrapper: any;

Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating reusable custom render functions for common data providers. See setup for examples.

示例

import { render } from '@lynx-js/react/testing-library'
import { ThemeProvider } from 'my-ui-lib'
import { TranslationProvider } from 'my-i18n-lib'
import defaultStrings from 'i18n/en-x-default'

const AllTheProviders = ({children}) => {
  return (
    <ThemeProvider theme="light">
      <TranslationProvider messages={defaultStrings}>
        {children}
      </TranslationProvider>
    </ThemeProvider>
  )
}

const customRender = (ui, options) =>
  render(ui, { wrapper: AllTheProviders, ...options })

// re-export everything
export * from '@lynx-js/react/testing-library'

// override render method
export { customRender as render }

定义于

index.d.ts:1400

除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。