Skip to content

Commit

Permalink
Invert logic for retrieving test code string (#254)
Browse files Browse the repository at this point in the history
* fix: Invert logic for getting test code by checking for `test.body` before `test.fn` inside `cleanTest` method

* docs: update changelog
  • Loading branch information
adamgruber authored Oct 17, 2018
1 parent f0ca20e commit 155b087
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# mochawesome changelog

## Unreleased
## [Unreleased]
### Changed
- Invert logic for getting test code by checking for `test.body` before `test.fn` inside `cleanTest` method [#252](https://github.com/adamgruber/mochawesome/issues/252)

## [3.0.3] / 2018-07-25
### Changed
Expand Down Expand Up @@ -161,6 +163,7 @@ This release is in tandem with and requires mochawesome-report-generator >= 3.0.
- Custom font-icon set
- All fonts are now local to the report

[Unreleased]: https://github.com/adamgruber/mochawesome/compare/3.0.3...HEAD
[3.0.3]: https://github.com/adamgruber/mochawesome/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/adamgruber/mochawesome/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/adamgruber/mochawesome/compare/3.0.0...3.0.1
Expand Down
9 changes: 7 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,13 @@ function normalizeErr(err, config) {
* @return {Object} cleaned test
*/
function cleanTest(test, config) {
/* istanbul ignore next: test.fn exists prior to mocha 2.4.0 */
const code = test.fn ? test.fn.toString() : test.body;
let code = test.body;

/* istanbul ignore next */
if (code === undefined) {
/* istanbul ignore next: test.fn exists prior to mocha 2.4.0 */
code = test.fn ? test.fn.toString() : '';
}

const cleaned = {
title: stripAnsi(test.title),
Expand Down

0 comments on commit 155b087

Please sign in to comment.