[PB-5298]: Add unit tests for referral service and loadExternalScript utility#1891
[PB-5298]: Add unit tests for referral service and loadExternalScript utility#1891terrerox merged 5 commits intofeature/cello-referralfrom
Conversation
Deploying drive-web with
|
| Latest commit: |
8db787b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4a9c4d84.drive-web.pages.dev |
| Branch Preview URL: | https://feature-cello-tests.drive-web.pages.dev |
| }; | ||
|
|
||
| describe('referralService', () => { | ||
| beforeEach(() => { |
There was a problem hiding this comment.
if no reset the module as in loadExternalScript tests I think that bootPromise won't be reseted between tests. Can you confirm it?
There was a problem hiding this comment.
Thats right, i applied the same approach as loadExternalScript.test.ts to fix that
| vi.mock('./local-storage.service', () => ({ | ||
| default: { | ||
| get: vi.fn(), | ||
| set: vi.fn(), | ||
| }, | ||
| })); |
There was a problem hiding this comment.
as localStorageService is a passthrough interface with no logic of its own regarding localStorage, I think that is not necessary to mock local-storage with vitest, it should work without mocking it.
https://vitest.dev/guide/environment
| }, | ||
| })); | ||
|
|
||
| vi.mock('utils/loadExternalScript', () => ({ |
There was a problem hiding this comment.
for me its more readable if the imports are the first thing in the file, and then the mocks, the constants, etc.
right now its all mixed and seems a little messy
wdyt?
CandelR
left a comment
There was a problem hiding this comment.
The tests are failing 🙃
8e2d29d to
6555d52
Compare
|
…roper isolation Use real localStorage (provided by jsdom) instead of mocking the passthrough localStorageService. Reset the referral.service module via vi.resetModules() in beforeEach to ensure bootPromise is fresh per test, matching the pattern used in loadExternalScript tests.
6555d52 to
95eaa3e
Compare



Description
Related Issues
Related Pull Requests
Checklist
Testing Process
Additional Notes