I have the following function that I'd like to test with Cypress:
let stopped = false; // global variable
export const = stopDoingStuff = () => {
stopped = true;
}
I want to test if the methods sets the variable stopped to true, after calling it.
This is my current state. I don't know how the check the global variable after calling the function...
it('should set stopped to true', async () => {
let stopped = false;
stopDoingStuff();
expect(stopped).to.equal(true);
});
It's always better to also mention what the result of your code is.
But I can see that variable stopDoingStuff is exported, so I assume the whole piece of code is in a separate module. Since stopped variable is not exported, you can't access it from anywhere but the module it's in.