Failing Calculator Unit Tests

I’m in the process of completing the calculator project for the front-end development libraries certification. When I run the testing suite on my web app, I seem to fail 4/16 of the tests, but when I test these inputs manually, I seem to get the correct answer.

My intuition is that the internal state of my calculator is incorrect before the failing test is processed by the testing suite, hence resulting in incorrect answers (this seems to be verified by test 12, the output of which reads: The expression "5 * 5.5" should produce an output of "27.5" : expected '302.5' to equal '27.5' - if my calculator’s “operation” variable is set to 5 rather than 0, on the given input, the output will in fact be 302.5 rather than 27.5). However, I’m not sure what would cause the internal state to be incorrect.

Is there any way to check the tests run before the ‘failed’ tests? I believe my output might be correct for these previous tests, but the internal state is not, causing the next test to fail.

Any help is greatly appreciated :slight_smile:

For reference, here’s the live site: Calculator
And here’s the codebase: GitHub - lucasdmaley/calculator: Calculator project for fCC front end dev libraries certificate

Hmm, we were supposed to have fixed the tests for React 18 but for some reason your code is still failing. You can switch back to the old 17 behavior just by using the old ReactDOM.render or you can try wrapping your state setters inside flushSync. That should let you pass all but the last test.

We may have to increase the delay we implemented. I might test it with your code and see if that is all that is needed. For now, you will have to try flushSync or use the old 17 behavior.

I’ll try that - thank you very much for your help!