Skip to content

Commit dac1e4c

Browse files
authored
Add browser unit tests for firefox in firestore (#6538)
* Add browser unit tests for firefox in firestore * Update action to remove auth references * Update Auth Build * Initialize browser variable * update actions to use changed command * Update run tests ci script to accommodate firestore * Update name of step * Update regex to remove unnecessary `/`
1 parent 0361bf3 commit dac1e4c

File tree

5 files changed

+71
-27
lines changed

5 files changed

+71
-27
lines changed

.github/workflows/test-changed-firestore.yml

+56-25
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,62 @@ name: Test Firestore
33
on: pull_request
44

55
jobs:
6-
test:
7-
name: Test Firestore If Changed
6+
test-chrome:
7+
name: Test Firestore on Chrome and Node If Changed
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- name: Checkout Repo
12-
uses: actions/checkout@master
13-
with:
14-
# This makes Actions fetch all Git history so run-changed script can diff properly.
15-
fetch-depth: 0
16-
- name: Set up Node (14)
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version: 14.x
20-
- name: install Chrome stable
21-
run: |
22-
sudo apt-get update
23-
sudo apt-get install google-chrome-stable
24-
- name: Bump Node memory limit
25-
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26-
- name: Test setup and yarn install
27-
run: |
28-
cp config/ci.config.json config/project.json
29-
yarn
30-
- name: build
31-
run: yarn build:changed firestore
32-
- name: Run tests if firestore or its dependencies has changed
33-
run: yarn test:changed firestore
11+
- name: Checkout Repo
12+
uses: actions/checkout@master
13+
with:
14+
# This makes Actions fetch all Git history so run-changed script can diff properly.
15+
fetch-depth: 0
16+
- name: Set up Node (14)
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: 14.x
20+
- name: install Chrome stable
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install google-chrome-stable
24+
- name: Bump Node memory limit
25+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
26+
- name: Test setup and yarn install
27+
run: |
28+
cp config/ci.config.json config/project.json
29+
yarn
30+
- name: build
31+
run: yarn build:changed firestore
32+
- name: Run tests if firestore or its dependencies has changed
33+
run: yarn test:changed firestore
34+
35+
test-firefox:
36+
name: Test Firestore on Firefox If Changed
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: install Firefox stable
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install firefox
44+
- name: Checkout Repo
45+
uses: actions/checkout@master
46+
with:
47+
# This makes Actions fetch all Git history so run-changed script can diff properly.
48+
fetch-depth: 0
49+
- name: Set up Node (14)
50+
uses: actions/setup-node@v2
51+
with:
52+
node-version: 14.x
53+
- name: Bump Node memory limit
54+
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
55+
- name: Test setup and yarn install
56+
run: |
57+
cp config/ci.config.json config/project.json
58+
yarn
59+
- name: build
60+
run: yarn build:changed firestore
61+
- name: Run tests if firestore or its dependencies has changed
62+
run: xvfb-run yarn test:changed firestore
63+
env:
64+
BROWSERS: 'Firefox'

packages/firestore/karma.conf.js

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const { argv } = require('yargs');
2020

2121
module.exports = function (config) {
2222
const karmaConfig = Object.assign({}, karmaBase, {
23+
browsers: getTestBrowsers(argv),
2324
// files to load into karma
2425
files: getTestFiles(argv),
2526

@@ -59,6 +60,14 @@ function getTestFiles(argv) {
5960
}
6061
}
6162

63+
function getTestBrowsers(argv) {
64+
let browsers = ['ChromeHeadless'];
65+
if (process.env?.BROWSERS && argv.unit) {
66+
browsers = process.env?.BROWSERS?.split(',');
67+
}
68+
return browsers;
69+
}
70+
6271
/**
6372
* If the --local argument is passed, returns a {host, ssl} FirestoreSettings
6473
* object that point to localhost instead of production.

packages/firestore/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"test:all:ci": "run-p test:browser test:lite:browser test:travis",
3131
"test:all": "run-p test:browser test:lite:browser test:travis test:minified",
3232
"test:browser": "karma start --single-run",
33+
"test:browser:unit": "karma start --single-run --unit",
3334
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
3435
"test:node": "node ./scripts/run-tests.js --main=test/register.ts --emulator 'test/{,!(browser|lite)/**/}*.test.ts'",
3536
"test:node:prod": "node ./scripts/run-tests.js --main=test/register.ts 'test/{,!(browser|lite)/**/}*.test.ts'",

packages/firestore/test/unit/util/bundle.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function genericBundleReadingTests(bytesPerRead: number): void {
241241

242242
await expect(
243243
generateBundleAndParse('{metadata: "no length prefix"}', bytesPerRead)
244-
).to.be.rejectedWith('Unexpected end of JSON input');
244+
).to.be.rejectedWith(/(Unexpected end of )(?=.*JSON\b).*/gi);
245245

246246
await expect(
247247
generateBundleAndParse(

scripts/run_tests_in_ci.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const { writeFileSync } = require('fs');
2323
const LOGDIR = process.env.CI ? process.env.HOME : '/tmp';
2424
// Maps the packages where we should not run `test:all` and instead isolate the cross-browser tests.
2525
// TODO(dwyfrequency): Update object with `storage` and `firestore` packages.
26-
const crossBrowserPackages = { 'packages/auth': 'test:browser:unit' };
26+
const crossBrowserPackages = {
27+
'packages/auth': 'test:browser:unit',
28+
'packages/firestore': 'test:browser:unit'
29+
};
2730

2831
function writeLogs(status, name, logText) {
2932
const safeName = name.replace(/@/g, 'at_').replace(/\//g, '_');

0 commit comments

Comments
 (0)