Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zambezi/mocha-headless-chrome
Run Mocha tests using headless Google Chrome
https://github.com/zambezi/mocha-headless-chrome
headless headless-chrome mocha
Last synced: 11 days ago
JSON representation
Run Mocha tests using headless Google Chrome
- Host: GitHub
- URL: https://github.com/zambezi/mocha-headless-chrome
- Owner: zambezi
- License: mit
- Created: 2017-10-24T13:12:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-25T08:43:22.000Z (about 7 years ago)
- Last Synced: 2024-11-25T02:20:29.300Z (about 1 month ago)
- Topics: headless, headless-chrome, mocha
- Language: JavaScript
- Size: 40 KB
- Stars: 4
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# mocha-headless-chrome
Run Mocha tests with Node.js using headless Google Chrome.
They are alternative npm packages to do this task but this one differs from the other existing one by
- Working on Node.js < 8
- Not relying on GoogleChrome/puppeteer. Which make it faster and lighter.## Getting Started
To begin, you'll need to install `@zambezi/mocha-headless-chrome`:
```console
$ npm install @zambezi/mocha-headless-chrome --save-dev
```Then you'll need a local npm install of mocha:
```console
$ npm install mocha --save-dev
```To run the tests, you'll need an HTML file with some basics:
```html
Test
expect = chai.expect;
mocha.setup('bdd')
// add tests heremocha.run();
```
You can then add your tests either through an external script file or
inline within a `` tag. Running the tests is easy, either with the CLI
binary, or programmatically.## CLI
```console
$ mocha-headless-chrome --helpUsage
$ mocha-headless-chrome <file.html> [options]Options
--mocha A JSON string representing a config object to pass to Mocha
--log-level Specify a log level; trace, debug, info, warn, error
--no-colors Disable colors in Mocha's output
--reporter Specify the Mocha reporter to use
--timeout Specify the test startup timeout to useExamples
$ mocha-headless-chrome test.html --no-colors
$ mocha-headless-chrome test.html --reporter dot
$ mocha-headless-chrome test.html --mocha '{"ui":"tdd"}'
```## Reporters
Third party reporter have to be loaded within the page to be used. For instance to use `mocha-teamcity-reporter` ;
- Install the reporter `npm install mocha-teamcity-reporter --save-dev`.
- Modify the HTML page to add a script tag:```html
<!doctype>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="../node_modules/mocha/mocha.js">
expect = chai.expect;
mocha.setup('bdd')
// add tests heremocha.run();