Skip to content

Commit

Permalink
v0.1.5 (#19)
Browse files Browse the repository at this point in the history
* feat(core): support passing service account through `SERVICE_ACCOUNT` environment variable
* fix(core): add warning if `FIREBASE_CLIENT_ID` is set within environment (since it will override `FIREBASE_TOKEN`, which can cause unexpected errors)
* feat(docs): add note about how `SERVICE_ACCOUNT` environment variable is now supported
* fix(docs): add note about requirement of service account to docs for `createTestEnvFile`
  • Loading branch information
prescottprue authored Mar 22, 2019
1 parent b6a9d64 commit a8413b0
Show file tree
Hide file tree
Showing 5 changed files with 667 additions and 331 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ If you are intereted in what drove the need for this checkout [the why section](

1. Log into your app for the first time
1. Go to the Auth tab of Firebase and get your UID. This will be the account which you use to login while running tests (we will call this UID `TEST_UID`)
1. Generate a service account -> save it as `serviceAccount.json`
1. Generate a service account -> save it as `serviceAccount.json` (for local dev)
1. Set service account as the `SERVICE_ACCOUNT` environment variable within your CI (make sure to wrap it in `"`)
1. Install Cypress and add it to your package file: `npm i --save-dev cypress`
1. Add cypress folder by calling `cypress open`

Expand All @@ -52,6 +53,7 @@ If you are intereted in what drove the need for this checkout [the why section](
{
"TEST_UID": "<- uid of the user you want to test as ->",
"FIREBASE_PROJECT_ID": "<- projectId of your project ->",
"FIREBASE_API_KEY": "<- browser apiKey of your project ->"
}
```

Expand All @@ -68,10 +70,11 @@ If you are intereted in what drove the need for this checkout [the why section](
// Your config from Firebase Console
};

window.fbInstance = firebase.initializeApp(fbConfig);
firebase.initializeApp(fbConfig);

attachCustomCommands({ Cypress, cy, firebase })
```

1. Setup plugin adding following your plugins file (`cypress/plugins/index.js`):

```js
Expand Down Expand Up @@ -134,6 +137,10 @@ Tests will run faster locally if you tests against the build version of your app

Create test environment file (`cypress.env.json`) which contains custom auth token generated using `firebase-admin` SDK and `serviceAccount.json`.

##### Requirements

A service account must be provided. This can be done by setting `serviceAccount.json` in the root of the project (often used locally since service accounts should be in gitignore), or by setting the `SERVICE_ACCOUNT` enviroment variable. For different environmets you can prefix with the environment name such as `STAGE_SERVICE_ACCOUNT`.

##### Examples

```bash
Expand Down
1 change: 0 additions & 1 deletion cmds/createTestEnvFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function createTestEnvFile(envName) {
// Create config object to be written into test env file by combining with existing config
const newCypressConfig = Object.assign({}, currentCypressEnvSettings, {
TEST_UID: envVarBasedOnCIEnv('TEST_UID'),
FIREBASE_API_KEY: envVarBasedOnCIEnv('FIREBASE_API_KEY'),
FIREBASE_PROJECT_ID,
FIREBASE_AUTH_JWT: customToken
});
Expand Down
Loading

0 comments on commit a8413b0

Please sign in to comment.