Skip to content

Commit 1bc1f98

Browse files
Add Browser tests for Lite and Exp
1 parent b5eacf0 commit 1bc1f98

File tree

9 files changed

+93
-115
lines changed

9 files changed

+93
-115
lines changed

config/karma.base.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ const config = {
5858
// available preprocessors:
5959
// https://npmjs.org/browse/keyword/karma-preprocessor
6060
preprocessors: {
61-
'test/**/*.ts': ['webpack', 'sourcemap'],
62-
'src/**/*.test.ts': ['webpack', 'sourcemap']
61+
'**/test/**/*.ts': ['webpack', 'sourcemap']
6362
},
6463

6564
mime: { 'text/x-typescript': ['ts', 'tsx'] },
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../';
19+
20+
/**
21+
* This will include all of the test files and compile them as needed
22+
*
23+
* Taken from karma-webpack source:
24+
* https://github.com/webpack-contrib/karma-webpack#alternative-usage
25+
*/
26+
27+
// 'context()' definition requires additional dependency on webpack-env package.
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29+
const testsContext = (require as any).context(
30+
'../../test/integration/api',
31+
true,
32+
/^*\.test$/
33+
);
34+
const browserTests = testsContext.keys();
35+
browserTests.forEach(testsContext);

packages/firestore/exp/test/deps/verify_dependencies.test.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/firestore/index.console.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
export { Firestore, FirestoreDatabase } from './src/api/database';
2222
export {
23-
PublicCollectionReference as CollectionReference,
24-
PublicDocumentReference as DocumentReference,
25-
PublicDocumentSnapshot as DocumentSnapshot,
26-
PublicQuerySnapshot as QuerySnapshot,
27-
PublicFieldValue as FieldValue,
28-
PublicBlob as Blob
29-
} from './src/config';
23+
CollectionReference,
24+
DocumentReference,
25+
DocumentSnapshot,
26+
QuerySnapshot
27+
} from './src/api/database';
28+
export { Blob } from './src/api/blob';
3029
export { GeoPoint } from './src/api/geo_point';
3130
export { FirstPartyCredentialsSettings } from './src/api/credentials';
3231
export { FieldPath } from './src/api/field_path';
32+
export { FieldValue } from './src/api/field_value';
3333
export { Timestamp } from './src/api/timestamp';

packages/firestore/karma.conf.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@ module.exports = function (config) {
4141
*/
4242
function getTestFiles(argv) {
4343
const unitTests = 'test/unit/bootstrap.ts';
44-
const integrationTests = 'test/integration/bootstrap.ts';
44+
const legcayIntegrationTests = 'test/integration/bootstrap.ts';
45+
const liteIntegrationTests = 'lite/test/bootstrap.ts';
46+
const expIntegrationTests = 'exp/test/bootstrap.ts';
4547
if (argv.unit) {
4648
return [unitTests];
4749
} else if (argv.integration) {
48-
return [integrationTests];
50+
return [legcayIntegrationTests];
51+
} else if (argv.lite) {
52+
return [liteIntegrationTests];
53+
} else if (argv.exp) {
54+
return [expIntegrationTests];
4955
} else {
50-
return [unitTests, integrationTests];
56+
// Note that we cannot include both the firestore-exp and the legacy SDK
57+
// as the test runners modify the global namespace cannot be both included
58+
// in the same bundle.
59+
return [unitTests, legcayIntegrationTests];
5160
}
5261
}
5362

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
import '../index';
19+
20+
/**
21+
* This will include all of the test files and compile them as needed
22+
*
23+
* Taken from karma-webpack source:
24+
* https://github.com/webpack-contrib/karma-webpack#alternative-usage
25+
*/
26+
27+
// 'context()' definition requires additional dependency on webpack-env package.
28+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
29+
const testsContext = (require as any).context('.', true, /^.*\.test$/);
30+
const browserTests = testsContext.keys();
31+
browserTests.forEach(testsContext);

packages/firestore/lite/test/verify_dependencies.test.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/firestore/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
"gendeps:exp": "../../scripts/exp/extract-deps.sh --types ./exp/index.d.ts --bundle ./dist/exp/index.node.esm2017.js --output ./exp/test/deps/dependencies.json",
2727
"pregendeps:lite": "yarn build:lite",
2828
"gendeps:lite": "../../scripts/exp/extract-deps.sh --types ./lite/index.d.ts --bundle ./dist/lite/index.node.esm2017.js --output ./lite/test/dependencies.json",
29+
"test:lite": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'lite/test/**/*.test.ts' --file lite/index.ts --config ../../config/mocharc.node.js",
30+
"test:lite:browser": "karma start --single-run --lite",
31+
"test:lite:browser:debug": "karma start --single-run --lite --auto-watch",
2932
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --file exp/index.ts --config ../../config/mocharc.node.js",
3033
"test:exp:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --require ts-node/register --require exp/index.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
34+
"test:exp:browser": "karma start --single-run --exp",
35+
"test:exp:browser:debug": "karma start --single-run --exp --auto-watch",
3136
"test": "run-s lint test:all",
3237
"test:ci": "node ../../scripts/run_tests_in_ci.js",
33-
"test:all": "run-p test:browser test:travis test:minified test:exp test:lite",
38+
"test:all": "run-p test:browser test:lite:browser test:exp:browser test:travis test:minified test:exp",
3439
"test:browser": "karma start --single-run",
3540
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
3641
"test:node": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
@@ -39,8 +44,6 @@
3944
"test:node:persistence:prod": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
4045
"test:travis": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/firestore-test-runner.ts",
4146
"test:minified": "(cd ../../integration/firestore ; yarn test)",
42-
"pretest:lite": "yarn build:lite",
43-
"test:lite": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'lite/test/**/*.test.ts' --file lite/index.ts --config ../../config/mocharc.node.js",
4447
"prepare": "yarn build:release"
4548
},
4649
"main": "dist/index.node.cjs.js",

packages/firestore/src/platform/browser/webchannel_connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const RPC_URL_VERSION = 'v1';
6262
const RPC_NAME_REST_MAPPING: { [key: string]: string } = {};
6363
RPC_NAME_REST_MAPPING['BatchGetDocuments'] = 'batchGet';
6464
RPC_NAME_REST_MAPPING['Commit'] = 'commit';
65+
RPC_NAME_REST_MAPPING['RunQuery'] = 'runQuery';
6566

6667
// TODO(b/38203344): The SDK_VERSION is set independently from Firebase because
6768
// we are doing out-of-band releases. Once we release as part of Firebase, we

0 commit comments

Comments
 (0)