# Test your app with multiple user accounts

> Test your app with multiple user accounts: one seeded account per role, a separate browser session for each, and saved sign-in state so tests skip the login.

Source: https://mosaicbrowser.com/guides/test-your-app-with-multiple-user-accounts

## How to test your app with multiple user accounts

Test your app with multiple user accounts by seeding one account per role in a test environment, signing each into its own isolated browser session, and saving that signed-in state so tests start already logged in. Then write the cases where the accounts act on each other, because that is where multi-user bugs live.

![Admin, buyer and seller, each signed in on its own](https://mosaicbrowser.com/covers/test-your-app-with-multiple-user-accounts.webp)

Most bugs that need two accounts to find are about one account changing what another sees: a seller edits a price while a buyer has it in the basket, an admin removes a permission while the user's page is open, two people edit the same record. Testing your app with multiple user accounts comes down to three things done once: accounts that exist on purpose, a separate browser session for each, and a fast way back to "signed in". Everything below assumes it is your app, or one you are hired to test, in a staging or test environment.

## Step 1: seed one account per role

Write the test users into the database with the seed script, not by hand through the sign-up form. A hand-made account drifts: someone changes its password, finishes its onboarding, or deletes it during a demo, and the test that relied on it fails for a reason nobody can see.

A useful starting set for a marketplace-style app:

| Account | Why it exists |
| --- | --- |
| `admin@test` | every permission, for setup and for checking audit logs |
| `seller-a@test`, `seller-b@test` | two of the same role, to prove one cannot see the other's data |
| `buyer-new@test` | no history, for onboarding and empty states |
| `buyer-old@test` | years of orders, for pagination and slow queries |
| `buyer-2fa@test` | two-factor on, so the sign-in path with a code is tested too |

The pair of identical roles is the one teams skip, and it finds the worst bugs: a query missing its tenant filter returns seller B's orders to seller A, and with only one seller account every result looks right.

## Step 2: give every account its own browser session

Two accounts in two tabs of the same browser are one session, because the tabs share cookies. Sign in as the buyer in the second tab and the seller's tab becomes the buyer on its next request. Each account needs its own cookie store: separate browser profiles by hand, or separate browser contexts in an automated test. The options and their limits are laid out in [testing multiple sessions in the same browser](https://mosaicbrowser.com/guides/test-multiple-sessions-in-the-same-browser).

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Logins and 2FA codes](https://mosaicbrowser.com/features/logins-and-2fa)

## Step 3: save the signed-in state

Signing in through the form in every test is slow and makes every test depend on the login page. Playwright's pattern is a setup project that signs in once per role and writes each session to a file, which later tests load as `storageState` ([Authentication](https://playwright.dev/docs/auth), read 2 November 2026). For roles that interact, its documentation uses two contexts in one test:

```
test("seller sees the buyer's order", async ({ browser }) => {
  const seller = await browser.newContext({ storageState: 'playwright/.auth/seller.json' })
  const buyer = await browser.newContext({ storageState: 'playwright/.auth/buyer.json' })
  // act as the buyer, then assert on the seller's page
})

```

The same page carries a warning worth repeating: the state file "may contain sensitive cookies and headers that could be used to impersonate you or your test account", and Playwright discourages checking it into any repository. Put `playwright/.auth` in `.gitignore`.

## Step 4: write the cases where accounts meet

With accounts and sessions in place, the cases worth writing are the cross-account ones:

1. **Isolation.** Seller A cannot reach seller B's records by guessing an ID in the URL or the API.
2. **Live changes.** A permission revoked by the admin takes effect on the user's open page, without waiting for them to sign in again.
3. **Concurrency.** Two users save the same record a second apart; the app keeps one, says so, and does not silently merge.
4. **Notifications.** An action by one account reaches the other's inbox, bell or websocket, once.
5. **Sign-out.** Signing one account out does not end another account's session in a different browser.

## Testing your app with multiple user accounts by hand, in Mosaic

Manual and exploratory testing needs the same separation, with a person at the keyboard. In Mosaic, each test account gets a profile: a browser with its own cookie jar and storage that stays signed in across restarts, its own proxy if the test depends on the network, and its own fingerprint. That last part matters when the app scores devices, because two accounts in two Chrome profiles still report one machine.

1. Click **New profile** for each account and name it after the role: "Seller A", "Seller B", "Buyer (2FA)".
2. Sign each in once. Save the account's password, and its two-factor setup key if it has one, in that profile's **Logins** tab (the **Two-factor secret** field), so the code is there when the session expires. A setup key that cannot produce a code is refused when you save it ([logins and 2FA](https://mosaicbrowser.com/features/logins-and-2fa)).
3. Start the profiles a test needs, select them, and use **Arrange** to put the windows side by side.
4. Tag the test profiles, say `staging`, and filter the table by that tag, so they never mix with anything else on the machine.

![The Mosaic profiles table: names, coloured tags, proxy locations and a Start button on each row](https://mosaicbrowser.com/shots/profiles-list.png)
*One profile per test account, named after its role*

On Pro, the local REST API starts a profile and returns its DevTools endpoint, so the same signed-in profiles can run your Playwright suite through `connectOverCDP` ([REST API](https://mosaicbrowser.com/features/rest-api)). Mosaic is a desktop app, so this suits a tester's own machine rather than CI. Pro is $25 a month, and a new account starts on Free with 3 profiles and no card, as [pricing](https://mosaicbrowser.com/pricing) shows.

## Sources

1. [Playwright docs: Authentication](https://playwright.dev/docs/auth), read November 2, 2026
2. [Playwright docs: Isolation (browser contexts)](https://playwright.dev/docs/browser-contexts), read November 2, 2026

## Questions

### Should test accounts share one email inbox?

They can, if your mail provider supports sub-addresses, but the app under test must treat each address as a separate user. Check that it does: an app that normalises addresses on sign-up can merge test users you meant to keep apart.

### Can I commit Playwright's saved login files to the repository?

Playwright's documentation advises against it: the state file can hold cookies and headers that would let someone impersonate the test account. Keep the folder in .gitignore and regenerate it in a setup step.

### How do I test an account that has two-factor sign-in?

Store the account's TOTP setup key with the test account and generate the code when needed. In Mosaic, each profile has its own credentials vault that holds logins and 2FA codes for that profile only.

### Can I use these methods on someone else's app?

Test accounts belong on systems you own or are hired to test. Creating extra accounts on a third-party service is governed by that service's terms, and many allow one account per person.

## Related

[How to test multiple sessions in the same browser](https://mosaicbrowser.com/guides/test-multiple-sessions-in-the-same-browser): Tabs in one browser share cookies, so one session. To test several at once, give each its own cookie store: incognito, a Chrome profile or a context.

[How to manage 2FA codes for multiple accounts](https://mosaicbrowser.com/guides/manage-2fa-codes-for-multiple-accounts): Keep each account's 2FA secret next to its login, back the secrets up somewhere you control, and save recovery codes before you need them.

[2FA codes per browser profile, with a login vault each](https://mosaicbrowser.com/features/logins-and-2fa): Mosaic keeps 2FA codes per browser profile: each profile has its own login vault with TOTP codes, shown with a countdown and typed with real keystrokes.

[How to use Playwright with an anti-detect browser](https://mosaicbrowser.com/guides/use-playwright-with-an-anti-detect-browser): Use Playwright with an anti-detect browser by starting the profile first and attaching with connectOverCDP. Keep its context; leave the fingerprint alone.

[Anti-detect browser REST API: profiles from your scripts](https://mosaicbrowser.com/features/rest-api): Mosaic's anti-detect browser REST API runs on 127.0.0.1 with API keys. Create and start profiles, then attach Puppeteer or Playwright over CDP.







[How to type into multiple browsers at once](https://mosaicbrowser.com/guides/type-into-multiple-browsers-at-once): Tick the running profiles, click Type in all, and Mosaic types your text into every window as real keystrokes, each window with its own timing.

## Run this guide on your own accounts

Every Mosaic profile is a fingerprint, a proxy IP and a cookie jar that agree with each other, kept on your computer. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
