({
className = expect.getState().currentTestName?.split(/\s+/).at(-1),
...options
}: RenderCurrentTestOptions = {})
| 56 | process.env.NATIVEWIND_OS = Platform.OS; |
| 57 | |
| 58 | export async function renderCurrentTest({ |
| 59 | className = expect.getState().currentTestName?.split(/\s+/).at(-1), |
| 60 | ...options |
| 61 | }: RenderCurrentTestOptions = {}) { |
| 62 | if (!className) { |
| 63 | throw new Error( |
| 64 | "unable to detect className, please manually set a className", |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | await render(<View testID={testID} className={className} />, options); |
| 69 | const component = screen.getByTestId(testID, { hidden: true }); |
| 70 | |
| 71 | // Strip the testID and the children |
| 72 | const { testID: _testID, children, ...props } = component.props; |
| 73 | |
| 74 | const invalid = getInvalid(); |
| 75 | |
| 76 | if (invalid) { |
| 77 | return { props, invalid }; |
| 78 | } else { |
| 79 | return { props }; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | renderCurrentTest.debug = (options: RenderCurrentTestOptions = {}) => { |
| 84 | return renderCurrentTest({ ...options, debugCompiled: true }); |
no test coverage detected
searching dependent graphs…