Skip to content

Commit

Permalink
Next (#275)
Browse files Browse the repository at this point in the history
* pkg: bump version; drop engines

* Greenkeeping (#255)

* pkg: bump version; drop engines

* chore: remove babel dependency

* chore: update eslint and fix lint error

* test: silence mochawesome output during test

* chore: update dependencies

* chore: update node versions in travis config

* chore: replace lodash with individual modules
further, replace `_.map` and `_.compact` with native `map` and `reduce`

* chore: update codeclimate config to v2

* chore: update description; remove build script; update files array
no need for `dist/` folder now that source is no longer transpiled

* docs: update changelog

* remove errant console.logs

* Update data structure (#259)

* feat: change `allSuites` to results and make an array
this change allows for a more flexible data structure that will support merging of reports. it also eliminates some ambiguity since `allSuites` was a single object despite the name implying an array

* feat: remove `getPercentClass` utility and class-related stats
classes are a presentation detail and should be left up to the report generator

* remove unused 'isRoot' property from cleaned tests

* remove `copyrightYear` from report json
this is a presentation detail that belongs in the report generator

* add `meta` property to report output to track useful info about the report
- mocha version
- mochawesome version, config
- marge version, options

* add uuid to suites

* change meta.mochawesome.config -> meta.mochawesome.options

* add comment about failed hooks

* add mochawesome-report-generator@next as dependency

* chore: update `diff` dependency

* feat: update `passPercentage` and `pendingPercentage` to be raw values rather than rounded
Rounding is a presentation detail better left to the report generator

* fix reporter test to work with mocha v6+

* remove proxyquire for local report generator

* update changelog

* bump alpha version

* add node 8 to ci config

* update docs to indicate node support version

* fix addcontext path

* bump alpha version

* update functional tests
  • Loading branch information
adamgruber committed Jun 4, 2019
1 parent 815ca14 commit c620fe6
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 191 deletions.
11 changes: 0 additions & 11 deletions .babelrc

This file was deleted.

28 changes: 2 additions & 26 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
---
engines:
duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 90
eslint:
enabled: true
channel: "eslint-3"
config:
extensions:
- ".js"
fixme:
enabled: true
ratings:
paths:
- "**.js"
exclude_paths:
- dist/
- .nyc_output/
- _site/
- coverage/
version: "2"
exclude_patterns:
- docs/
- test/
- test-functional/
- test-programmatic/
- test/sample-suite.js
- test/sample-tests.js
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "4"
- "5"
- "6"
- "node"
- "lts/*"
- "8"
addons:
code_climate:
repo_token: 1a650700393c767904fc318ba4e936e72d348ab9d924f4a3e53bdba9d87a4ec6
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# mochawesome changelog

## [Unreleased]
### Changed
- Drop support for Node <8
- Removed Babel dependency
- Replace lodash dependency with individual modules
- Updated codeclimate config to version 2
- Updated various dependencies
- **Breaking changes to JSON data structure**
- Renamed `allSuites` to `results` and made it an array of suites
- Removed `isRoot` property from cleaned tests (only suites can be a root)
- Removed class-related stats (`passPercentClass`, `pendingPercentClass`)
- Added `uuid` to suites
- Removed rounding of `passPercent` and `pendingPercent`
- Removed `copyrightYear` property
- Added new `meta` property to track info about the test run (useful for debugging)

## [3.1.2] - 2019-04-17
### Fixed
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mochawesome
===========
[![npm](https://img.shields.io/npm/v/mochawesome.svg?style=flat-square)](http://www.npmjs.com/package/mochawesome) [![Build Status](https://img.shields.io/travis/adamgruber/mochawesome/master.svg?style=flat-square)](https://travis-ci.org/adamgruber/mochawesome) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg?style=flat-square)](https://gitter.im/mochawesome/general) [![Code Climate](https://img.shields.io/codeclimate/github/adamgruber/mochawesome.svg?style=flat-square)](https://codeclimate.com/github/adamgruber/mochawesome)

Mochawesome is a custom reporter for use with the Javascript testing framework, [mocha][mocha]. It runs on Node.js (>=4) and works in conjunction with [mochawesome-report-generator][marge] to generate a standalone HTML/CSS report to helps visualize your test runs.
Mochawesome is a custom reporter for use with the Javascript testing framework, [mocha][mocha]. It runs on Node.js (>=8) and works in conjunction with [mochawesome-report-generator][marge] to generate a standalone HTML/CSS report to helps visualize your test runs.


## Features
Expand All @@ -19,7 +19,6 @@ Mochawesome is a custom reporter for use with the Javascript testing framework,
- Filters to display only the tests you want
- Responsive and mobile-friendly
- Offline viewing
- Support for IE9+

## Usage

Expand Down
2 changes: 1 addition & 1 deletion addContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*
*/

module.exports = require('./dist/addContext');
module.exports = require('./src/addContext');
59 changes: 23 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mochawesome",
"version": "3.1.2",
"description": "A Gorgeous HTML/CSS Reporter for Mocha.js",
"version": "4.0.0-alpha.2",
"description": "A gorgeous reporter for Mocha.js",
"scripts": {
"lint": "eslint src test",
"test": "npm run lint && cross-env NODE_ENV=test nyc mocha",
Expand All @@ -10,9 +10,7 @@
"test:mem": "mocha test-functional/mem-test.js --opts test-functional/mocha.opts",
"test:ctx": "mocha test-functional/test-context.js --opts test-functional/mocha.opts",
"tdd": "npm run lint && cross-env NODE_ENV=test nyc mocha --watch",
"dev": "babel --watch src -d dist",
"build": "babel src -d dist",
"prepack": "npm run test && npm run build"
"prepack": "npm run test"
},
"author": "Adam Gruber",
"license": "MIT",
Expand All @@ -26,62 +24,51 @@
"json",
"html"
],
"engine": "node >= 4",
"main": "dist/mochawesome.js",
"main": "src/mochawesome.js",
"files": [
"addContext.js",
"dist"
"src"
],
"nyc": {
"include": [
"src/*.js"
],
"require": [
"babel-register"
],
"sourceMap": false,
"instrument": false,
"reporter": [
"lcov",
"html",
"text-summary"
],
"cache": true,
"cache": false,
"check-coverage": true,
"lines": 99,
"statements": 99,
"functions": 100,
"branches": 90
},
"dependencies": {
"babel-runtime": "^6.20.0",
"chalk": "^2.3.0",
"diff": "^3.4.0",
"chalk": "^2.4.1",
"diff": "^4.0.1",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.3",
"mochawesome-report-generator": "^3.0.1",
"strip-ansi": "^4.0.0",
"uuid": "^3.0.1"
"lodash.isempty": "^4.4.0",
"lodash.isfunction": "^3.0.9",
"lodash.isobject": "^3.0.2",
"lodash.isstring": "^4.0.1",
"mochawesome-report-generator": "^4.0.0-alpha.0",
"strip-ansi": "^5.0.0",
"uuid": "^3.3.2"
},
"peerDependencies": {
"mocha": "*"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.20.0",
"babel-plugin-istanbul": "^4.1.5",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-stage-3": "^6.11.0",
"babel-register": "^6.14.0",
"cross-env": "^5.1.1",
"eslint": "^4.12.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.2.0",
"cross-env": "^5.2.0",
"eslint": "^5.7.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"mocha": "*",
"nyc": "^11.4.0",
"proxyquire": "^1.7.10",
"should": "^13.1.3",
"sinon": "^4.1.2"
"nyc": "^13.1.0",
"proxyquire": "^2.1.0",
"should": "^13.2.3",
"sinon": "^7.0.0"
}
}
4 changes: 2 additions & 2 deletions src/addContext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const isObject = require('lodash/isObject');
const isEmpty = require('lodash/isEmpty');
const isObject = require('lodash.isobject');
const isEmpty = require('lodash.isempty');
const chalk = require('chalk');
const stringify = require('json-stringify-safe');

Expand Down
44 changes: 26 additions & 18 deletions src/mochawesome.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const Base = require('mocha/lib/reporters/base');
const Spec = require('mocha/lib/reporters/spec');
const mochaPkg = require('mocha/package.json');
const uuid = require('uuid');
const marge = require('mochawesome-report-generator');
const margePkg = require('mochawesome-report-generator/package.json');
const conf = require('./config');
const utils = require('./utils');
const pkg = require('../package.json');

// Import the utility functions
const {
log,
getPercentClass,
mapSuites
} = utils;

Expand Down Expand Up @@ -88,15 +90,11 @@ function Mochawesome(runner, options) {

let endCalled = false;

// Add a unique identifier to each test/hook
runner.on('test', test => {
test.uuid = uuid.v4();
});
runner.on('hook', hook => {
hook.uuid = uuid.v4();
});
runner.on('pending', test => {
test.uuid = uuid.v4();
// Add a unique identifier to each suite/test/hook
[ 'suite', 'test', 'hook', 'pending' ].forEach(type => {
runner.on(type, item => {
item.uuid = uuid.v4();
});
});

// Process the full suite
Expand All @@ -108,29 +106,39 @@ function Mochawesome(runner, options) {
// so we ensure the suite is processed only once
endCalled = true;

const allSuites = mapSuites(this.runner.suite, totalTestsRegistered, this.config);
const rootSuite = mapSuites(this.runner.suite, totalTestsRegistered, this.config);

const obj = {
stats: this.stats,
suites: allSuites,
copyrightYear: new Date().getFullYear()
results: [ rootSuite ],
meta: {
mocha: {
version: mochaPkg.version
},
mochawesome: {
options: this.config,
version: pkg.version
},
marge: {
options: options.reporterOptions,
version: margePkg.version
}
}
};

obj.stats.testsRegistered = totalTestsRegistered.total;

const { passes, failures, pending, tests, testsRegistered } = obj.stats;
const passPercentage = Math.round((passes / (testsRegistered - pending)) * 1000) / 10;
const pendingPercentage = Math.round((pending / testsRegistered) * 1000) /10;
const passPercentage = (passes / (testsRegistered - pending)) * 100;
const pendingPercentage = (pending / testsRegistered) * 100;

obj.stats.passPercent = passPercentage;
obj.stats.pendingPercent = pendingPercentage;
obj.stats.other = (passes + failures + pending) - tests;
obj.stats.other = (passes + failures + pending) - tests; // Failed hooks
obj.stats.hasOther = obj.stats.other > 0;
obj.stats.skipped = testsRegistered - tests;
obj.stats.hasSkipped = obj.stats.skipped > 0;
obj.stats.failures -= obj.stats.other;
obj.stats.passPercentClass = getPercentClass(passPercentage);
obj.stats.pendingPercentClass = getPercentClass(pendingPercentage);

// Save the final output to be used in the done function
this.output = obj;
Expand Down
Loading

0 comments on commit c620fe6

Please sign in to comment.