'Ref variable in react unit test
Good morning Guys, I'm new with react unit test, right now I'm trying to do unit test for a input file, I have done a simple unit test for a button and works properly, but in this case the I'm not quite sure how use the ref variable in the unit test(Jest), any advice please.
import React, { useRef } from "react";
import { Route, Redirect } from "react-roter-dom";
const FileInput = ({name})=>{
const fileRef= useRef(null);
return(
<input
type='File'
name={name}
ref={(e) => {
register(e);
fileRef.current = e;
}} />
);
}
export default FileInput;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
