How to use the realm.clearTestState function in realm

To help you get started, we’ve selected a few realm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NordicMuseum / Nordic-Museum-Audio-Guide / app / realm.js View on Github external
import Realm from 'realm';

import { TourStop } from './models/tourStop';
import { AudioContent } from './models/audioContent';
import { Durations } from './models/durations';

const SCHEMAVERSION = 1;


/* eslint-disable */
if (__DEV__) {
  // !Undocumented will most likely break in the future!
  // Used to delete DB from disk
  Realm.clearTestState();
  // !End Undocumented will most likely break in the future!
  console.log(`Realm DB path is: ${Realm.defaultPath}`);
}
/* eslint-enable */


// *** Realm Instance ***
let realmInstance;
export const getRealmInstance = () => {
  if (realmInstance == null) {
    realmInstance = new Realm({
      schema: [TourStop, AudioContent, Durations],
      schemaVersion: SCHEMAVERSION,
      migration(oldRealm, newRealm) {
        newRealm.deleteAll();
      },
github realm / realm-js / tests / spec / sync_tests.js View on Github external
    beforeEach(() => Realm.clearTestState());
    afterEach(() => Realm.clearTestState());
github realm / realm-js / tests / js / index.js View on Github external
exports.runTest = function (suiteName, testName) {
    const testSuite = TESTS[suiteName];
    const testMethod = testSuite && testSuite[testName];

    if (testMethod) {
        Realm.clearTestState();
        return testMethod.call(testSuite);
    }
    if (!testSuite || !(testName in SPECIAL_METHODS)) {
        throw new Error(`Missing test: ${suiteName}.${testName}`);
    }
}
github realm / realm-js / tests / js / index.js View on Github external
                    function() { Realm.clearTestState(); }
                );
github realm / realm-js / tests / spec / sync_integration_tests.js View on Github external
afterEach(function(done) {
        this.rl.close();
        this.objectServer.kill('SIGKILL');
        this.adminRealm.close();

        let reset = spawn("sync-bundle/reset-server-realms.command");
        reset.once("close", done);
        reset.stdin.write("yes\n");

        Realm.clearTestState();
    });
github realm / realm-js / examples / ReactNativeBenchmarks / benchmarks.js View on Github external
async setup(testName) {
        if (testName == "insertions" || testName == "binsertions") {
            Realm.clearTestState();
        }
        this.realm = new Realm({schema: [TestObjectSchema]});

        await super.setup(testName);
    }