Write Missions
Each .mission.js or .mission.ts file exports an executeMission function and invokes runMissions. Testronaut loads ESM-style mission syntax independently of the host project, so package.json does not need "type": "module".
βοΈ Writing a Mission Fileβ
Create a file in your missions/ directory, e.g. missions/login.mission.js:
import { runMissions } from 'testronaut';
import { loginMission } from './login.mission.js';
export const logoutMission = `
Ensure you are already logged in, if not, log in.
Locate the Logout button, you may need to expand the menu.
Take a screenshot.
Click the logout button.
Figure out if the logout worked.
Take a screenshot.
If successful, report SUCCESS stating the reason why.
Otherwise, report FAILURE stating the reason why.
`
export async function executeMission() {
return await runMissions({
preMission: loginMission,
mission: logoutMission
}, "logout mission");
}
βοΈ Environment Variablesβ
Testronaut reads your .env file for credentials and API access keys. Depending on your selected LLM provider, youβll include the appropriate key:
# Example: OpenAI
OPENAI_API_KEY=sk-...
# or Gemini
GEMINI_API_KEY=AIza...
# or Anthropic Claude
ANTHROPIC_API_KEY=sk-ant-...
# Mission variables
URL=https://example.com/login
USERNAME=example@example.com
PASSWORD=********
Tips:β
Screenshots are flexible and can be added to the prompt language on demand.
Keep secrets in env vars.
Let missions fail loudly. You may specify assertions for success (such as expected elements or content on resulting page), or request that the LLM self determine mission success (It will base success criteria on the mission context as well as the resulting DOM).