diff --git a/.changeset/gentle-bugs-drop.md b/.changeset/gentle-bugs-drop.md new file mode 100644 index 00000000000..9c7931e9a31 --- /dev/null +++ b/.changeset/gentle-bugs-drop.md @@ -0,0 +1,5 @@ +--- +"@firebase/auth": patch +--- + +Calls to `connectAuthEmulator` with the `disableWarnings` flag set to true will no longer cause a `console.info` warning to be printed diff --git a/packages/auth/src/core/auth/emulator.test.ts b/packages/auth/src/core/auth/emulator.test.ts index cf7737232ca..2d613fd8aef 100644 --- a/packages/auth/src/core/auth/emulator.test.ts +++ b/packages/auth/src/core/auth/emulator.test.ts @@ -130,16 +130,12 @@ describe('core/auth/emulator', () => { ); }); - it('logs out the warning but has no banner if disableBanner true', () => { + it('skips console info and has no banner if warnings disabled', () => { sinon.stub(console, 'info'); connectAuthEmulator(auth, 'http://localhost:2020', { disableWarnings: true }); - expect(console.info).to.have.been.calledWith( - 'WARNING: You are using the Auth Emulator,' + - ' which is intended for local testing only. Do not use with' + - ' production credentials.' - ); + expect(console.info).not.to.have.been.called; if (typeof document !== 'undefined') { expect(document.querySelector('.firebase-emulator-warning')).to.be.null; } diff --git a/packages/auth/src/core/auth/emulator.ts b/packages/auth/src/core/auth/emulator.ts index 166533e637a..e8653283187 100644 --- a/packages/auth/src/core/auth/emulator.ts +++ b/packages/auth/src/core/auth/emulator.ts @@ -75,7 +75,9 @@ export function connectAuthEmulator( options: Object.freeze({ disableWarnings }) }); - emitEmulatorWarning(disableWarnings); + if (!disableWarnings) { + emitEmulatorWarning(); + } } function extractProtocol(url: string): string { @@ -114,7 +116,7 @@ function parsePort(portStr: string): number | null { return port; } -function emitEmulatorWarning(disableBanner: boolean): void { +function emitEmulatorWarning(): void { function attachBanner(): void { const el = document.createElement('p'); const sty = el.style; @@ -143,8 +145,7 @@ function emitEmulatorWarning(disableBanner: boolean): void { } if ( typeof window !== 'undefined' && - typeof document !== 'undefined' && - !disableBanner + typeof document !== 'undefined' ) { if (document.readyState === 'loading') { window.addEventListener('DOMContentLoaded', attachBanner);