Coder Social home page Coder Social logo

fabiomcosta / mocha-elk-reporter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpahuja/mocha-elk-reporter

0.0 2.0 0.0 90 KB

Mocha reporter that sends data to ELK (Elastic Search, Log Stash, Kibana)

License: MIT License

JavaScript 100.00%

mocha-elk-reporter's Introduction

Build Status

mocha-elk-reporter

A simple custom mocha reporter that sends Mocha Test results to Elastic search.

Purpose

  • Sending test results to Elastic Search helps collect test results over a period of time/multiple runs.
  • With Kibana you can create different visualizations to better understand the trends for test results.
  • This helps get better visibility, helps better measure reliability, understand cause of failures, measure speed etc. of the tests.

To learn more about ELK (Elastic Search, LogStash, Kibana). Click Here [https://www.elastic.co/products/kibana]

Usage

To use mocha-elk-reporter, add it as a 'devDependency' in your project

npm install --save-dev mocha-elk-reporter

Add a elk-reporter.js file to your project for your Elastic search instance

module.exports = {
  applicationName: "application name to be sent in the content of the tests",
  elasticSearchHost: "host name with port for your elastic search instance e.g. my-elasticsearch.com:9200, 10.10.1.100:9200",
  elasticSearchIndex: "indexName"
}

Mocha by default supports different kind of reporters like spec, json, etc. You can use this reporter similar to any other reporter by passing in additional command line arguments when running the tests using mocha. i.e.

--reporter mocha-elk-reporter

After you execute a test with additional parameters, you should now see data coming into your instance of ELK.

If there are issues with your configuration you should see appropriate logs associated with that

Advance Usage

Until this issue is resolved and PR merged in. If you want to use multiple reporters for your reporting needs e.g. spec, json, mocha-allure-reporter in conjunction with this reporter, you can do so with the help 'mocha multi' module.

To add that as a devDependency to your project

npm install --save-dev mocha-multi

Now you can run multiple reporters while running mocha tests uding this command

'multi="spec=- mocha-elk-reporter=-" mocha --reporter mocha-multi'

addContext Usage

If you are using mocha-multi-reporters with mochawesome and mochawesome's addContext functionality, any key-value pairs in 'value' will automatically get sent. For example here you would have myKey sent to ELK

addContext(this, { title: 'some text here', value: { myKey: "myValue" }}); 

You can also use addContext standalone without mochawesome using an exposed version. you call it like this:

const addContextMER = require('mocha-elk-reporter/addContext');

Then in your actual test use it with this format:

    it('it-test1', function() {
      assert.equal([1,2,3].indexOf(4), -1);
      addContextMER(this, { title: 'some text here', value: { myKey: "myValue" }});
    });

mocha-elk-reporter's People

Contributors

jpage-godaddy avatar maryokhin avatar mpahuja avatar newpablo avatar ounis avatar super9user avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.