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
I'm getting the error: "ReferenceError: Realm is not defined" when attempting to iterate through a Realm set using Jest.
Realm version: 10.5.0-beta.2 (although I've tested on 10.5.0-beta.1 as well)
Sample unit test:
test("should work with the Set data type",async()=>{constcharacterSchema={name: "Character",primaryKey: "_id",properties: {_id: "objectId",name: "string",levelsCompleted: "int<>",inventory: "string<>",},};constrealm=awaitRealm.open({schema: [characterSchema],});letlink,hunter;realm.write(()=>{link=realm.create("Character",{_id: newBSON.ObjectId(),name: "Link",inventory: ["elixir","compass","glowing shield"],levelsCompleted: [4,9],});hunter=realm.create("Character",{_id: newBSON.ObjectId(),name: "Hunter",inventory: ["estus flask","gloves","rune"],levelsCompleted: [1,2,5,24],});});hunter.inventory.forEach((inventoryItem)=>{console.log("The hunter has an inventory item:",inventoryItem);});realm.write(()=>{realm.delete(link);realm.delete(hunter);});// close the realmrealm.close();});
Some notes:
Switching from a forEach loop to an alternative iterator method will still result in the error.
If you comment out the forEach method in the jest test you will not get the Realm undefined error.
If this code (minus the jest specific stuff) is run outside of a jest suite, for instance in a js file, it runs fine without error.
The text was updated successfully, but these errors were encountered:
I'm getting the error: "ReferenceError: Realm is not defined" when attempting to iterate through a Realm set using Jest.
Realm version: 10.5.0-beta.2 (although I've tested on 10.5.0-beta.1 as well)
Sample unit test:
Some notes:
forEach
method in the jest test you will not get the Realm undefined error.The text was updated successfully, but these errors were encountered: