From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../istanbul-reports/lib/clover/index.js | 163 ++++++++ .../istanbul-reports/lib/cobertura/index.js | 151 ++++++++ .../istanbul-reports/lib/html-spa/.babelrc | 3 + .../istanbul-reports/lib/html-spa/assets/bundle.js | 30 ++ .../lib/html-spa/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../istanbul-reports/lib/html-spa/assets/spa.css | 298 +++++++++++++++ .../istanbul-reports/lib/html-spa/index.js | 176 +++++++++ .../lib/html-spa/src/fileBreadcrumbs.js | 31 ++ .../lib/html-spa/src/filterToggle.js | 50 +++ .../lib/html-spa/src/flattenToggle.js | 25 ++ .../lib/html-spa/src/getChildData.js | 155 ++++++++ .../istanbul-reports/lib/html-spa/src/index.js | 160 ++++++++ .../istanbul-reports/lib/html-spa/src/routing.js | 52 +++ .../lib/html-spa/src/summaryHeader.js | 63 +++ .../lib/html-spa/src/summaryTableHeader.js | 130 +++++++ .../lib/html-spa/src/summaryTableLine.js | 159 ++++++++ .../lib/html-spa/webpack.config.js | 22 ++ .../istanbul-reports/lib/html/annotator.js | 305 +++++++++++++++ .../istanbul-reports/lib/html/assets/base.css | 224 +++++++++++ .../lib/html/assets/block-navigation.js | 86 +++++ .../istanbul-reports/lib/html/assets/favicon.png | Bin 0 -> 445 bytes .../lib/html/assets/sort-arrow-sprite.png | Bin 0 -> 138 bytes .../istanbul-reports/lib/html/assets/sorter.js | 209 ++++++++++ .../lib/html/assets/vendor/prettify.css | 1 + .../lib/html/assets/vendor/prettify.js | 1 + .../istanbul-reports/lib/html/index.js | 421 +++++++++++++++++++++ .../istanbul-reports/lib/html/insertion-text.js | 114 ++++++ .../istanbul-reports/lib/json-summary/index.js | 56 +++ .../istanbul-reports/lib/json/index.js | 44 +++ .../istanbul-reports/lib/lcov/index.js | 33 ++ .../istanbul-reports/lib/lcovonly/index.js | 77 ++++ .../istanbul-reports/lib/none/index.js | 10 + .../istanbul-reports/lib/teamcity/index.js | 67 ++++ .../istanbul-reports/lib/text-lcov/index.js | 17 + .../istanbul-reports/lib/text-summary/index.js | 62 +++ .../istanbul-reports/lib/text/index.js | 298 +++++++++++++++ 36 files changed, 3693 insertions(+) create mode 100644 vanilla/node_modules/istanbul-reports/lib/clover/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/cobertura/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/.babelrc create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/assets/bundle.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/assets/sort-arrow-sprite.png create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/assets/spa.css create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/fileBreadcrumbs.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/filterToggle.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/flattenToggle.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/getChildData.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/routing.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryHeader.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableHeader.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/src/summaryTableLine.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html-spa/webpack.config.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/annotator.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/base.css create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/block-navigation.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/favicon.png create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/sort-arrow-sprite.png create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/sorter.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/vendor/prettify.css create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/assets/vendor/prettify.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/html/insertion-text.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/json-summary/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/json/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/lcov/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/lcovonly/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/none/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/teamcity/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/text-lcov/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/text-summary/index.js create mode 100644 vanilla/node_modules/istanbul-reports/lib/text/index.js (limited to 'vanilla/node_modules/istanbul-reports/lib') diff --git a/vanilla/node_modules/istanbul-reports/lib/clover/index.js b/vanilla/node_modules/istanbul-reports/lib/clover/index.js new file mode 100644 index 0000000..40d1606 --- /dev/null +++ b/vanilla/node_modules/istanbul-reports/lib/clover/index.js @@ -0,0 +1,163 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const { ReportBase } = require('istanbul-lib-report'); + +class CloverReport extends ReportBase { + constructor(opts) { + super(); + + this.cw = null; + this.xml = null; + this.file = opts.file || 'clover.xml'; + } + + onStart(root, context) { + this.cw = context.writer.writeFile(this.file); + this.xml = context.getXMLWriter(this.cw); + this.writeRootStats(root, context); + } + + onEnd() { + this.xml.closeAll(); + this.cw.close(); + } + + getTreeStats(node, context) { + const state = { + packages: 0, + files: 0, + classes: 0 + }; + const visitor = { + onSummary(node, state) { + const metrics = node.getCoverageSummary(true); + if (metrics) { + state.packages += 1; + } + }, + onDetail(node, state) { + state.classes += 1; + state.files += 1; + } + }; + node.visit(context.getVisitor(visitor), state); + return state; + } + + writeRootStats(node, context) { + this.cw.println(''); + this.xml.openTag('coverage', { + generated: Date.now().toString(), + clover: '3.2.0' + }); + + this.xml.openTag('project', { + timestamp: Date.now().toString(), + name: 'All files' + }); + + const metrics = node.getCoverageSummary(); + this.xml.inlineTag('metrics', { + statements: metrics.lines.total, + coveredstatements: metrics.lines.covered, + conditionals: metrics.branches.total, + coveredconditionals: metrics.branches.covered, + methods: metrics.functions.total, + coveredmethods: metrics.functions.covered, + elements: + metrics.lines.total + + metrics.branches.total + + metrics.functions.total, + coveredelements: + metrics.lines.covered + + metrics.branches.covered + + metrics.functions.covered, + complexity: 0, + loc: metrics.lines.total, + ncloc: metrics.lines.total, // what? copied as-is from old report + ...this.getTreeStats(node, context) + }); + } + + writeMetrics(metrics) { + this.xml.inlineTag('metrics', { + statements: metrics.lines.total, + coveredstatements: metrics.lines.covered, + conditionals: metrics.branches.total, + coveredconditionals: metrics.branches.covered, + methods: metrics.functions.total, + coveredmethods: metrics.functions.covered + }); + } + + onSummary(node) { + if (node.isRoot()) { + return; + } + const metrics = node.getCoverageSummary(true); + if (!metrics) { + return; + } + + this.xml.openTag('package', { + name: asJavaPackage(node) + }); + this.writeMetrics(metrics); + } + + onSummaryEnd(node) { + if (node.isRoot()) { + return; + } + this.xml.closeTag(this.xml.stack[this.xml.stack.length - 1]); + } + + onDetail(node) { + const fileCoverage = node.getFileCoverage(); + const metrics = node.getCoverageSummary(); + const branchByLine = fileCoverage.getBranchCoverageByLine(); + + this.xml.openTag('file', { + name: asClassName(node), + path: fileCoverage.path + }); + + this.writeMetrics(metrics); + + const lines = fileCoverage.getLineCoverage(); + Object.entries(lines).forEach(([k, count]) => { + const attrs = { + num: k, + count, + type: 'stmt' + }; + const branchDetail = branchByLine[k]; + + if (branchDetail) { + attrs.type = 'cond'; + attrs.truecount = branchDetail.covered; + attrs.falsecount = branchDetail.total - branchDetail.covered; + } + this.xml.inlineTag('line', attrs); + }); + + this.xml.closeTag('file'); + } +} + +function asJavaPackage(node) { + return node + .getRelativeName() + .replace(/\//g, '.') + .replace(/\\/g, '.') + .replace(/\.$/, ''); +} + +function asClassName(node) { + return node.getRelativeName().replace(/.*[\\/]/, ''); +} + +module.exports = CloverReport; diff --git a/vanilla/node_modules/istanbul-reports/lib/cobertura/index.js b/vanilla/node_modules/istanbul-reports/lib/cobertura/index.js new file mode 100644 index 0000000..e5574fa --- /dev/null +++ b/vanilla/node_modules/istanbul-reports/lib/cobertura/index.js @@ -0,0 +1,151 @@ +'use strict'; +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +const path = require('path'); +const { escape } = require('html-escaper'); +const { ReportBase } = require('istanbul-lib-report'); + +class CoberturaReport extends ReportBase { + constructor(opts) { + super(); + + opts = opts || {}; + + this.cw = null; + this.xml = null; + this.timestamp = opts.timestamp || Date.now().toString(); + this.projectRoot = opts.projectRoot || process.cwd(); + this.file = opts.file || 'cobertura-coverage.xml'; + } + + onStart(root, context) { + this.cw = context.writer.writeFile(this.file); + this.xml = context.getXMLWriter(this.cw); + this.writeRootStats(root); + } + + onEnd() { + this.xml.closeAll(); + this.cw.close(); + } + + writeRootStats(node) { + const metrics = node.getCoverageSummary(); + this.cw.println(''); + this.cw.println( + '' + ); + this.xml.openTag('coverage', { + 'lines-valid': metrics.lines.total, + 'lines-covered': metrics.lines.covered, + 'line-rate': metrics.lines.pct / 100.0, + 'branches-valid': metrics.branches.total, + 'branches-covered': metrics.branches.covered, + 'branch-rate': metrics.branches.pct / 100.0, + timestamp: this.timestamp, + complexity: '0', + version: '0.1' + }); + this.xml.openTag('sources'); + this.xml.inlineTag('source', null, this.projectRoot); + this.xml.closeTag('sources'); + this.xml.openTag('packages'); + } + + onSummary(node) { + const metrics = node.getCoverageSummary(true); + if (!metrics) { + return; + } + this.xml.openTag('package', { + name: node.isRoot() ? 'main' : escape(asJavaPackage(node)), + 'line-rate': metrics.lines.pct / 100.0, + 'branch-rate': metrics.branches.pct / 100.0 + }); + this.xml.openTag('classes'); + } + + onSummaryEnd(node) { + const metrics = node.getCoverageSummary(true); + if (!metrics) { + return; + } + this.xml.closeTag('classes'); + this.xml.closeTag('package'); + } + + onDetail(node) { + const fileCoverage = node.getFileCoverage(); + const metrics = node.getCoverageSummary(); + const branchByLine = fileCoverage.getBranchCoverageByLine(); + + this.xml.openTag('class', { + name: escape(asClassName(node)), + filename: path.relative(this.projectRoot, fileCoverage.path), + 'line-rate': metrics.lines.pct / 100.0, + 'branch-rate': metrics.branches.pct / 100.0 + }); + + this.xml.openTag('methods'); + const fnMap = fileCoverage.fnMap; + Object.entries(fnMap).forEach(([k, { name, decl }]) => { + const hits = fileCoverage.f[k]; + this.xml.openTag('method', { + name: escape(name), + hits, + signature: '()V' //fake out a no-args void return + }); + this.xml.openTag('lines'); + //Add the function definition line and hits so that jenkins cobertura plugin records method hits + this.xml.inlineTag('line', { + number: decl.start.line, + hits + }); + this.xml.closeTag('lines'); + this.xml.closeTag('method'); + }); + this.xml.closeTag('methods'); + + this.xml.openTag('lines'); + const lines = fileCoverage.getLineCoverage(); + Object.entries(lines).forEach(([k, hits]) => { + const attrs = { + number: k, + hits, + branch: 'false' + }; + const branchDetail = branchByLine[k]; + + if (branchDetail) { + attrs.branch = true; + attrs['condition-coverage'] = + branchDetail.coverage + + '% (' + + branchDetail.covered + + '/' + + branchDetail.total + + ')'; + } + this.xml.inlineTag('line', attrs); + }); + + this.xml.closeTag('lines'); + this.xml.closeTag('class'); + } +} + +function asJavaPackage(node) { + return node + .getRelativeName() + .replace(/\//g, '.') + .replace(/\\/g, '.') + .replace(/\.$/, ''); +} + +function asClassName(node) { + return node.getRelativeName().replace(/.*[\\/]/, ''); +} + +module.exports = CoberturaReport; diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/.babelrc b/vanilla/node_modules/istanbul-reports/lib/html-spa/.babelrc new file mode 100644 index 0000000..f995d68 --- /dev/null +++ b/vanilla/node_modules/istanbul-reports/lib/html-spa/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": [["@babel/preset-env", { "modules": "commonjs" }], "@babel/preset-react"] +} diff --git a/vanilla/node_modules/istanbul-reports/lib/html-spa/assets/bundle.js b/vanilla/node_modules/istanbul-reports/lib/html-spa/assets/bundle.js new file mode 100644 index 0000000..341b64f --- /dev/null +++ b/vanilla/node_modules/istanbul-reports/lib/html-spa/assets/bundle.js @@ -0,0 +1,30 @@ +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var l=t[r]={i:r,l:!1,exports:{}};return e[r].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var l in e)n.d(r,l,function(t){return e[t]}.bind(null,l));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";e.exports=n(3)},function(e,t,n){"use strict"; +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/var r=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,o,u=a(e),c=1;ce.length)&&(t=e.length);for(var n=0,r=Array(t);nO.length&&O.push(e)}function I(e,t,n){return null==e?0:function e(t,n,r,l){var o=typeof t;"undefined"!==o&&"boolean"!==o||(t=null);var u=!1;if(null===t)u=!0;else switch(o){case"string":case"number":u=!0;break;case"object":switch(t.$$typeof){case i:case a:u=!0}}if(u)return r(l,t,""===n?"."+M(t,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(t))for(var c=0;c