-
Notifications
You must be signed in to change notification settings - Fork 934
Storage Emulator support in rules-unit-testing #4863
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
Conversation
🦋 Changeset detectedLatest commit: 9a885a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Changeset File Check
|
Binary Size ReportAffected SDKs
Test Logs |
Very nice 😍 |
}; | ||
/** Construct an App authenticated as an admin user. */ | ||
export function initializeAdminApp(options: AdminAppOptions): firebase.app.App { | ||
export function initializeAdminApp(options: AdminAppOptions): app.App { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type has been wrong for a while! We can't live with it anymore because of Storage, which has a totally different API between client and Admin.
ssl: false | ||
}); | ||
const { hostname, port } = parseHost(getFirestoreHost()); | ||
app.firestore().useEmulator(hostname, port); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving to consistently use useEmulator
across the board.
@@ -216,7 +220,24 @@ describe('Testing Module Tests', function () { | |||
}); | |||
}); | |||
|
|||
it('initializeAdminApp() has admin access', async function () { | |||
it('initializeAdminApp() has admin access to RTDB', async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated this into three tests so we can tell failures apart.
@@ -15,7 +15,7 @@ | |||
"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 --project=foo --debug emulators:exec 'yarn test:nyc'", | |||
"test": "FIREBASE_CLI_PREVIEWS=storageemulator STORAGE_EMULATOR_HOST=http://localhost:9199 firebase --project=foo --debug emulators:exec 'yarn test:nyc'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add the STORAGE_EMULATOR_HOST
variable to compensate for firebase/firebase-tools#3337
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"test": "FIREBASE_CLI_PREVIEWS=storageemulator STORAGE_EMULATOR_HOST=http://localhost:9199 firebase --project=foo --debug emulators:exec 'yarn test:nyc'", | |
"test": "FIREBASE_CLI_PREVIEWS=storageemulator firebase --project=foo --debug emulators:exec 'yarn test:nyc'", |
Gotta clean this up now we've released the CLI with the fix
Size Analysis ReportAffected Products
|
Discussion
Adds support for Storage emulator to the rules-unit-testing library.
TODO:
Nice to have:
Testing
See unit tests. Currently we have the following failures, so we have to skip a test in CI:
(1) is a known issue with Storage not being able to work without credentials even when using the emulator. @abeisgoat or @hiranya911 do you know of any way to fix this without adding service account credentials to the JS SDK test environment?
API Changes
initializeAdminApp()
has always been returning afirebase.app.App
type from the client SDK but that has not been correct for a few releases! So I did change the type which is an API change, but it's to fix a bug.