Skip to content

Commit

Permalink
chore(release): 1.1.0 [skip ci]
Browse files Browse the repository at this point in the history
## [1.1.0](1.0.0...1.1.0) (2022-05-20)

### 📔 Docs

* add readme ([b14bb6d](b14bb6d))
* add test docs ([11ccec9](11ccec9))

### 🦊 CI/CD

* fix publishConfig access ([9b18d84](9b18d84))

### 🧪 Tests

* fix index mkdirp mock ([a80af47](a80af47))

### 🚀 Features

* add oneFilePerSuite option ([c7691c4](c7691c4))

'
  • Loading branch information
semantic-release-bot committed May 20, 2022
1 parent c7691c4 commit 41046c8
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 0 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [1.1.0](https://github.com/Konecty/jest-doc-reporter/compare/1.0.0...1.1.0) (2022-05-20)


### 📔 Docs

* add readme ([b14bb6d](https://github.com/Konecty/jest-doc-reporter/commit/b14bb6dfdf9adddd90bbc48fd9dc95a1879a2da6))
* add test docs ([11ccec9](https://github.com/Konecty/jest-doc-reporter/commit/11ccec9b976d539a2bba578d453646371ec140ca))


### 🦊 CI/CD

* fix publishConfig access ([9b18d84](https://github.com/Konecty/jest-doc-reporter/commit/9b18d847e78cbd41efe4b872d687527cd118d705))


### 🧪 Tests

* fix index mkdirp mock ([a80af47](https://github.com/Konecty/jest-doc-reporter/commit/a80af476e871cbab079b05a17f0e320a3d5d0ac6))


### 🚀 Features

* add oneFilePerSuite option ([c7691c4](https://github.com/Konecty/jest-doc-reporter/commit/c7691c41899e729bd73ad204d78f70b2374ec99f))

## [1.0.0](https://github.com/Konecty/jest-doc-reporter/compare/...1.0.0) (2022-05-17)


Expand Down
18 changes: 18 additions & 0 deletions dist/lib/filterEntries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = filterEntries;

function filterEntries(filterRegex, entries = []) {
if (filterRegex == null) {
return entries;
}

if (filterRegex instanceof RegExp) {
return entries.filter(entry => !entry.match(filterRegex));
}

return entries.filter(entry => !entry.match(new RegExp(filterRegex)));
}
19 changes: 19 additions & 0 deletions dist/lib/groupResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = groupResults;

var _update = _interopRequireDefault(require("lodash/update"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function groupResults(aggregatedResults) {
return aggregatedResults.testResults.reduce((acc, testResult) => {
testResult.testResults.forEach(test => {
(0, _update.default)(acc, test.ancestorTitles.concat('testResults'), value => (value ?? []).concat(test));
});
return acc;
}, {});
}
47 changes: 47 additions & 0 deletions dist/lib/groupSuites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = groupSuites;

var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));

var _sortEntries = _interopRequireDefault(require("./sortEntries"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function groupSuites(testResultGroup, filterRegex, sort) {
const testFilter = filterRegex instanceof RegExp ? filterRegex : new RegExp(filterRegex ?? '');
const outputFiles = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any

const generateFiles = (groups, parent = []) => {
Object.keys(groups).forEach(suite => {
if (filterRegex != null && suite.match(testFilter)) {
return;
}

const group = groups[suite];

if (group != null && group.testResults != null) {
const key = parent.concat(suite).filter(k => k).map(p => (0, _kebabCase.default)(p || '')).join('/');
outputFiles[key] = [`# ${suite}\n`].concat((0, _sortEntries.default)(sort, group.testResults.filter(test => {
if (filterRegex != null && test.title.match(testFilter)) {
return false;
}

return true;
}).map(test => `- ${test.title}`))).join('\n');
}

Object.keys(group).filter(k => k !== 'testResults').forEach(k => {
generateFiles({
[k]: group[k]
}, parent.concat(suite));
});
}, {});
};

generateFiles(testResultGroup);
return outputFiles;
}
22 changes: 22 additions & 0 deletions dist/lib/sortEntries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = sortEntries;

function sortEntries(sort, entries) {
if (!Array.isArray(entries)) {
return entries;
}

if (sort === 'asc') {
return entries.sort();
}

if (sort === 'desc') {
return entries.sort().reverse();
}

return entries;
}
87 changes: 87 additions & 0 deletions dist/reporter/multipleFileReporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;

var _chalk = _interopRequireDefault(require("chalk"));

var _fs = _interopRequireDefault(require("fs"));

var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));

var _mkdirp = _interopRequireDefault(require("mkdirp"));

var _path = _interopRequireDefault(require("path"));

var _filterEntries = _interopRequireDefault(require("../lib/filterEntries"));

var _groupResults = _interopRequireDefault(require("../lib/groupResults"));

var _groupSuites = _interopRequireDefault(require("../lib/groupSuites"));

var _sortEntries = _interopRequireDefault(require("../lib/sortEntries"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

async function _default(aggregatedResults, options) {
if (aggregatedResults == null) {
return;
}

const {
title = 'Docs',
logo,
sort = 'none',
filterRegex
} = options;

const currentPath = _path.default.resolve();

const outputPath = _path.default.resolve(currentPath, options.outputPath ?? './');

const testResultGroup = (0, _groupResults.default)(aggregatedResults);
const outputFiles = (0, _groupSuites.default)(testResultGroup, filterRegex, sort); // eslint-disable-next-line @typescript-eslint/no-explicit-any

function writeIndex(groups, parent = []) {
const index = [];

if (parent.length == 0) {
if (logo != null) {
index.push(`${logo}\n`);
}

index.push(`# ${title}\n`);
} else {
index.push(`# ${parent[parent.length - 1]}\n`);
}

(0, _sortEntries.default)(sort, (0, _filterEntries.default)(filterRegex, Object.keys(groups))).forEach(suite => {
if (groups[suite].testResults == null) {
index.push(`- [${suite}](${(0, _kebabCase.default)(suite)}/index.md)\n`);
writeIndex(groups[suite], parent.concat(suite));
} else {
index.push(`- [${suite}](${(0, _kebabCase.default)(suite)}.md)\n`);
}
});

const indexFile = _path.default.resolve(outputPath, parent.map(_kebabCase.default).join('/'), 'index.md');

_mkdirp.default.sync(_path.default.dirname(indexFile));

_fs.default.writeFileSync(indexFile, index.join('\n'));
}

writeIndex(testResultGroup);
Object.keys(outputFiles).forEach(key => {
const outputFile = _path.default.resolve(outputPath, `${key}.md`);

const content = outputFiles[key];

_mkdirp.default.sync(_path.default.dirname(outputFile));

_fs.default.writeFileSync(outputFile, content);
});
console.info(_chalk.default.greenBright(`@konecty/jest-doc-reporter >> ${Object.keys(outputFiles).length + 1} Reports generated to (${outputPath})`));
}
41 changes: 41 additions & 0 deletions dist/reporter/singleFileReporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;

var _chalk = _interopRequireDefault(require("chalk"));

var _fs = _interopRequireDefault(require("fs"));

var _mkdirp = _interopRequireDefault(require("mkdirp"));

var _path = _interopRequireDefault(require("path"));

var _index = _interopRequireDefault(require("./index"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

async function _default(aggregatedResults, options) {
if (aggregatedResults == null) {
return;
}

const result = (0, _index.default)({
testData: aggregatedResults,
options: options
});

const currentPath = _path.default.resolve();

const outputPath = _path.default.resolve(currentPath, options.outputPath ?? './');

_mkdirp.default.sync(outputPath);

const outputFile = _path.default.resolve(outputPath, 'index.md');

_fs.default.writeFileSync(outputFile, result);

console.info(_chalk.default.greenBright(`@konecty/jest-doc-reporter >> Report generated (${outputFile})`));
}

0 comments on commit 41046c8

Please sign in to comment.