{"id":28437883,"url":"https://github.com/testdriverai/demo-exec-js","last_synced_at":"2026-02-12T22:02:03.454Z","repository":{"id":284852505,"uuid":"956274900","full_name":"testdriverai/demo-exec-js","owner":"testdriverai","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-28T01:57:30.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-29T21:26:11.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testdriverai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-28T01:33:42.000Z","updated_at":"2025-03-28T01:57:33.000Z","dependencies_parsed_at":"2025-03-28T02:32:35.924Z","dependency_job_id":"118769ac-2826-4722-9b48-dd61b4d10335","html_url":"https://github.com/testdriverai/demo-exec-js","commit_stats":null,"previous_names":["testdriverai/demo-exec-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/testdriverai/demo-exec-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdriverai%2Fdemo-exec-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdriverai%2Fdemo-exec-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdriverai%2Fdemo-exec-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdriverai%2Fdemo-exec-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testdriverai","download_url":"https://codeload.github.com/testdriverai/demo-exec-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testdriverai%2Fdemo-exec-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29382870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T20:34:40.886Z","status":"ssl_error","status_checked_at":"2026-02-12T20:23:00.490Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-06T00:09:44.838Z","updated_at":"2026-02-12T22:02:03.448Z","avatar_url":"https://github.com/testdriverai.png","language":null,"readme":"# Execute JS In TestDriver.ai\n\nLet's say you want to use some custom JS within your test to hit an API. \n\nAs of `5.1.0` you can execute any NodeJS script complete with NPM support using the `exec` command! \n\nThis repo is a demo of running custom npm packages in TestDriver. \n\n## Running this demo\n\nClone this repo, then run:\n\n```\nnpm install\ntestdriverai run testdriver/testdriver.yaml\n```\n\n![CleanShot 2025-03-27 at 20 52 49@2x](https://github.com/user-attachments/assets/d6f5cbb4-b1b3-49b1-878c-dfcbfc3ce96f)\n\n\n## How it works\n\n### Params\n- `js` - The NodeJS script to run. Output must be defined as `result`\n- `output` - The variable name available as `${OUTPUT.var}` in future steps\n\n\n```yaml\nversion: 5.1.0\nsession: 67e57d614dc25283aa0872a9\nsteps:\n  - prompt: Log in with the totp\n    commands:\n      - command: exec\n        output: totp \n        js: |\n          const { TOTP } = require(\"totp-generator\");\n          let otp = TOTP.generate(\"JBSWY3DPEB3W64TMMQQQ\").otp;\n          result = otp;\n      - command: type\n        text: ${OUTPUT.totp}\n```\n\n### Protips\n\n- Don't overwrite `result`\n- Make sure to `npm install` locally (and within `prerun` when using the GitHub action)\n- NodeJS code executes in the same context as the calling process, on the host machine. It uses [VM](https://nodejs.org/api/vm.html) internally.\n\n### Gotchas\n\n- This can only be deployed on hosted Windows runners, hosted Linux runners do not support `prerun` yet\n\n## Using NPM Modules From Scratch\n\n```\nnpm init\nnpm install totp-generator --save\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestdriverai%2Fdemo-exec-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestdriverai%2Fdemo-exec-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestdriverai%2Fdemo-exec-js/lists"}