Skip to content

Migrate testing to rules-unit-testing #3378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b336c8b
Migrate testing to rules-unit-testing
samtstern Jul 9, 2020
ff83ad6
Remove bad dep
samtstern Jul 9, 2020
543fbb3
Merge branch 'master' into ss-fork-testing
samtstern Jul 16, 2020
60381b3
Fix dev dependency
samtstern Jul 17, 2020
318ecca
Fix how env is checked
samtstern Jul 17, 2020
6b85198
var name
samtstern Jul 17, 2020
98c993f
Merge remote-tracking branch 'origin/master' into ss-fork-testing
samtstern Aug 3, 2020
a7351d8
Deps
samtstern Aug 3, 2020
f4864f0
Update Firestore dep
samtstern Aug 3, 2020
d1ac304
Fix yarn.lock
samtstern Aug 4, 2020
ab2352b
Make tests pass
samtstern Aug 4, 2020
b431203
Merge remote-tracking branch 'origin/master' into ss-fork-testing
samtstern Aug 4, 2020
8f54ed5
Add changeset
samtstern Aug 4, 2020
3e2b499
Update versions and changeset
samtstern Aug 6, 2020
2b92d40
Merge remote-tracking branch 'origin/master' into ss-fork-testing
samtstern Aug 7, 2020
f9d9898
Merge remote-tracking branch 'origin/master' into ss-fork-testing
samtstern Aug 10, 2020
c5b7268
Restore testing package (#3556)
samtstern Aug 11, 2020
d9bdde6
Update changeset ignore config
samtstern Aug 11, 2020
9ee4bf9
Revert some changes
samtstern Aug 11, 2020
23fc04a
Revert some changes
samtstern Aug 11, 2020
be695ee
No changelog
samtstern Aug 11, 2020
186908f
Merge branch 'master' into ss-fork-testing
samtstern Aug 12, 2020
9993f0d
Update package.json
samtstern Aug 12, 2020
cb12261
No port conflict
samtstern Aug 12, 2020
3b0c125
Merge remote-tracking branch 'origin/master' into ss-fork-testing
samtstern Aug 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/cold-bats-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@firebase/rules-unit-testing': major
---

Release `@firebase/rules-unit-testing` to replace the `@firebase/testing` package. The new
package is API compatible but has the following breaking behavior changes:

* `assertFails()` will now only fail on `PERMISSION DENIED` errors, not any error.
* `initializeAdminApp()` now relies on `firebase-admin` rather than imitating the Admin SDK.
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"@firebase/app-types-exp",
"@firebase/functions-exp",
"@firebase/functions-types-exp",
"@firebase/testing",
"firebase-exp"
],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true,
"useCalculatedVersionForSnapshots": true
}
}
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ packages/auth-types @bojeil-google @avolkovi @samhorlbeck @scottcrossen @fireba

# Testing Code
packages/testing @avolkovi @samhorlbeck @scottcrossen @yuchenshi @firebase/jssdk-global-approvers
packages/rules-unit-testing @avolkovi @samhorlbeck @scottcrossen @yuchenshi @firebase/jssdk-global-approvers

# RxFire Code
packages/rxfire @davideast @jamesdaniels @firebase/jssdk-global-approvers
Expand Down
1 change: 1 addition & 0 deletions packages/rules-unit-testing/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
38 changes: 38 additions & 0 deletions packages/rules-unit-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# @firebase/testing

## 0.20.10

### Patch Changes

- Updated dependencies []:
- [email protected]

## 0.20.9

### Patch Changes

- Updated dependencies [[`a87676b8`](https://github.com/firebase/firebase-js-sdk/commit/a87676b84b78ccc2f057a22eb947a5d13402949c)]:
- @firebase/[email protected]
- [email protected]

## 0.20.8

### Patch Changes

- Updated dependencies [[`02419ce8`](https://github.com/firebase/firebase-js-sdk/commit/02419ce8470141f012d9ce425a6a4a4aa912e480)]:
- [email protected]

## 0.20.7

### Patch Changes

- Updated dependencies [[`9c409ea7`](https://github.com/firebase/firebase-js-sdk/commit/9c409ea74efd00fe17058c5c8b74450fae67e9ee), [`5a355360`](https://github.com/firebase/firebase-js-sdk/commit/5a3553609da893d45f7fe1897387f72eaedf2fe0), [`c2b737b2`](https://github.com/firebase/firebase-js-sdk/commit/c2b737b2187cb525af4d926ca477102db7835420), [`9a9a81fe`](https://github.com/firebase/firebase-js-sdk/commit/9a9a81fe4f001f23e9fe1db054c2e7159fca3ae3)]:
- [email protected]

## 0.20.6

### Patch Changes

- Updated dependencies [[`a754645e`](https://github.com/firebase/firebase-js-sdk/commit/a754645ec2be1b8c205f25f510196eee298b0d6e), [`17c628eb`](https://github.com/firebase/firebase-js-sdk/commit/17c628eb228c21ad1d4db83fdae08d1142a2b902), [`bb740836`](https://github.com/firebase/firebase-js-sdk/commit/bb7408361519aa9a58c8256ae01914cf2830e118), [`39ca8ecf`](https://github.com/firebase/firebase-js-sdk/commit/39ca8ecf940472159d0bc58212f34a70146da60c), [`877c060c`](https://github.com/firebase/firebase-js-sdk/commit/877c060c47bb29a8efbd2b96d35d3334fd9d9a98), [`e90304c8`](https://github.com/firebase/firebase-js-sdk/commit/e90304c8ac4341d8b23b55da784eb21348b04025), [`469c8bdf`](https://github.com/firebase/firebase-js-sdk/commit/469c8bdf18c4a22e99d595a9896af2f934df20fd)]:
- [email protected]
- @firebase/[email protected]
9 changes: 9 additions & 0 deletions packages/rules-unit-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @firebase/rules-unit-testing

A set of utilities useful for testing Security Rules with the Realtime Database or Cloud Firestore
emulators.

See:

* [Test your Cloud Firestore Security Rules](https://firebase.google.com/docs/firestore/security/test-rules-emulator)
* [Testing Security Rules with the Realtime Database Emulator](https://firebase.google.com/docs/database/security/test-rules-emulator)
13 changes: 13 additions & 0 deletions packages/rules-unit-testing/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"emulators": {
"firestore": {
"port": 9001
},
"database": {
"port": 9000
},
"ui": {
"enabled": false
}
}
}
35 changes: 35 additions & 0 deletions packages/rules-unit-testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* The testing module does not need to be registered since it should not ever
* come by default. The only way to use the testing module is by explicitly
* creating a dependency on @firebase/rules-unit-testing.
*/

export {
apps,
assertFails,
assertSucceeds,
clearFirestoreData,
database,
firestore,
initializeAdminApp,
initializeTestApp,
loadDatabaseRules,
loadFirestoreRules
} from './src/api';
50 changes: 50 additions & 0 deletions packages/rules-unit-testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@firebase/rules-unit-testing",
"version": "0.1.0",
"description": "",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"engines": {
"node": "^8.13.0 || >=10.10.0"
},
"files": [
"dist"
],
"scripts": {
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/rules-unit-testing --include-dependencies build",
"dev": "rollup -c -w",
"test:nyc": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js",
"test": "firebase emulators:exec 'yarn test:nyc'",
"test:ci": "node ../../scripts/run_tests_in_ci.js",
"prepare": "yarn build"
},
"license": "Apache-2.0",
"dependencies": {
"firebase": "7.17.2",
"@firebase/logger": "0.2.6",
"@firebase/util": "0.3.0",
"request": "2.88.2"
},
"devDependencies": {
"@google-cloud/firestore": "4.2.0",
"@types/request": "2.48.5",
"firebase-admin": "9.0.0",
"firebase-tools": "8.7.0",
"rollup": "2.23.0",
"rollup-plugin-typescript2": "0.27.1"
},
"peerDependencies": {
"@google-cloud/firestore": "^4.2.0",
"firebase-admin": "^9.0.0"
},
"repository": {
"directory": "packages/rules-unit-testing",
"type": "git",
"url": "https://github.com/firebase/firebase-js-sdk.git"
},
"typings": "dist/index.d.ts",
"bugs": {
"url": "https://github.com/firebase/firebase-js-sdk/issues"
}
}
37 changes: 37 additions & 0 deletions packages/rules-unit-testing/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import typescriptPlugin from 'rollup-plugin-typescript2';
import pkg from './package.json';
import typescript from 'typescript';

const plugins = [
typescriptPlugin({
typescript
})
];

const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

export default {
input: 'index.ts',
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
plugins: [...plugins],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
};
Loading