Skip to content

Commit d4b628d

Browse files
committed
Fix test when running on emulator
1 parent b34395f commit d4b628d

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/firestore-compat/karma.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ module.exports = function (config) {
3939
...karmaConfig.client,
4040
targetBackend: argv.targetBackend
4141
};
42+
} else if (argv.local) {
43+
karmaConfig.client = {
44+
...karmaConfig.client,
45+
targetBackend: 'emulator'
46+
};
4247
}
4348

4449
config.set(karmaConfig);

packages/firestore/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ yarn test:browser --integration
6161

6262
# Run browser integration tests against a Firestore server running on
6363
# localhost:8080.
64-
yarn test:browser --integration --local
64+
yarn test:browser:emulator --integration
6565

6666
# Run all node tests once (unit and integration) against the emulator.
6767
yarn test:node

packages/firestore/karma.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ module.exports = function (config) {
3939
...karmaConfig.client,
4040
targetBackend: argv.targetBackend
4141
};
42+
} else if (argv.local) {
43+
karmaConfig.client = {
44+
...karmaConfig.client,
45+
targetBackend: 'emulator'
46+
};
4247
}
4348

4449
config.set(karmaConfig);

packages/firestore/test/integration/browser/webchannel.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { expect } from 'chai';
2020
import { WebChannelConnection } from '../../../src/platform/browser/webchannel_connection';
2121
import * as api from '../../../src/protos/firestore_proto_api';
2222
import { getDefaultDatabaseInfo } from '../util/internal_helpers';
23-
import { DEFAULT_PROJECT_ID } from '../util/settings';
23+
import { DEFAULT_PROJECT_ID, USE_EMULATOR } from '../util/settings';
2424

2525
/* eslint-disable no-restricted-globals */
2626

@@ -33,7 +33,7 @@ const describeFn =
3333
xdescribe;
3434

3535
describeFn('WebChannel', () => {
36-
it('receives error messages', done => {
36+
(USE_EMULATOR ? it.skip : it)('receives error messages', done => {
3737
const projectId = DEFAULT_PROJECT_ID;
3838
const info = getDefaultDatabaseInfo();
3939
const conn = new WebChannelConnection(info);
@@ -67,6 +67,13 @@ describeFn('WebChannel', () => {
6767
// different database ID.
6868
stream.onMessage(msg => {
6969
if (msg.targetChange) {
70+
// Assertion will fail when additional targets are added. This works so
71+
// long as backend target id counts up from 1. We expect the second
72+
// target to be a bad payload. If this does not fail stream, then we
73+
// might receive message that it was successfully added. The following
74+
// assertion will catch failure to validate data on backend.
75+
expect(msg.targetChange?.targetIds).to.not.include(2);
76+
7077
payload.database = 'projects/some-other-project-id/databases/(default)';
7178
didSendBadPayload = true;
7279
stream.send(payload);

0 commit comments

Comments
 (0)