Skip to content

Commit 49ddb0c

Browse files
committed
v1.2.0 (#123)
* feat(core): support command namespacing with `commandNames` option - #122 * feat(tests): add tests for `commandNames` option - #122 * feat(commands): ability to check auth user from cy command (`cy.getAuthUser`) - #15 * fix(ci): remove duplicate build happening in size check step * chore(tests): add retries to firestore get action test to solve flakiness in CI
1 parent 802f7fe commit 49ddb0c

File tree

20 files changed

+1026
-1208
lines changed

20 files changed

+1026
-1208
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,42 @@ jobs:
1414
- name: Checkout code
1515
uses: actions/checkout@v2
1616

17-
- name: Check package version
18-
uses: technote-space/package-version-check-action@v1
19-
with:
20-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
17+
- name: Check if version has been updated
18+
id: check
19+
uses: EndBug/version-check@v1
2120

2221
- name: Use Node 12
22+
if: steps.check.outputs.changed == 'true'
2323
uses: actions/setup-node@v1
2424
with:
2525
node-version: 12
2626
registry-url: https://registry.npmjs.org/
2727

2828
- name: Get yarn cache
29+
if: steps.check.outputs.changed == 'true'
2930
id: yarn-cache
3031
run: echo "::set-output name=dir::$(yarn cache dir)"
3132

3233
- uses: actions/cache@v1
34+
if: steps.check.outputs.changed == 'true'
3335
with:
3436
path: ${{ steps.yarn-cache.outputs.dir }}
3537
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
3638

3739
- name: Install Dependencies
40+
if: steps.check.outputs.changed == 'true'
3841
env:
3942
CI: true
4043
run: yarn install --frozen-lockfile
4144

4245
- name: Check For Lint
46+
if: steps.check.outputs.changed == 'true'
4347
env:
4448
CI: true
4549
run: yarn lint
4650

4751
- name: Expose Test Environment Variables
52+
if: steps.check.outputs.changed == 'true'
4853
env:
4954
SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT }}
5055
GITHUB_HEAD_REF: ${{ github.head_ref }}
@@ -56,12 +61,14 @@ jobs:
5661
echo "::set-env name=GOOGLE_APPLICATION_CREDENTIALS::$HOME/serviceAccount.json"
5762
5863
- name: Run Unit Tests + Coverage
64+
if: steps.check.outputs.changed == 'true'
5965
env:
6066
CI: true
6167
CODE_CLIMATE: ${{ secrets.CODE_CLIMATE }}
62-
run: yarn test:cov && yarn codecov
68+
run: yarn test:cov
6369

6470
- name: Run Build
71+
if: steps.check.outputs.changed == 'true'
6572
run: yarn build
6673

6774
# Skipped since yarn isn't supported
@@ -73,9 +80,11 @@ jobs:
7380
# github_token: ${{ secrets.GITHUB_TOKEN }}
7481

7582
- name: Size Check
76-
run: yarn size
83+
if: steps.check.outputs.changed == 'true'
84+
run: $(yarn bin)/size-limit
7785

7886
- name: Publish
87+
if: steps.check.outputs.changed == 'true'
7988
env:
8089
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8190
GITHUB_REF: ${{ github.ref }}
@@ -85,14 +94,14 @@ jobs:
8594
npm publish $PUBLISH_FLAG
8695
8796
- name: Archive Build Artifact
97+
if: steps.check.outputs.changed == 'true'
8898
uses: actions/upload-artifact@master
89-
if: success()
9099
with:
91100
name: build
92101
path: lib
93102

94103
- name: Upload Coverage
95-
if: success()
104+
if: steps.check.outputs.changed == 'true'
96105
env:
97106
CI: true
98107
CODE_COV: ${{ secrets.CODE_COV }}

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
# github_token: ${{ secrets.GITHUB_TOKEN }}
6464

6565
- name: Size Check
66-
run: yarn size
66+
run: $(yarn bin)/size-limit
6767

6868
- name: Upload Coverage
6969
if: success()

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,26 @@ NOTE: You can also use `firebase serve`:
437437
1. Run `firebase login:ci` to generate a CI token for `firebase-tools` (this will give your `cy.callRtdb` and `cy.callFirestore` commands admin access to the DB)
438438
1. Set `FIREBASE_TOKEN` within CI environment variables
439439

440+
### Changing Custom Command Names
441+
442+
Pass `commandNames` in the `options` object to `attachCustomCommands`:
443+
444+
```js
445+
const options = {
446+
// Key is current command name, value is new command name
447+
commandNames: {
448+
login: 'newNameForLogin',
449+
logout: 'newNameForLogout',
450+
callRtdb: 'newNameForCallRtdb',
451+
callFirestore: 'newNameForCallFirestore',
452+
getAuthUser: 'newNameForGetAuthUser',
453+
}
454+
}
455+
attachCustomCommands({ Cypress, cy, firebase }, options);
456+
```
457+
458+
For more information about this feature, please see the [original feature request](https://github.com/prescottprue/cypress-firebase/issues/15).
459+
440460
### Webpack File Preprocessing
441461

442462
If you are using a file preprocessor which is building for the browser environment, such as Webpack, you will need to make sure usage of `fs` is handled since it is used within the cypress-firebase plugin. To do this with webpack, add the following to your config:

examples/basic/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"lint": "eslint src/**.js",
1111
"lint:fix": "yarn lint --fix",
1212
"emulate": "firebase emulators:start --only database,firestore",
13-
"test": "cross-env CYPRESS_baseUrl=http://localhost:3000 cypress run",
14-
"test:open": "cross-env CYPRESS_baseUrl=http://localhost:3000 cypress open",
13+
"test": "cross-env GCLOUD_PROJECT=redux-firebasev3 CYPRESS_baseUrl=http://localhost:3000 cypress run",
14+
"test:open": "cross-env GCLOUD_PROJECT=redux-firebasev3 CYPRESS_baseUrl=http://localhost:3000 cypress open",
1515
"test:emulate": "cross-env FIREBASE_DATABASE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.database.port)\" FIRESTORE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.firestore.port)\" yarn test:open"
1616
},
1717
"dependencies": {
@@ -22,7 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"cross-env": "^7.0.2",
25-
"cypress": "^4.4.1",
25+
"cypress": "^4.5.0",
2626
"cypress-firebase": "^1.1.0",
2727
"eslint-plugin-chai-friendly": "^0.5.0",
2828
"eslint-plugin-cypress": "^2.10.3",

examples/basic/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4843,10 +4843,10 @@ cypress-firebase@^1.1.0:
48434843
resolved "https://registry.yarnpkg.com/cypress-firebase/-/cypress-firebase-1.1.0.tgz#87a2dcfedd740270a7b7020982d240ee88f2b922"
48444844
integrity sha512-TWBy7Syi2xWxHswJPP5ys+iGGF1hHOE0b6arnQvMplCrkoj0YUMTe3fpyLiFlYsqYLzczEYTX6gd4aploMI8oA==
48454845

4846-
cypress@^4.4.1:
4847-
version "4.4.1"
4848-
resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.4.1.tgz#f5aa1aa5f328f1299bff328103f7cbad89e80f29"
4849-
integrity sha512-LcskZ/PXRG9XTlEeeenKqz/KddT1x+7O7dqXsdKWPII01LxLNmNHIvHnlUqApchVbinJ5vir6J255CkELSeL0A==
4846+
cypress@^4.5.0:
4847+
version "4.5.0"
4848+
resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.5.0.tgz#01940d085f6429cec3c87d290daa47bb976a7c7b"
4849+
integrity sha512-2A4g5FW5d2fHzq8HKUGAMVTnW6P8nlWYQALiCoGN4bqBLvgwhYM/oG9oKc2CS6LnvgHFiKivKzpm9sfk3uU3zQ==
48504850
dependencies:
48514851
"@cypress/listr-verbose-renderer" "0.4.1"
48524852
"@cypress/request" "2.88.5"

examples/react-redux-firebase/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"eject": "react-scripts eject",
99
"lint": "eslint src/**.js",
1010
"lint:fix": "yarn lint --fix",
11-
"test": "cross-env CYPRESS_baseUrl=http://localhost:3000 cypress run",
12-
"test:open": "cross-env CYPRESS_baseUrl=http://localhost:3000 cypress open",
13-
"test:emulate": "cross-env FIREBASE_DATABASE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.database.port)\" FIRESTORE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.firestore.port)\" yarn test:open"
11+
"test": "cross-env GCLOUD_PROJECT=redux-firebasev3 CYPRESS_baseUrl=http://localhost:3000 cypress run",
12+
"test:open": "cross-env GCLOUD_PROJECT=redux-firebasev3 CYPRESS_baseUrl=http://localhost:3000 cypress open",
13+
"test:emulate": "cross-env GCLOUD_PROJECT=redux-firebasev3 FIREBASE_DATABASE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.database.port)\" FIRESTORE_EMULATOR_HOST=\"localhost:$(cat firebase.json | jq .emulators.firestore.port)\" yarn test:open"
1414
},
1515
"dependencies": {
1616
"firebase": "^7.14.1",
@@ -22,7 +22,7 @@
2222
"redux": "^4.0.1"
2323
},
2424
"devDependencies": {
25-
"cross-env": "^5.2.0",
25+
"cross-env": "^7.0.2",
2626
"cypress": "^3.1.5",
2727
"cypress-firebase": "*",
2828
"eslint-plugin-cypress": "^2.10.3",

examples/react-redux-firebase/yarn.lock

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4552,13 +4552,20 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
45524552
safe-buffer "^5.0.1"
45534553
sha.js "^2.4.8"
45544554

4555-
cross-env@^5.1.3, cross-env@^5.2.0:
4555+
cross-env@^5.1.3:
45564556
version "5.2.0"
45574557
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2"
45584558
dependencies:
45594559
cross-spawn "^6.0.5"
45604560
is-windows "^1.0.0"
45614561

4562+
cross-env@^7.0.2:
4563+
version "7.0.2"
4564+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
4565+
integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==
4566+
dependencies:
4567+
cross-spawn "^7.0.1"
4568+
45624569
45634570
version "7.0.1"
45644571
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.1.tgz#0ab56286e0f7c24e153d04cc2aa027e43a9a5d14"
@@ -4594,6 +4601,15 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
45944601
shebang-command "^1.2.0"
45954602
which "^1.2.9"
45964603

4604+
cross-spawn@^7.0.1:
4605+
version "7.0.2"
4606+
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6"
4607+
integrity sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==
4608+
dependencies:
4609+
path-key "^3.1.0"
4610+
shebang-command "^2.0.0"
4611+
which "^2.0.1"
4612+
45974613
45984614
version "2.0.5"
45994615
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
const fs = require('fs')
2-
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor')
32
const cypressFirebasePlugin = require('cypress-firebase').plugin
43

54
module.exports = (on, config) => {
6-
on('file:preprocessor', (file) => {
7-
// console.log(`preprocessor invoked with ${JSON.stringify(file)}`); // uncomment for debugging webpack crashes
8-
return cypressTypeScriptPreprocessor(file).then((results) => {
9-
// console.log(`preprocessor returned ${JSON.stringify(results)}`); // uncomment for debugging webpack crashes
10-
11-
if (!fs.existsSync(file.outputPath)) {
12-
console.error(`Output file does not exist on the filesystem: ${JSON.stringify(file)}`);
13-
throw new Error(`Output file does not exist on the filesystem: ${JSON.stringify(file)}`);
14-
}
15-
return results;
16-
}).catch((err) => {
17-
console.error(`Error occurred running preprocessor`, err);
18-
throw err;
19-
});
20-
})
21-
225
return cypressFirebasePlugin(config)
236
}

examples/typescript/cypress/support/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//
2424
// -- This is will overwrite an existing command --
2525
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26-
import attachCustomCommands from 'cypress-firebase/lib/attachCustomCommands'
26+
import { attachCustomCommands } from 'cypress-firebase'
2727
import * as firebase from 'firebase/app'
2828
import 'firebase/auth'
2929
import 'firebase/database'

examples/typescript/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"scripts": {
66
"start": "react-scripts start",
77
"build": "react-scripts build",
8-
"test": "yarn cypress:run",
9-
"cypress:run": "cypress run",
10-
"cypress:open": "cypress open",
8+
"test": "cross-env GCLOUD_PROJECT=redux-firebasev3 cypress run",
9+
"test:open": "cross-env GCLOUD_PROJECT=redux-firebasev3 cypress open",
1110
"lint": "eslint ./src/*.js cypress/**/*.ts --ext .ts,js",
1211
"lint:fix": "yarn lint --fix"
1312
},
@@ -23,10 +22,11 @@
2322
"devDependencies": {
2423
"@typescript-eslint/eslint-plugin": "^2.29.0",
2524
"@typescript-eslint/parser": "^2.29.0",
26-
"cypress": "^4.4.1",
25+
"cross-env": "^7.0.2",
26+
"cypress": "^4.5.0",
2727
"eslint": "^6.8.0",
2828
"eslint-config-prettier": "^6.11.0",
29-
"eslint-plugin-chai-friendly": "^0.5.0",
29+
"eslint-plugin-chai-friendly": "^0.6.0",
3030
"eslint-plugin-cypress": "^2.10.3",
3131
"eslint-plugin-prettier": "^3.1.3",
3232
"prettier": "^2.0.5",

0 commit comments

Comments
 (0)