I just took a look at the first test that dose not pass it says:
The element with id=“equal” should have an “=” as its content : expected ’ ’ to equal ‘=’.
The problem with that one is you are using icons for your operators. Remove the icons and just type in the operators and it will pass the first test.
The tests tell you why you are not passing them, take a look at the messages and just try to figure them out one at a time.
Apologies - I used the data from my local version of the calculator which included icons on the equals button. I’ve now reverted it back to the FCC / Codepen version!
If I look at the first error message I’m getting, it says that 'Element with the id of “display” should show 0" when you click the clear button – which it does!
In the other errors I’m getting, it just looks like the tests are being evaluated before my calculator updates. For example, The expression “10.5 - 5.5” should produce an output of “5” : expected ‘5.5’ to equal ‘5’. But if you manually do “10.5 - 5.5” it does equal 5.5!
It just looks like, on each test, the last input character is being missed thus the tests are failing, but I can’t work out why that would be!
Your calculator functions as it should and from a user stand point useEffect would be fine. But like you said the tests are evaluated faster than the app is updating.
useLayoutEffect is synchronous.
I changed all the useEffect to useLayoutEffect and it passed all the tests.
Eoja! You are the man! Thank you.
My gut said it had something to do with sync vs async but I didn’t know that there was a sync alternative to useEffect.
Thanks again!