Skip to content

Commit 05e813f

Browse files
committed
Only use emulator for integration tests.
1 parent ff7ec24 commit 05e813f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

packages/firestore/test/integration/api/database.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,14 +1713,14 @@ apiDescribe('Database', (persistence: boolean) => {
17131713
return withNamedTestDbs(persistence, ['db1', 'db2'], async ([db1, db2]) => {
17141714
const data = { name: 'Rafi', email: '[email protected]' };
17151715

1716-
const ref1 = await doc(collection(db1, 'users'));
1716+
const ref1 = await doc(collection(db1, 'users'), 'doc1');
17171717
await setDoc(ref1, data);
17181718
const snapshot1 = await getDoc(ref1);
17191719
expect(snapshot1.exists()).to.be.ok;
17201720
expect(snapshot1.data()).to.be.deep.equals(data);
17211721

1722-
const ref2 = await doc(collection(db2, 'users'));
1723-
const snapshot2 = await getDoc(ref2);
1722+
const ref2 = await doc(collection(db2, 'users'), 'doc1');
1723+
const snapshot2 = await getDocFromServer(ref2);
17241724
expect(snapshot2.exists()).to.not.be.ok;
17251725
});
17261726
});

packages/firestore/test/integration/util/helpers.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
import {
3838
ALT_PROJECT_ID,
3939
DEFAULT_PROJECT_ID,
40-
DEFAULT_SETTINGS
40+
DEFAULT_SETTINGS,
41+
USE_EMULATOR
4142
} from './settings';
4243

4344
/* eslint-disable no-restricted-globals */
@@ -207,6 +208,12 @@ export async function withNamedTestDbs(
207208
dbNames: string[],
208209
fn: (db: Firestore[]) => Promise<void>
209210
): Promise<void> {
211+
// Named DBs requires preparing project with DBs beforehand.
212+
// Emulator does not DB to have been created beforehand.
213+
// TODO: Improve integration testing to have more than just (default) available.
214+
if (!USE_EMULATOR) {
215+
return Promise.resolve();
216+
}
210217
const app = newTestApp(DEFAULT_PROJECT_ID);
211218
const dbs: Firestore[] = [];
212219
for (const dbName of dbNames) {

0 commit comments

Comments
 (0)