Test accounts for sign-in: Google, Apple, Microsoft, GitHub and your own
How to give automated tests their own accounts, why Google and Apple sign-in pages often stop test browsers, and what to do instead.
Most of what you ship is behind sign-in, so most of what you need to test is too. A test that can't sign in only ever checks your homepage. This guide covers how to give your tests an account of their own for each common kind of sign-in, and the sign-in pages that may not let a test browser through.
Why a test account, never a real one
A test can do anything its account can. If it signs in as you, a test that deletes a project deletes yours. A test account:
- has only the permissions the tests need,
- holds made-up data, never a real customer's,
- can be reset or deleted without losing anything,
- keeps test traffic out of your analytics, billing and emails.
Make one per environment (local, preview, staging, production) so a test against staging never touches production data.
Your own email and password sign-in
This is the easiest kind to test, and the one to lean on.
- Create the test user in each environment with a seed script, so a fresh database always has it.
- Mark it as a test account in your data (a flag or a known email domain such as
test.example.com) and leave it out of analytics, marketing emails and billing. - Give it a strong password stored where your tests read secrets, never in the repository.
- If you have two-step sign-in, use an authenticator app for the test account, not text messages. The authenticator's setup key can be stored with the password, and the test makes the six-digit code itself.
Sign in with Google
Google may block sign-in from browsers that are controlled by software. Its guidance to developers says a browser "must not provide automation features", and its help page shows the message people see: "This browser or app may not be secure". A test driving Chrome through WebDriver often gets exactly that, and you can't count on getting through.
So don't test Google's own sign-in page. Test everything after it:
- A test-only sign-in path. In preview and staging only, accept a test account's email and password directly, and make the same session your Google sign-in would. Switch it off in production with configuration your production deploy can't set.
- Firebase. The Authentication emulator serves its own sign-in page for Google and other providers, with made-up accounts. Its tokens are unsigned and production refuses them, so it's for local and preview testing only.
- Production. Test production's signed-in pages through your own email and password sign-in, with a test account, if your site has one. If Google is the only way in, test the signed-in pages on a staging copy that runs the same code.
Sign in with Apple
Apple has no test accounts for Sign in with Apple. Its sandbox testers are for in-app purchases. An Apple Account needs two-step sign-in, and its verification code goes to a trusted Apple device, or by text message or phone call to a trusted phone number, so a test can't complete it on its own.
Use the same approach as Google: a test-only sign-in path in preview and staging, and test the pages after sign-in.
Microsoft (Entra ID)
Microsoft's own advice for automated integration tests is a separate test tenant with test users. In a test tenant you can leave the test users out of the multi-factor rules your real users have, through Conditional Access. Never do that in the tenant your real users sign in to. Microsoft also explains setting up the test environment.
Sign in with GitHub
GitHub allows one free machine account per person, beside your own, "used exclusively for performing automated tasks" (GitHub's terms, section B.3). Create it, give it access only to what the tests need, and turn on two-step sign-in with an authenticator app so the test can make its codes from the setup key.
Auth providers with test modes
- Clerk. Any email with
+clerk_testin it, such asjane+clerk_test@example.com, is a test address: no email is sent and the code is424242. Numbers from+1 (XXX) 555-0100to555-0199work the same way for text messages. Both work only while the Clerk instance's test mode is on: Clerk's page says where to turn it on, and it's on by default for development instances. - Firebase. The emulator above.
- Auth0, Okta and others. Create a separate development tenant with its own test users, and turn off bot detection and multi-factor rules there only.
Check your provider's own testing page before you start. They change.
Keep test accounts safe
- Give each one only the permissions its tests need. A test that only reads never needs an admin.
- Never put real customer data in a test account.
- Change test passwords when someone with access leaves, the same as any shared secret.
- Delete test accounts and test sign-in paths you no longer use.
- Make sure every test-only sign-in path is switched off in production, and test that it is: a request to it in production should fail.
With PocketQA
PocketQA runs your flows on your own lab computer, the one your phones are plugged into. A test account is kept there: a person adds it on that computer, with the sites it may sign in to, and a flow uses it by name ({{test-user.user}}, {{test-user.password}}). The password is stored only on that computer and typed only on the sites you allowed. It never appears in a result, a report or what your coding agent reads, and once it's typed that device keeps no screenshots for the rest of the test. Your first flow shows one in use.