Skip to main content
Store credentials outside your code, and mark them as secret when you type them.
  • Read passwords and tokens from environment variables, never from the test file.
  • Type them with secret: true so TestDriver doesn’t log or store them.

Type a secret

Pass { secret: true } to type() for any sensitive value. Click the field first, then type:
tests/login.test.mjs

What secret: true hides

With secret: true, TestDriver replaces the text with ****:
  • In the SDK’s console output.
  • In the record of the action that TestDriver stores for the test run.
The text is still typed into the sandbox, so secret: true can’t hide what the screen shows. If the field displays its contents, the value appears in the Dashcam recording and in screenshots. Password fields usually mask what you type, but plain text fields don’t.
With autoScreenshots on, screenshot file names include the first characters of the typed text, even when secret is true. Leave autoScreenshots off in tests that type secrets.

Store secrets locally

TestDriver loads a .env file in your project root automatically. Put your local credentials there:
.env
Add .env to .gitignore so it’s never committed:
.gitignore

Store secrets in CI

In GitHub Actions, store each credential as a repository secret:
1

Open your repository's secrets

In GitHub, go to Settings > Secrets and variables > Actions.
2

Add each secret

Click New repository secret and add TEST_USERNAME and TEST_PASSWORD.
3

Pass them to the test step

Map the secrets to environment variables in your workflow:
.github/workflows/testdriver.yml
You don’t need to store your TestDriver API key this way. The testdriverai/action step authenticates with GitHub OIDC. See Run in CI/CD for the full workflow.

Checklist

  • Type passwords, tokens, and other sensitive values with secret: true.
  • Read credentials from environment variables, not from the test file.
  • Keep .env out of version control.
  • Use test accounts with only the access your tests need.

Next steps

Use variables and test data

Drive tests with environment variables and fixtures.

type()

Every option for typing text.

Run in CI/CD

Authenticate and run tests in your pipeline.

Reuse code

Put your login steps in a shared helper.