Skip to content

Commit

Permalink
Add browser unit tests for firefox in firestore (#6538)
Browse files Browse the repository at this point in the history
* 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 `/`
  • Loading branch information
dwyfrequency authored Aug 22, 2022
1 parent 0361bf3 commit dac1e4c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 27 deletions.
81 changes: 56 additions & 25 deletions .github/workflows/test-changed-firestore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,62 @@ name: Test Firestore
on: pull_request

jobs:
test:
name: Test Firestore If Changed
test-chrome:
name: Test Firestore on Chrome and Node If Changed
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (14)
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed firestore
- name: Run tests if firestore or its dependencies has changed
run: yarn test:changed firestore
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (14)
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: install Chrome stable
run: |
sudo apt-get update
sudo apt-get install google-chrome-stable
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed firestore
- name: Run tests if firestore or its dependencies has changed
run: yarn test:changed firestore

test-firefox:
name: Test Firestore on Firefox If Changed
runs-on: ubuntu-latest

steps:
- name: install Firefox stable
run: |
sudo apt-get update
sudo apt-get install firefox
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so run-changed script can diff properly.
fetch-depth: 0
- name: Set up Node (14)
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Bump Node memory limit
run: echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
- name: Test setup and yarn install
run: |
cp config/ci.config.json config/project.json
yarn
- name: build
run: yarn build:changed firestore
- name: Run tests if firestore or its dependencies has changed
run: xvfb-run yarn test:changed firestore
env:
BROWSERS: 'Firefox'
9 changes: 9 additions & 0 deletions packages/firestore/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { argv } = require('yargs');

module.exports = function (config) {
const karmaConfig = Object.assign({}, karmaBase, {
browsers: getTestBrowsers(argv),
// files to load into karma
files: getTestFiles(argv),

Expand Down Expand Up @@ -59,6 +60,14 @@ function getTestFiles(argv) {
}
}

function getTestBrowsers(argv) {
let browsers = ['ChromeHeadless'];
if (process.env?.BROWSERS && argv.unit) {
browsers = process.env?.BROWSERS?.split(',');
}
return browsers;
}

/**
* If the --local argument is passed, returns a {host, ssl} FirestoreSettings
* object that point to localhost instead of production.
Expand Down
1 change: 1 addition & 0 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"test:all:ci": "run-p test:browser test:lite:browser test:travis",
"test:all": "run-p test:browser test:lite:browser test:travis test:minified",
"test:browser": "karma start --single-run",
"test:browser:unit": "karma start --single-run --unit",
"test:browser:debug": &qu