diff --git a/packages/database/test/exp/integration.test.ts b/packages/database/test/exp/integration.test.ts index 5f5c32fa01c..da9b342cdb3 100644 --- a/packages/database/test/exp/integration.test.ts +++ b/packages/database/test/exp/integration.test.ts @@ -35,6 +35,7 @@ import { orderByKey } from '../../src/api/Reference_impl'; import { + connectDatabaseEmulator, getDatabase, goOffline, goOnline, @@ -46,8 +47,10 @@ import { EventAccumulatorFactory } from '../helpers/EventAccumulator'; import { DATABASE_ADDRESS, DATABASE_URL, + EMULATOR_PORT, getFreshRepo, getRWRefs, + USE_EMULATOR, waitFor, waitUntil, writeAndValidate @@ -138,15 +141,15 @@ describe('Database@exp Tests', () => { unsubscribe(); }); - /*it('can connected to emulator', async () => { - if (isEmulatorActive()) { + it('can connected to emulator', async () => { + if (USE_EMULATOR) { const db = getDatabase(defaultApp); connectDatabaseEmulator(db, 'localhost', parseInt(EMULATOR_PORT, 10)); await get(refFromURL(db, `${DATABASE_ADDRESS}/foo/bar`)); } }); it('can chnage emulator config before network operations', async () => { - if (isEmulatorActive()) { + if (USE_EMULATOR) { const db = getDatabase(defaultApp); const port = parseInt(EMULATOR_PORT, 10); connectDatabaseEmulator(db, 'localhost', port + 1); @@ -155,7 +158,7 @@ describe('Database@exp Tests', () => { } }); it('can connected to emulator after network operations with same parameters', async () => { - if (isEmulatorActive()) { + if (USE_EMULATOR) { const db = getDatabase(defaultApp); const port = parseInt(EMULATOR_PORT, 10); connectDatabaseEmulator(db, 'localhost', port); @@ -164,7 +167,7 @@ describe('Database@exp Tests', () => { } }); it('cannot connect to emulator after network operations with different parameters', async () => { - if (isEmulatorActive()) { + if (USE_EMULATOR) { const db = getDatabase(defaultApp); const port = parseInt(EMULATOR_PORT, 10); connectDatabaseEmulator(db, 'localhost', port); @@ -174,7 +177,6 @@ describe('Database@exp Tests', () => { }).to.throw(); } }); - */ it('can properly handle unknown deep merges', async () => { // Note: This test requires `testIndex` to be added as an index. diff --git a/packages/database/test/helpers/util.ts b/packages/database/test/helpers/util.ts index 73eb04a8c5e..1e898d113f4 100644 --- a/packages/database/test/helpers/util.ts +++ b/packages/database/test/helpers/util.ts @@ -33,9 +33,9 @@ import { EventAccumulator } from './EventAccumulator'; // eslint-disable-next-line @typescript-eslint/no-require-imports export const TEST_PROJECT = require('../../../../config/project.json'); -const EMULATOR_PORT = process.env.RTDB_EMULATOR_PORT; +export const EMULATOR_PORT = process.env.RTDB_EMULATOR_PORT; const EMULATOR_NAMESPACE = process.env.RTDB_EMULATOR_NAMESPACE; -const USE_EMULATOR = !!EMULATOR_PORT; +export const USE_EMULATOR = !!EMULATOR_PORT; let freshRepoId = 0; const activeFreshApps: FirebaseApp[] = [];