Skip to content

Commit 720da56

Browse files
committed
refactor: Correct under-reported code coverage for Options/parsers
buildConfigDefinitions imported parsers from ../src/Options/parsers at module scope. Loading it in a spec instruments the real src file a second time (top level only), colliding with the sourcemap-remapped lib coverage from parsers.spec.js and clobbering it down to ~2.5%. Move the require into parseDefaultValue, its only consumer, so the module reports its true 100%.
1 parent 7e9d53a commit 720da56

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

resources/buildConfigDefinitions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* To rebuild the definitions file, run
1010
* `$ node resources/buildConfigDefinitions.js`
1111
*/
12-
const parsers = require('../src/Options/parsers');
1312

1413
/** The types of nested options. */
1514
const nestedOptionTypes = [
@@ -190,6 +189,8 @@ function mapperFor(elt, t) {
190189
}
191190

192191
function parseDefaultValue(elt, value, t) {
192+
/* istanbul ignore next: lazy require (not module scope) so specs don't double-instrument parsers.js; only reached by `npm run definitions` */
193+
const parsers = require('../src/Options/parsers');
193194
let literalValue;
194195
if (t.isStringTypeAnnotation(elt)) {
195196
if (value == '""' || value == "''") {

0 commit comments

Comments
 (0)