Skip to content

Commit

Permalink
Exclude affected functions from coverage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
biancadanforth committed Aug 20, 2019
1 parent 8d87435 commit 3bbbb34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions utilsForFrontend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 3bbbb34

Please sign in to comment.