fix: some validateAdminArgs unit tests wouldn't actually fail under incorrect behavior by stephenarosaj · Pull Request #3009 · firebase/firebase-admin-node

some of the validateAdminArgs() unit tests used a pattern of nested check-expects, and the outer expect would just be checking that a specific error wasn't thrown, which would swallow up any failures from inner expects - it would always pass the outer expect, meaning that even if the inner expects should fail the test, the test would pass.

this is shown on lines 224 of validate-admin-args.spec.ts, where variables are provided to validateAdminArgs() but on line 227 we check that they are undefined. if you bring this incorrect inner expect out of the outer expect, the test fails - because we are expecting undefined when in reality we passed in variables and are correctly returned variables. to be clear, this is an incorrectly written test, but the behavior of the function is correct - the bad test wasn't caught because of this nested check-expects pattern.

changing the testing pattern here to flatten the expects to the same level solves the problem!