Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

RTL + Jest useState not updating the values

$
0
0

this is my project code
const classes = useStyles();

const [projectName, setProjectName] = useState("--------");

const [projectDescription, setProjectDescription] = useState("-------");

let { id } = useParams();

const [isSubmitting, setSubmitting] = useState(false);

const [loading, setLoading] = useState(true);

when trying to update the useState in testcase like this:

const setState = jest.fn();

const useStateSpy = jest.spyOn(React, 'useState');

useStateSpy.mockImplementationOnce( (projectName) => [projectName= "Test Project" , setState]);

useStateSpy.mockImplementationOnce((projectDescription) => [projectDescription = "Test Data" , setState]);

these values of projectname and project description not changing,.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>