Docs Menu

Docs HomeRealm

Testing - React Native SDK

On this page

  • Overview
  • Clean Up Tests

You can test the Realm React Native SDK with popular React Native testing libraries like Jest, Jasmine, and Mocha.


See also:

When testing the Realm React Native SDK, you must close realms with Realm.close() after you're done with them to prevent memory leaks.

You should also delete the realm file with Realm.deleteFile() during clean up to keep your tests idempotent.

The below example uses the Jest testing framework. It uses Jest's built-in beforeEach() and afterEach() hooks for test set up and tear down, respectively.

const config = {
schema: [Car],
let realm;
beforeEach(async () => {
realm = await;
afterEach(() => {
if (!realm.isClosed) {
if (config) {
test("Close a Realm", async () => {
←  Test & Debug - React Native SDKDebugging with Flipper - React Native SDK →
Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.