{"name":"mocha-headless-chrome","version":"5.1.0","description":"Run client-side mocha tests in the command line through headless Chrome","main":"./lib/runner.js","typings":"./lib/runner.d.ts","bin":{"mocha-headless-chrome":"bin/start"},"engines":{"node":">=18.0.0"},"scripts":{"test":"node lib/cli -f ./example/example-page.html -o ./result/result.json -c ./result/coverage.json -w 801 -H 501 -a incognito","ts":"tsc ./example/example.ts && node ./example/example.js","help":"node lib/cli -h"},"repository":{"type":"git","url":"git+https://github.com/direct-adv-interfaces/mocha-headless-chrome.git"},"keywords":["mocha","tests","puppeteer","headless-chrome"],"author":{"name":"dima117a@gmail.com"},"license":"MIT","types":"./runner.d.ts","bugs":{"url":"https://github.com/direct-adv-interfaces/mocha-headless-chrome/issues"},"homepage":"https://github.com/direct-adv-interfaces/mocha-headless-chrome#readme","dependencies":{"args":"^5.0.1","puppeteer":"^24.3.0"},"devDependencies":{"chai":"^4.5.0","mocha":"^11.1.0","mocha-teamcity-reporter":"^4.2.0","typescript":"^5.9.2"},"_id":"mocha-headless-chrome@5.1.0","gitHead":"33bc6e9322ec7635bb0f0323eb86bc58fe22eb3c","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-u3qe+0M0MwSEOviHOflRyYMcvuvWhNNIOj8vVTTFVhrJdNZjI1Lhc6h3TgqEyhe70oF7M5V6Lwgq2n2XTw2NYA==","shasum":"2489bdf63deaa55e4cd242ac710c2ccda4cd7ca6","tarball":"http://registry-npm.ywwl.com/mocha-headless-chrome/download/mocha-headless-chrome-5.1.0.tgz","fileCount":10,"unpackedSize":18548,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAwJnGU0XyacA7QfHHTaBiWEr3cwc8r2YLxbWfq24opmAiBGFKrXptE4Ql0yMQe8dm4Qvo/47FGOQIZr6Ftp6zX/Sg=="}],"size":6400,"noattachment":false,"key":"/mocha-headless-chrome/-/mocha-headless-chrome-5.1.0.tgz"},"_npmUser":{"name":"dima117","email":"dima117a@gmail.com"},"directories":{},"maintainers":[{"name":"dima117","email":"dima117a@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mocha-headless-chrome_5.1.0_1753998858434_0.06179818452341146"},"_hasShrinkwrap":false,"readme":"# mocha-headless-chrome\n\n[![npm](https://img.shields.io/npm/v/mocha-headless-chrome.svg)](https://www.npmjs.com/package/mocha-headless-chrome)\n[![license](https://img.shields.io/npm/l/mocha-headless-chrome.svg)](http://spdx.org/licenses/MIT.html)\n\nThis is the tool which runs client-side [mocha](https://github.com/mochajs/mocha) tests in the command line through headless Chrome ([puppeteer](https://github.com/GoogleChrome/puppeteer) is used).\n\nNode 18.0.0+ and Mocha 2.3.0+ are supported.\n\n## Getting Started\n\nFirst you need to install [mocha-headless-chrome](https://www.npmjs.com/package/mocha-headless-chrome):\n\n```sh\nnpm i mocha-headless-chrome\n```\n\nThen prepare the test page (see [the example](example/example-page.html)).\n\n*Note. It is necessary to add the **&lt;meta charset=\"utf-8\">** tag. Otherwise browser may use another encoding and test results will be shown incorrectly.*\n\nThen run the CLI and specify your test page path using **-f** parameter.\n\n```sh\nmocha-headless-chrome -f test-page.html\n```\n\n## Options\n\n- **-f, --file** - Path or URL of the page which contains tests (required)\n- **-r, --reporter** - Mocha reporter name (defaults to \"spec\")\n- **-o, --out** - Path to the file where test result will be saved\n- **-c, --coverage** - Path to the file where coverage info will be saved\n- **-e, --executablePath** - Chrome executable path\n- **-v, --visible** - Show Chrome window\n- **-a, --args** - Chrome arguments ('--' prefix will be added)\n- **-w, --width** - Viewport width\n- **-H, --height** - Viewport height\n- **-t, --timeout** - Timeout in ms (defaults to 60000)\n- **-p, --polling** - Puppeteer polling mechanism\n- **-h, --help** - Output usage information\n\n## Examples\n\nRun test on the \"test.html\" page:\n\n```sh\nmocha-headless-chrome -f test.html\n```\n\nRun tests on the remote page:\n\n```sh\nmocha-headless-chrome -f http://localhost:8080\n```\n\nOutput test results using \"nyan\" reporter:\n\n```sh\nmocha-headless-chrome -f test.html -r nyan\n```\n\nPass the Chrome **--no-sandbox** and **--disable-setuid-sandbox** arguments:\n\n```sh\nmocha-headless-chrome -f test.html -a no-sandbox -a disable-setuid-sandbox\n```\n\n## Mocha reporters\n\nAll mocha reporters are supported. Specify the reporter name through **-r** parameter. All reporter output (include cursor manipulations) will be redirected to stdout as like it works in console.\n\nFor usage of third-party reporter just include it's code to the page by **&lt;script>** tag and specify it's name in the **-r** parameter.\n\nAlso special reporter named **\"none\"** is available which does not output anything. This reporter will be useful when you want to process test result without output to console (for example, when saving data to a file).\n\n## Programmatically usage\n\nYou can use mocha-headless-chrome programmatically. Just require the *mocha-headless-chrome* node module and pass proper parameters into it. Function result is a Promise.\n\n```js\nconst {runner} = require('mocha-headless-chrome');\n\nconst options = {\n    file: 'test.html',                           // test page path\n    reporter: 'dot',                             // mocha reporter name\n    width: 800,                                  // viewport width\n    height: 600,                                 // viewport height\n    timeout: 120000,                             // timeout in ms\n    polling: 'raf',                              // polling mechanism\n    executablePath: '/usr/bin/chrome-unstable',  // chrome executable path\n    visible: true,                               // show chrome window\n    args: ['no-sandbox']                         // chrome arguments\n};\n\nrunner(options)\n    .then(result => {\n        let json = JSON.stringify(result);\n        console.log(json);\n    });\n```\n\nSee also the [TypeScript example](./example/example.ts).\n","publish_time":1753998858621,"_cnpm_publish_time":1753998858621,"dist-tags":{"latest":"5.1.0"}}