Developers
JavaScript SDK
yarn add @timetick/sdkRun a test
Section titled “Run a test”You need an API key, a simulator and a test. Take the ids from the address bar in the portal.
import { createClient } from "@timetick/sdk";
const sdk = createClient({ apiKey: process.env.TIMETICK_API_TOKEN });
const projectId = "123";const testId = "456";const simulatorId = "789";
const [workspace] = (await sdk.simWorlds.list(projectId)) ?? [];const test = await sdk.tests.get(testId);const requirement = test?.requirements?.[0];if (!workspace?.id || !requirement?.id) throw new Error("Check the ids.");
const run = await sdk.testRuns.create({ simWorldId: workspace.id, scenarioId: testId, speedup: 1, scheduleMode: "NOW", requirementDevices: [ { requirementId: requirement.id, deviceId: simulatorId, deviceMode: "SIMULATOR" }, ],});if (!run?.id) throw new Error("The run did not start.");
let status: typeof run.status | undefined = run.status;while (!status || !["COMPLETED", "FAILED", "SKIPPED"].includes(status)) { await new Promise((r) => setTimeout(r, 5000)); status = (await sdk.testRuns.get(run.id))?.status;}console.log(status);See why it failed
Section titled “See why it failed”const details = await sdk.testRuns.getDetails(run.id);
const { records } = await sdk.logs.list({ simulatorId, from: new Date(Date.now() - 60 * 60 * 1000), to: new Date(),});details has the reason, and records has the OCPP messages of the last hour.
The SDK also creates simulators, tests, test plans and Stress Tests. Every method is listed on npm.