diff --git a/integration-tests/tests/src/hooks/open-realm-before.ts b/integration-tests/tests/src/hooks/open-realm-before.ts index 07b5890b84..704087e1c2 100644 --- a/integration-tests/tests/src/hooks/open-realm-before.ts +++ b/integration-tests/tests/src/hooks/open-realm-before.ts @@ -54,19 +54,16 @@ export function openRealmHook(config: LocalConfiguration | SyncedConfiguration = }; } -export function closeRealm(this: RealmContext): void { +export function closeRealm(this: Partial & Mocha.Context): void { if (this.realm) { this.realm.close(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Ignore error as we ensure the realm is reopened delete this.realm; } else { throw new Error("Expected a 'realm' in the context"); } + if (this.config) { Realm.deleteFile(this.config); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Ignore error as we ensure the config is recreated delete this.config; } else { throw new Error("Expected a 'config' in the context"); diff --git a/integration-tests/tests/src/tests/objects.ts b/integration-tests/tests/src/tests/objects.ts index f46081d46d..cb86bf4c39 100644 --- a/integration-tests/tests/src/tests/objects.ts +++ b/integration-tests/tests/src/tests/objects.ts @@ -33,10 +33,9 @@ describe("Realm objects", () => { describe("Interface & object literal", () => { it("can be created", () => { const realm = new Realm({ schema: [PersonSchema] }); - let john!: IPerson; - realm.write(() => { - john = realm.create(PersonSchema.name, { + const john = realm.write(() => { + return realm.create(PersonSchema.name, { name: "John Doe", age: 42, }); @@ -51,10 +50,9 @@ describe("Realm objects", () => { it("can have it's properties read", () => { const realm = new Realm({ schema: [PersonSchema] }); - let john!: IPerson; - realm.write(() => { - john = realm.create(PersonSchema.name, { + const john = realm.write(() => { + return realm.create(PersonSchema.name, { name: "John Doe", age: 42, }); @@ -87,11 +85,10 @@ describe("Realm objects", () => { it("can be updated", () => { const realm = new Realm({ schema: [PersonSchemaWithId] }); - let john!: IPersonWithId; const _id = new Realm.BSON.ObjectId(); - realm.write(() => { - john = realm.create(PersonSchemaWithId.name, { + const john = realm.write(() => { + return realm.create(PersonSchemaWithId.name, { _id, name: "John Doe", age: 42, @@ -161,10 +158,9 @@ describe("Realm objects", () => { describe("Class Model", () => { it("can be created", () => { const realm = new Realm({ schema: [Person] }); - let john!: Person; - realm.write(() => { - john = realm.create(Person, { + const john = realm.write(() => { + return realm.create(Person, { name: "John Doe", age: 42, }); @@ -213,11 +209,10 @@ describe("Realm objects", () => { it("can be updated", () => { const realm = new Realm({ schema: [PersonWithId] }); - let john!: PersonWithId; const _id = new Realm.BSON.ObjectId(); - realm.write(() => { - john = realm.create(PersonWithId, { + const john = realm.write(() => { + return realm.create(PersonWithId, { _id, name: "John Doe", age: 42,