From 3bbbb342b9df1b28ad439d5b6b052ac603394554 Mon Sep 17 00:00:00 2001 From: Bianca Danforth Date: Mon, 19 Aug 2019 17:04:52 -0700 Subject: [PATCH] Exclude affected functions from coverage Add '/* istanbul ignore next */' to stop trying to cover the following methods, since they are executed in the 'isVisible.html' test page, and that scope does not have coverage variables defined. * ancestors * isDomElement * isVisible * toDomElement This allows coverage to continue to work (ignoring these functions) and keeps the JS functional tests in the same stage as the rest of the JavaScript tests in TravisCI. It should be noted that none of these functions previously had test coverage, which is part of why this approach is feasible. --- Makefile | 2 +- utilsForFrontend.mjs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 264286bf..a11a8167 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ test: $(JS) pytest cli/fathom_web/test coverage: $(JS) - @node_modules/.bin/istanbul cover node_modules/.bin/mocha -- --recursive + @node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- --recursive debugtest: $(JS) # This is known to work on node 7.6.0. diff --git a/utilsForFrontend.mjs b/utilsForFrontend.mjs index 08774d24..27b2e50e 100644 --- a/utilsForFrontend.mjs +++ b/utilsForFrontend.mjs @@ -389,6 +389,7 @@ export function domSort(fnodes) { /** * @return whether a thing appears to be a DOM element. */ +/* istanbul ignore next */ export function isDomElement(thing) { return thing.nodeName !== undefined; } @@ -399,6 +400,7 @@ export function isDomElement(thing) { * * @arg fnodeOrElement {Node|Fnode} */ +/* istanbul ignore next */ export function toDomElement(fnodeOrElement) { return isDomElement(fnodeOrElement) ? fnodeOrElement : fnodeOrElement.element; } @@ -436,6 +438,7 @@ export function attributesMatch(element, predicate, attrs = []) { /** * Yield an element and each of its ancestors. */ +/* istanbul ignore next */ export function *ancestors(element) { yield element; let parent; @@ -461,6 +464,7 @@ export function sigmoid(x) { * Return whether an element is practically visible, considering things like 0 * size or opacity, ``visibility: hidden`` and ``overflow: hidden``. */ +/* istanbul ignore next */ export function isVisible(fnodeOrElement) { // This could be 5x more efficient if https://github.com/w3c/csswg-drafts/issues/4122 happens. const element = toDomElement(fnodeOrElement);