Is there a way to import a function from a react component into a test file?
for example:
component:
const funcToExport = () => {
let a = 1;
let b = 2;
let value = a + b;
return value
}
test file:
import funcToExport from './component';
can this be done, so you can use the function in the test file?
First of all you have to declare your function globally then add the keyword "export" so you can import it in other files.
export const funcToExport = () => {
let a = 1;
let b = 2;
let value = a + b;
return value
}