Skip to content

[@firebase/rules-unit-testing] confusing documentation #6306

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

Closed
louis030195 opened this issue May 27, 2022 · 1 comment
Closed

[@firebase/rules-unit-testing] confusing documentation #6306

louis030195 opened this issue May 27, 2022 · 1 comment
Labels
documentation testing-sdk testing with emulator

Comments

@louis030195
Copy link

The documentation of assertSucceeds and assertFails are "Assert the promise to be rejected with a "permission denied" error", are success and failure the same thing?

* Assert the promise to be rejected with a "permission denied" error.

/**
 * Assert the promise to be rejected with a "permission denied" error.
 *
 * Useful to assert a certain request to be denied by Security Rules. See example below.
 * This function recognizes permission-denied errors from Database, Firestore, and Storage JS SDKs.
 *
 * @param pr - the promise to be asserted
 * @returns a Promise that is fulfilled if pr is rejected with "permission denied". If pr is
 *          rejected with any other error or resolved, the returned promise rejects.
 * @public
 * @example
 * ```javascript
 * const unauthed = testEnv.unauthenticatedContext();
 * await assertFails(get(doc(unauthed.firestore(), '/private/doc'), { ... });
 * ```
 */
export function assertFails(pr: Promise<any>): Promise<any> {
/**
 * Assert the promise to be rejected with a "permission denied" error.
 *
 * This is a no-op function returning the passed promise as-is, but can be used for documentational
 * purposes in test code to emphasize that a certain request should succeed (e.g. allowed by rules).
 *
 * @public
 * @example
 * ```javascript
 * const alice = testEnv.authenticatedContext('alice');
 * await assertSucceeds(get(doc(alice.firestore(), '/doc/readable/by/alice'), { ... });
 * ```
 */
export function assertSucceeds<T>(pr: Promise<T>): Promise<T> {
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation testing-sdk testing with emulator
Projects
None yet
Development

No branches or pull requests

3 participants