{"id":28740050,"url":"https://github.com/meteor-community-packages/meteor-browser-tests","last_synced_at":"2025-06-16T06:41:12.447Z","repository":{"id":39874685,"uuid":"82306120","full_name":"Meteor-Community-Packages/meteor-browser-tests","owner":"Meteor-Community-Packages","description":"A helper package for Meteor test driver packages. Runs client tests in a headless browser.","archived":false,"fork":false,"pushed_at":"2025-05-30T11:43:41.000Z","size":119,"stargazers_count":12,"open_issues_count":10,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-30T13:16:13.388Z","etag":null,"topics":["hacktoberfest","meteor","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Meteor-Community-Packages.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null},"funding":{"github":["storytellercz","jankapunkt"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2017-02-17T14:42:13.000Z","updated_at":"2025-05-30T11:42:32.000Z","dependencies_parsed_at":"2024-01-05T14:28:12.905Z","dependency_job_id":"d7845bdb-45bd-452c-a5fc-b5751fff579e","html_url":"https://github.com/Meteor-Community-Packages/meteor-browser-tests","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/Meteor-Community-Packages/meteor-browser-tests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fmeteor-browser-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fmeteor-browser-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fmeteor-browser-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fmeteor-browser-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Meteor-Community-Packages","download_url":"https://codeload.github.com/Meteor-Community-Packages/meteor-browser-tests/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Meteor-Community-Packages%2Fmeteor-browser-tests/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260115278,"owners_count":22961027,"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":["hacktoberfest","meteor","testing"],"created_at":"2025-06-16T06:41:11.467Z","updated_at":"2025-06-16T06:41:12.426Z","avatar_url":"https://github.com/Meteor-Community-Packages.png","language":"JavaScript","funding_links":["https://github.com/sponsors/storytellercz","https://github.com/sponsors/jankapunkt"],"categories":[],"sub_categories":[],"readme":"# meteortesting:browser-tests\n\n![GitHub License](https://img.shields.io/github/license/Meteor-Community-Packages/meteor-browser-tests)\n[![Code quality](https://github.com/Meteor-Community-Packages/meteor-browser-tests/actions/workflows/lint.yml/badge.svg)](https://github.com/Meteor-Community-Packages/meteor-browser-tests/actions/workflows/lint.yml)\n[![CodeQL](https://github.com/Meteor-Community-Packages/meteor-browser-tests/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/Meteor-Community-Packages/meteor-browser-tests/actions/workflows/github-code-scanning/codeql)\n[![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat\u0026logo=biome)](https://biomejs.dev/)\n![GitHub License](https://img.shields.io/github/license/Meteor-Community-Packages/meteor-browser-tests)\n\n_Formerly published as aldeed:browser-tests_\n\nThis package exports a `startBrowser` function for server code, which runs your client tests within a headless browser page. Meteor test driver packages can depend on this package. See the example implementation here: https://github.com/DispatchMe/meteor-mocha\n\nNOTE: This package replaces [dispatch:phantomjs-tests](https://github.com/DispatchMe/meteor-phantomjs-tests). This package supports PhantomJS as well as others, and can be easily updated to support more.\n\n## Usage\n\nIn your test driver package `package.js` file, add\n\n```js\napi.use('meteortesting:browser-tests@1.6.0', 'server');\n```\n\nThen in your server code, do something similar to this:\n\n```js\nimport { startBrowser } from 'meteor/meteortesting:browser-tests';\n\nfunction start() {\n  startBrowser({\n    stdout(data) {\n      console.log(data.toString());\n    },\n    stderr(data) {\n      console.log(data.toString());\n    },\n    done(failureCount) {\n      // Your code to run when client tests are done running\n    },\n  });\n}\n\nexport { start };\n```\n\nAnd in your client code, you need to set some properties on `window` so that the browser script knows what is happening. Here is an example using Mocha:\n\n```js\n// Run the client tests. Meteor calls the `runTests` function exported by\n// the driver package on the client.\nfunction runTests() {\n  // These `window` properties are all used by the browser script to\n  // know what is happening.\n  window.testsAreRunning = true;\n  mocha.run((failures) =\u003e {\n    window.testsAreRunning = false;\n    window.testFailures = failures;\n    window.testsDone = true;\n  });\n}\n\nexport { runTests };\n```\n\n## Dependencies\n\nWhen using your test driver package, you will need to install the necessary NPM package dependency and indicate which headless browser you want to use.\n\n### Puppeteer\n\n`puppeteer@^19.11.1` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default).\n\n```bash\n$ npm i --save-dev puppeteer@^19.11.1\n$ TEST_BROWSER_DRIVER=puppeteer meteor test --once --driver-package \u003cyour package name\u003e\n```\n\n### Playwright\n\n#### Meteor 2.x:\n`playwright@^1.33.0` is the latest version with Node 14 compatibility (Meteor 2.x is set to use Node.js version 14.x by default).\n\n```bash\n$ npm i --save-dev playwright@^1.33.0\n$ TEST_BROWSER_DRIVER=playwright meteor test --once --driver-package \u003cyour package name\u003e\n```\n\n#### Meteor 3.x:\n```bash\n$ npm i --save-dev playwright\n$ npx playwright install\n# additionally it might ask you to install dependencies for the browsers:\n$ sudo meteor npx playwright install-deps \n$ TEST_BROWSER_DRIVER=playwright meteor test --once --driver-package \u003cyour package name\u003e\n```\n\nPlaywright supports multiple browsers, including Chromium, Firefox, and WebKit.\nYou can specify which browser to use by setting the `PLAYWRIGHT_BROWSER` environment variable.\nThe available options are `chromium`, `firefox`, and `webkit`.\nBy default, it uses `chromium`.\n\n### Selenium ChromeDriver\n\nGeneral note: make sure your chrome driver version matches your installed Chrome version.\nYou can check the version of Chrome you have installed by going to `chrome://version/` in your browser.\n\n#### Meteor 1.6+:\n\n```bash\n$ meteor npm i --save-dev selenium-webdriver chromedriver\n$ TEST_BROWSER_DRIVER=chrome meteor test --once --driver-package \u003cyour package name\u003e\n```\n\nChrome will run headless unless you export `TEST_BROWSER_VISIBLE=1`.\n\nAdditional command-line arguments for Chrome can be specified using the `TEST_CHROME_ARGS` environment variable. Multiple arguments are supported, separated by spaces. \nIf you need to include a space inside an individual argument, use `%20` instead of the space.\n\n#### Meteor \u003c 1.6:\n\n**NOTE: Currently you must pin to exactly version 3.0.0-beta-2 of selenium-webdriver for earlier versions of Meteor because the latest webdriver package only works on Node 6.x+. The `-E` in the command below is important!**\n\n```bash\n$ meteor npm i -E --save-dev selenium-webdriver@3.0.0-beta-2\n$ meteor npm i --save-dev chromedriver\n$ TEST_BROWSER_DRIVER=chrome meteor test --once --driver-package \u003cyour package name\u003e\n```\n\n### Nightmare/Electron\n\n```bash\n$ npm i --save-dev nightmare\n$ TEST_BROWSER_DRIVER=nightmare meteor test --once --driver-package \u003cyour package name\u003e\n```\n\nYou can export `TEST_BROWSER_VISIBLE=1` to show the Electron window while tests run.\n\n### PhantomJS\n\n\u003e Please note: Support for PhantomJS has been deprecated because it's development is suspended. \n\u003e For more information on why it got suspended, please take a look at [the repository](https://github.com/ariya/phantomjs)\n\n```bash\n$ npm i --save-dev phantomjs-prebuilt\n$ TEST_BROWSER_DRIVER=phantomjs meteor test --once --driver-package \u003cyour package name\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor-community-packages%2Fmeteor-browser-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeteor-community-packages%2Fmeteor-browser-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeteor-community-packages%2Fmeteor-browser-tests/lists"}