{"id":14975413,"url":"https://github.com/jquery/testswarm-browserstack","last_synced_at":"2025-07-17T18:16:05.599Z","repository":{"id":2368854,"uuid":"3333152","full_name":"jquery/testswarm-browserstack","owner":"jquery","description":"Integration layer between TestSwarm and BrowserStack","archived":false,"fork":false,"pushed_at":"2022-12-06T16:03:56.000Z","size":152,"stargazers_count":26,"open_issues_count":1,"forks_count":16,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-01-29T13:03:33.432Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"tornadoweb/tornado","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jquery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-02T08:25:20.000Z","updated_at":"2023-02-12T16:07:22.000Z","dependencies_parsed_at":"2023-01-11T16:09:39.092Z","dependency_job_id":null,"html_url":"https://github.com/jquery/testswarm-browserstack","commit_stats":null,"previous_names":["clarkbox/testswarm-browserstack"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Ftestswarm-browserstack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Ftestswarm-browserstack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Ftestswarm-browserstack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Ftestswarm-browserstack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jquery","download_url":"https://codeload.github.com/jquery/testswarm-browserstack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116318,"owners_count":19258231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-09-24T13:51:59.833Z","updated_at":"2025-02-04T12:30:58.785Z","avatar_url":"https://github.com/jquery.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/jquery/testswarm-browserstack/actions/workflows/CI.yaml/badge.svg?event=push)](https://github.com/jquery/testswarm-browserstack/actions/workflows/CI.yaml)\n[![npm](https://img.shields.io/npm/v/testswarm-browserstack.svg?style=flat)](https://www.npmjs.com/package/testswarm-browserstack)\n[![Tested with QUnit](https://img.shields.io/badge/tested_with-qunit-9c3493.svg)](https://qunitjs.com/)\n\n# testswarm-browserstack\n\nThis is a lightweight integration layer between [TestSwarm](https://github.com/jquery/testswarm) and [BrowserStack](https://www.browserstack.com/). Use it to spawn BrowserStack workers needed by TestSwarm on demand. It uses [node-browserstack](https://github.com/scottgonzalez/node-browserstack) to abstract the BrowserStack API.\n\nThis script is currently compatible with:\n* [TestSwarm](https://github.com/jquery/testswarm) v1.0.0 or higher\n* [BrowserStack API](https://github.com/browserstack/api) v4\n\n## Install\n\n```bash\ngit clone https://github.com/clarkbox/testswarm-browserstack.git testswarm-browserstack\ncd testswarm-browserstack/\nnpm install\n```\n\n\n## How to use CLI\n\n```bash\nnode src/cli.js --run\n```\n\nThis above command will create and terminate BrowserStack workers as needed according to the information the TestSwarm `swarmstate` API provides. This command should be executed on a regular interval, either via a scheduler (such as crontab) or by letting node do a continuous loop (using the `--run-loop` option). Be sure to do start it from a scheduler still in a way that it will only start it if it isn't running anymore (in case of an exception).\n\nIf you plan to run it from a scheduler and keep log files, you're recommended to use the `run-sample.sh` file as a start. It contains the basic cli invocation as a template. Fill in the argument values and adjust the script and log paths. Also, as a reminder that log files can run out of hand quickly, we've provided a sample file to use in `logrotate` (e.g. on Ubuntu). To learn about logrotate, checkout [Ubuntu manpages](http://manpages.ubuntu.com/manpages/hardy/man8/logrotate.8.html) or the [Slicehost tutorial](http://articles.slicehost.com/2010/6/30/understanding-logrotate-on-ubuntu-part-1) on the subject. To install it, copy the file to `logrotate.conf` within this directory, adjust the path and (if you want to) set different settings. Then move it to `/etc/logrotate.d/testswarm-browserstack.conf`.\n\n\n### Main scripts\n\n1. [testswarm-browserstack.js](https://github.com/clarkbox/testswarm-browserstack/blob/master/src/testswarm-browserstack.js) - Abstraction of TestSwarm API, and Scott González's BrowserStack API. Use it to automatically spawn BrowserStack workers based on your swarm's needs.\n1. [cli.js](https://github.com/clarkbox/testswarm-browserstack/blob/master/src/cli.js) - nodejs cli wrapper around it all. Allows for scripted or generally easy manual invocation of the script.\n\n\n### testswarm-browserstack.js\n\n#### Options documentation:\n* `browserstack.user`: BrowserStack username\n* `browserstack.pass`: BrowserStack password\n* `browserstack.project`: Project name for grouping on BrowserStack Automate dashboard\n* `browserstack.workerTimeout`: Maximum lifetime of the worker (in seconds). Use `0` for _indefinitely_ (BrowserStack will terminate the worker after the maximum run time, as of writing that maximum is 30 minutes).\n* `browserstack.dryRun`: Enable to only simulate spawning and termination of browserstack workers.\n* `browserstack.totalLimit`: Maximum number of simultaneous workers allowed under this BrowserStack account.\n* `browserstack.eqLimit`: How many simultaneous workers with the same browser are allowed.\n* `testswarm.root`: URL to the root of the TestSwarm installation. Relative to here should be `./index.php` and `./api.php`.\n* `testswarm.runUrl`: URL to the TestSwarm run page (including client name), for BrowserStack workers to open. If your swarm is protected with a token, this is the place to enter the token.\n* `verbose`: Output debug information (through `console.log`).\n\n\n#### Example `config.json`:\n```json\n{\n  \"browserstack\": {\n    \"user\": \"example\",\n    \"pass\": \"*******\"\n  },\n  \"testswarm\": {\n    \"root\": \"http://ci.example.org/testswarm\",\n    \"runUrl\": \"http://c.example.org/testswarm/run/JohnDoe\"\n  }\n}\n```\n\n###  cli.js\n\nThis is a nodejs cli wrapper around testswarm-browserstack.js. You can use it independent of testswarm. Use --help to get all the information you need to know (see above for example usage):\n\n```\n  Usage: cli.js [options]\n\n  Options:\n\n    -h, --help            output usage information\n    -V, --version         output the version number\n    --config [path]       path to config file with options (defaults to ./config.json)\n    --run                 Retrieve TestSwarm state and spawn/terminate BrowserStack workers as needed\n    --run-loop \u003ctimeout\u003e  Execute --run in a non-overlapping loop with set timeout (in seconds) between iterations\n    --worker \u003cid\u003e         Get info abuot a specific BrowserStack worker\n    --spawn \u003cuaId\u003e        Spwawn a BrowserStack worker by swarm useragent id (joining the swarm)\n    --terminate \u003cid\u003e      Terminate a specific BrowserStack worker\n    --terminateAll        Terminate all BrowserStack workers\n    -v, --verbose         Output debug information (through console.log)\n    --dry, --dry-run      Simulate spawning and termination of browserstack workers\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquery%2Ftestswarm-browserstack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjquery%2Ftestswarm-browserstack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquery%2Ftestswarm-browserstack/lists"}