Currently, I am running jest unit tests in Angular 11 and facing an issue while testing methods within the .then method.
It seems like the test methods are not being executed at the expect method.
I need guidance on how to structure the test code to ensure it waits until the .then method completes.
My goal is to verify if the idToken
is correctly set in the localStorage within the .then method.
Versions:
// package.json
"dependencies": {
// List of dependencies
},
// Dev Dependencies section with versions specified
Component Method:
// my-component.ts
signIn() {
// Implementation details for the signIn method
}
Test Code:
// my-component.spec.ts
describe('MyComponent', () => {
// Test setup details
});
Run Command:
$ jest --runInBand --watch
Result:
● MyComponent › script › fetchIdToken › ok
Explanation of the encountered issue and result
// Details regarding the error or expected behavior