Skip to content

Commit

Permalink
v1.0.0-alpha (#101)
Browse files Browse the repository at this point in the history
* feat(commands): default to tasks and remove usage of [firebase-tools-extra](https://github.com/prescottprue/firebase-tools-extra)
* feat(core): plugin using tasks is now top level plugin
* fix(core): remove all cli commands including `createTestEnvFile`
* fix(deps): remove commander, chalk, and figures from dependencies
* feat(plugin): remove setting of `baseUrl` and `FIREBASE_PROJECT_ID` from plugin
  • Loading branch information
prescottprue authored Mar 14, 2020
1 parent 42d36df commit 1ae16ba
Show file tree
Hide file tree
Showing 29 changed files with 1,149 additions and 2,940 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ lib-esm
node_modules
coverage
.nyc_output
.github
.github
index.d.ts
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/

- name: Get yarn cache
id: yarn-cache
Expand Down Expand Up @@ -51,7 +52,7 @@ jobs:

- name: Publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_REF: ${{ github.ref }}
run: |
export GIT_BRANCH=${GITHUB_REF##*/}
Expand Down
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,39 @@ If you are interested in what drove the need for this checkout [the why section]

```js
const admin = require('firebase-admin')
const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks
const cypressFirebasePlugin = require('cypress-firebase').plugin
module.exports = (on, config) => {
// Pass on function, config, and admin instance. Returns extended config
return cypressFirebasePlugin(on, config, admin)
}
```

#### Old Method (using firebase-tools-extra cli)

1. Same steps as above but make the following change of import in plugins file (`cypress/plugins/index.js`):

```diff
+ const cypressFirebasePlugin = require('cypress-firebase').plugin
- const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks
```

#### Auth

1. Log into your Firebase console for the first time.
1. Go to Auth tab of Firebase and create a user for testing purpose
1. Get the UID of created account. This will be the account which you use to login while running tests (we will call this UID `TEST_UID`)
1. Add the following to your `.gitignore`:

```
serviceAccount.json
cypress.env.json
```

1. Go to project setting on firebase console and generate new private key. See how to do [here](https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase/tutorials/authenticate-with-a-service-account)
1. Save the downloaded file as `serviceAccount.json` in the root of your project (make sure that it is .gitignored)
1. Add the UID of the user you created earlier to your cypress environment file (`cypress.env.json`) when running locally (make sure this is in you `.gitignore`):

```js
{
"TEST_UID": "<- uid of the user you want to test as ->"
}
```

In CI this will instead be loaded from the `TEST_UID` environment variable
1. Set the UID of the user you created earlier to the cypress environment. You can do this using a number of methods:
1. Adding `CYPRESS_TEST_UID` to `.env` file which is gitignored
1. Adding `TEST_UID` to `cypress.env.json`
1. Adding as part of your npm script to run tests with a tool such as `cross-env`:

```json
"test": "cross-env CYPRESS_TEST_UID=your-uid cypress open"
```

1. Pass the UID when logging in: `cy.login(Cypress.env('TEST_UID'))`
1. Make sure to set `CYPRESS_TEST_UID` environment variable in your CI settings if you are running tests in CI
1. Call `cy.login()` with the `before` or `beforeEach` sections of your tests

**NOTE**: If you are running tests within your CI provider you will want to set the `SERVICE_ACCOUNT` environment variable as the service account object and the `TEST_UID` environment variable as the UID of your test user

Expand All @@ -108,6 +101,7 @@ If you are interested in what drove the need for this checkout [the why section]

#### createTestEnvFile {#createTestEnvFile}

**NOTE**: This command is deprecated and will be removed in the next major version. It is suggested that you use `CYPRESS_` prefixed environment variables instead
Create test environment file (`cypress.env.json`) which contains custom auth token generated using `firebase-admin` SDK and `serviceAccount.json`.

##### Requirements
Expand Down
25 changes: 0 additions & 25 deletions bin/cypress-firebase

This file was deleted.

31 changes: 0 additions & 31 deletions cmds/createTestEnvFile.js

This file was deleted.

19 changes: 0 additions & 19 deletions cmds/index.js

This file was deleted.

41 changes: 0 additions & 41 deletions cmds/open.js

This file was deleted.

35 changes: 0 additions & 35 deletions cmds/run.js

This file was deleted.

Loading

0 comments on commit 1ae16ba

Please sign in to comment.