Skip to main content

☄️ Troubleshooting

Invalid session token​

  • testronaut login should revalidate auth.
  • Or regenerate your API key.

Email-code lookup returns invalid_session, but direct API access works​

This usually means the mission is running a different CLI installation than the one you updated, or an old TESTRONAUT_API_BASE override is routing requests through HTTP. An HTTP-to-HTTPS redirect can remove the Authorization header.

First, log in from the same project directory that contains the mission and confirm a session was saved without printing it:

testronaut login
TOKEN="$(jq -r '.sessionToken // empty' testronaut-config.json)"
printf 'Session token characters: %s\n' "${#TOKEN}"

Test the production API directly:

curl -sS https://api.testronaut.app/api/email-inboxes \
-H "Authorization: Bearer $TOKEN" | jq

If that succeeds but the mission still reports invalid_session, compare the local and global installations. npm view testronaut version shows the newest registry release; it does not show which version your shell executes.

npm ls testronaut
npm ls -g testronaut
which -a testronaut
node -p "require('./node_modules/testronaut/package.json').version"

Run the project-local installation explicitly:

npx --no-install testronaut missions/your-mission.mission.js
# equivalent:
./node_modules/.bin/testronaut missions/your-mission.mission.js

If the local command works, update the global installation or use the local command consistently:

npm install -g testronaut@latest
hash -r

Also check for stale API or session overrides:

printenv TESTRONAUT_API_BASE
printenv TESTRONAUT_SESSION_TOKEN | wc -c
grep -n 'TESTRONAUT_API_BASE\|TESTRONAUT_SESSION_TOKEN' .env .env.local 2>/dev/null

Production must use https://api.testronaut.app. To remove ambiguity for one diagnostic run:

TESTRONAUT_API_BASE=https://api.testronaut.app \
TESTRONAUT_SESSION_TOKEN="$TOKEN" \
npx --no-install testronaut missions/your-mission.mission.js

Clear the temporary shell values afterward:

unset TOKEN TESTRONAUT_SESSION_TOKEN TESTRONAUT_API_BASE

Cannot find report file​

  • Ensure <outputDir>/run_<runId>.json exists (CI should not clean the workspace before upload).

Flaky hover / drawers / expanding menus​

  • Prefer tools.hoverAndClick(selector) and add if Failure, retry this mission to the mission text.

testronaut: command not found​

This error means the testronaut command is not available in your shell's PATH. You have three options:

Option 1 — Global install

Install the CLI globally so the testronaut command is available everywhere:

npm install -g testronaut

After this, run testronaut directly from any directory.

Option 2 — Use the project-local CLI with npx (recommended for projects)

Install Testronaut in the project, then use npx --no-install so every team member runs the version pinned by that project:

npm install --save-dev testronaut
npx --no-install testronaut --init
npx --no-install testronaut your-mission.mission.js

Option 3 — Local project install via npm link

If you have a local clone of the testronaut-cli repository, you can link it into your global PATH from the project directory:

cd path/to/testronaut-cli
npm link

This makes your local build available as the testronaut command globally.