{"id":19511574,"url":"https://github.com/pixijs/floss","last_synced_at":"2025-07-20T09:33:18.670Z","repository":{"id":11148300,"uuid":"68523355","full_name":"pixijs/floss","owner":"pixijs","description":"Unit-testing for those hard to reach places","archived":false,"fork":false,"pushed_at":"2022-11-10T14:21:34.000Z","size":378,"stargazers_count":28,"open_issues_count":7,"forks_count":8,"subscribers_count":35,"default_branch":"main","last_synced_at":"2025-07-03T17:29:23.027Z","etag":null,"topics":["coverage","electron","electron-mocha","mocha","sinon","travis-ci","unit-testing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/floss","language":"TypeScript","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/pixijs.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":"2016-09-18T13:30:14.000Z","updated_at":"2023-02-09T16:33:32.000Z","dependencies_parsed_at":"2023-01-13T16:21:27.307Z","dependency_job_id":null,"html_url":"https://github.com/pixijs/floss","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/pixijs/floss","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixijs%2Ffloss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixijs%2Ffloss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixijs%2Ffloss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixijs%2Ffloss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixijs","download_url":"https://codeload.github.com/pixijs/floss/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixijs%2Ffloss/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265009649,"owners_count":23697218,"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":["coverage","electron","electron-mocha","mocha","sinon","travis-ci","unit-testing"],"created_at":"2024-11-10T23:21:32.723Z","updated_at":"2025-07-20T09:33:18.344Z","avatar_url":"https://github.com/pixijs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Floss\n\nUnit-testing for those hard to reach places.\n\n[![Node.js CI](https://github.com/pixijs/floss/workflows/Node.js%20CI/badge.svg)](https://github.com/pixijs/floss/actions?query=workflow%3A%22Node.js+CI%22) [![npm version](https://badge.fury.io/js/floss.svg)](https://badge.fury.io/js/floss)\n\nUses Electron to provide a Mocha unit-testing environment which can be run headlessly or to debugged with DevTools. This was largely inspired by the [electron-mocha](https://github.com/jprichardson/electron-mocha) and [mocha-electron](https://github.com/tscanlin/mochatron) projects but didn't quite have the debugging features needed to develop tests.\n\n## Installation\n\nInstall globally:\n\n```bash\nnpm install -g floss electron\n```\n\nInstall locally within a project:\n\n```bash\nnpm install floss electron --save-dev\n```\n\n### Debug Mode\n\nOpen tests in an Electron window where test can can be debugged with `debugger` and dev tools.\n\n```js\nawait floss({\n    path: 'test/*.js',\n    debug: true\n});\n```\n\n### Mocha Reporter\n\nThe `reporter` and `reporterOptions` are pass-through options for Mocha to specify a different reporter when running Floss in non-debug mode.\n\n```js\nawait floss({\n    path: 'test/*.js',\n    reporter: 'xunit',\n    reporterOptions: {\n    \tfilename: 'report.xml'\n    }\n});\n```\n\n### Custom Options\n\nAdditional properties can be passed to the test code by adding more values to the run options.\n\n```js\nawait floss({\n    path: 'test/*.js',\n    customUrl: 'http://localhost:8080' // \u003c- custom\n});\n```\n\nThe test code and use the global `options` property to have access to the run options.\n\n```js\nconsole.log(options.customUrl); // logs: http://localhost:8080\n```\n\n### Electron Arguments\n\nCommandline arguments can be passed to Electron directly by using `args`. In the example below, you may wan to disable Electron's user-gesture policy if you are testing HTML video or audio playback.\n\n```js\nawait floss({\n    path: 'test/index.js',\n    args: ['--autoplay-policy=no-user-gesture-required']\n});\n```\n\n## Command Line Usage\n\n### Arguments\n\n* **--path** or **-p** (String) Path to the file to test\n* **--debug** or **-d**  (Boolean) Enable to run in headful mode, default `false`.\n* **--quiet** or **-q** (Boolean) Prevent console[log/info/error/warn/dir] messages from appearing in `stdout`.\n* **--electron** or **-e**  (String) Path to the electron to use.\n* **--reporter** or **-R**  (String) Mocha reporter type, default `spec`.\n* **--reporterOptions** or **-O**  (String) Mocha reporter options.\n* **--require** or **-r** (String) Module to require (e.g., `ts-node/register`).\n* **-- [args]** Additional arguments can be passed to Electron after `--`\n\n### Usage\n\nCommand Line usage when installed globally:\n\n```bash\nfloss --path \"test/*.js\"\n```\n\nOr installed locally:\n\n```bash\nnode node_modules/.bin/floss --path \"test/*.js\"\n```\n\nAlernatively, within the **package.json**'s' scripts:\n\n```json\n{\n    \"scripts\": {\n        \"test\": \"floss --path \\\"test/*.js\\\"\"\n    }\n}\n```\n\n### Debug Mode\n\nOpen tests in an Electron window where test can can be debugged with `debugger` and dev tools.\n\n```bash\nfloss --path \"test/*.js\" --debug\n```\n\n### Using TypeScript\n\nSupport can easily be added for writing tests in TypeScript using [ts-node](https://www.npmjs.com/package/ts-node).\n\n```bash\nfloss --path \"test/*.ts\" --require ts-node/register\n```\n\n### Istanbul Code Coverage\n\nFloss supports `nyc`. To use it, just use floss as you would mocha:\n\n```bash\nnyc floss --path \"test/*.js\"\n```\n\n### Mocha Reporter\n\nCan use the same reporter options as the API mentioned above. The `reporterOptions` are expressed as a querystring, for instance `varname=foo\u0026another=bar`.\n\n```bash\nfloss --path \"test/*.js\" \\\n    --reporter=xunit \\\n    --reporterOptions output=report.xml\n```\n\n### Electron Arguments\n\nSupports passing additional arguments to Electron after `--`.\n\n```bash\nfloss --path \"test/*.js\" -- --autoplay-policy=no-user-gesture-required\n```\n\n## Custom Electron Version\n\nSome application may require a specific version of Electron. Floss uses Electron 10.0.0+, but you can specific the path to your own version. The custom version can be used either through the commandline argument `--electron`, by setting the Node environmental variable `ELECTRON_PATH` or by setting the run option `electron`.\n\n```bash\nfloss --path \"test/.js\" \\\n\t--electron /usr/local/bin/electron\n```\n\n```bash\nELECTRON_PATH=/usr/local/bin/electron floss --path \"test/*.js\"\n```\n\n## GitHub Actions Integration\n\n```yml\nname: Node.js CI\non:\n  push:\n    branches: [ '**' ]\n    tags: [ '**' ]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2\n    - uses: actions/setup-node@v1\n      with:\n        node-version: '12'\n    - run: npm install\n    - uses: GabrielBB/xvfb-action@v1.0\n      with:\n        run: npm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixijs%2Ffloss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixijs%2Ffloss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixijs%2Ffloss/lists"}