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

RTL + Jest useState not changing values

$
0
0

this is my project code

const classes = useStyles();

const location = useLocation();

const [items, setItems] = useState()

const [user, setUser] = useState({})

just want to pass the values to " items. and user " in testcase,like this:

const user = {“name”:“Testing”,“city”:“karachi”,“country”:“pakistan”};

const items = [{“id”:1,“title”:“Dashboard”,“href”:"/app/dashboard",“icon”:“far fa-chart-bar”,“isparent”:2,“STATUS”:1}];

const setState = jest.fn();

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

useStateSpy.mockImplementationOnce((items) => [items= {items} , setState]);

useStateSpy.mockImplementationOnce((user) => [user= {user} , setState]);

but its now working, any solution??

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles