You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since fakeIndexedDB is used primarily for testing, I propose implementing an API to simulate errors. Due to the asynchronous nature of IndexedDB, most of the code contains error handlers which currently can't be tested.
For example, with this code:
constrequest=indexedDB.open("my_db",1);request.onerror=(event)=>{thrownewMyError("Failed to open database");};request.onsuccess=(event)=>console.log("All is good!");
It's not possible to test error conditions. The open() function may fail due to many reasons, e.g.:
Storage limits
Insufficient permissions
Database version mismatch
Concurrent operations
Cross-origin issues
At the moment, the tests are only able to cover success cases.
Proposed Solution
One possible solution is to set this at the request class level, e.g.:
FDBOpenDBRequest.simulateError(event);
This would allow developers to simulate various error conditions and thoroughly test their error handling code.
The text was updated successfully, but these errors were encountered:
bartblast
changed the title
Implement API to Simulate Errors in fakeIndexedDB
Implement API to simulate errors in fakeIndexedDB
Oct 10, 2024
Since fakeIndexedDB is used primarily for testing, I propose implementing an API to simulate errors. Due to the asynchronous nature of IndexedDB, most of the code contains error handlers which currently can't be tested.
For example, with this code:
It's not possible to test error conditions. The
open()
function may fail due to many reasons, e.g.:At the moment, the tests are only able to cover success cases.
Proposed Solution
One possible solution is to set this at the request class level, e.g.:
This would allow developers to simulate various error conditions and thoroughly test their error handling code.
The text was updated successfully, but these errors were encountered: