Comments (4)
This error usually come from babel
when the polyfill for async/await has not been included. Requiring babel-polyfill
in your script should fix it.
But I'm not sure how it works with ts-node
.
I wanted to add your awesome library to our firebase/snippets-rules github repository
Thank you, I've built this library because our application has more than 1000 unit tests concerning our RTDB security rules, but we are not yet using Firestore and this library for our application, because we cannot switch to Firestore while it doesn't support validating batch updates / transactions.
I really hope Firebase would focus the next releases of Firestore on:
- Improving the writing of security rules, current language is not very good for typing the data (see FirebaseExtended/bolt#216), Efforts like
protobuf-rules-gen
are more hacking than real solutions - Release a local emulator for security rules (that do not require sending a lot of mocked data and our rules to a remote server for each assertion)
- Fix the batch update validation
- Document and help developers write reliable and secure rules for their DBs, I'm ready to bet that 90% of applications built on top of Firestore have important security flaws, not because of Firebase as a platform itself but because it's poorly documented how to write secure application (almost all of your sample have "write and read everything" rules)
That being said, we love the idea of Firebase
from expect-firestore.
@SamyPesse first of all thank you for your feedback on Firestore. I hear you and I will make sure others do as well.
As for this bug:
- I am not using Babel at all in my project
- This appears with JS and plain-ol
node
as well as with TypeScript andts-node
- I have added
babel-polyfill
to my project and donerequire('babel-polyfill')
in my code with no success
from expect-firestore.
first of all thank you for your feedback on Firestore. I hear you and I will make sure others do as well.
Thanks, As I've told @mcdonamp as well, we will be happy to help alpha/beta test or even contribute writing tooling to fix these issues.
As for this bug
This library is compiled with babel
, and it's not advised by babel to add the polyfill for async and generator functions in each libraries (it should be in the app/script using the library).
The polyfill should be included before anything else. If you use import
calls, Typescript will probably compile these imports (statics) before any require calls (runtime).
Try import 'babel-polyfill';
as the first line of your script.
This "works" for me:
import 'babel-polyfill';
import * as expectFirestore from 'expect-firestore';
const database = new expectFirestore.Database({
credential: {},
data: {},
rules: ''
});
// Note: doesn't matter if this function is async or not, or if I await the promises or not
async function main() {
await database.authorize();
// Test a get
await database.canGet({ uid: 'some-user' }, 'users/userA');
}
main();
It outputs:
ts-node ./test.ts
(node:51554) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: No key or keyFile set.
(node:51554) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
from expect-firestore.
@SamyPesse now I get it, thanks! I had to follow your advice and nuke my node_modules
. Apologies for the noise, I don't leave my Android bubble often enough.
from expect-firestore.
Related Issues (13)
- Test for listing collection
- Resource is incorrectly set for set/update requests
- request.resource should be "hydrated" for update requests
- Test for deleting
- Does the implementation of users in expect-firestore support custom claims?
- ReferenceError: regeneratorRuntime is not defined
- Data without subcollections causes 'Maximum call stack size exceeded'
- FR: Return debugging information from failures HOT 3
- Wrong method types for operations HOT 1
- Function mocks for get() and exists() need to pass absolute paths HOT 3
- Actually expose setData() and setRules() on the database type
- API to test batched writes HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expect-firestore.