Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - add JS functional test harness #2

Merged
merged 13 commits into from
Aug 21, 2019
Merged

Conversation

biancadanforth
Copy link
Owner

No description provided.

@biancadanforth biancadanforth force-pushed the 122-js-test-harness branch 7 times, most recently from e99b94f to 8711868 Compare August 5, 2019 22:47
@biancadanforth biancadanforth force-pushed the 122-js-test-harness branch 4 times, most recently from 34c04b0 to 3ef19ca Compare August 9, 2019 16:35
@biancadanforth
Copy link
Owner Author

Rebased this branch off of the upstream/is-visible branch in mozilla#116. Only the last 3 commits are new.

@biancadanforth biancadanforth force-pushed the 122-js-test-harness branch 17 times, most recently from 1ee42b0 to 4e265b1 Compare August 10, 2019 16:55
@biancadanforth biancadanforth force-pushed the 122-js-test-harness branch 4 times, most recently from ef95292 to f9bb999 Compare August 14, 2019 04:04
Now that we are actually linting the isVisible.js functional test, eslint reports an error:
```
/home/travis/build/mozilla/fathom/test/functional/isVisible.js

  4:68  error  "../../utilsForFrontend" is not found  node/no-missing-require
```
I believe this is because 'require' is relative to the directory in which the script is found, while eslint is checking relative to the current working directory.

This could be resolved by:
* Ignoring the error (easiest)
* Updating 'eslint-plugin-node' to >= v5.1.0 in which we can apply the 'resolvePaths' setting.
  * This requires also updating 'eslint', as otherwise 'make lint' fails
  * Updating 'eslint' updates default rules, for which there are then dozens of new violations throughout the source code to address
  * I vote that considering updating eslint be a follow-up issue, rather than part of fixing mozilla#122

In light of these options, I chose the best, easiest one, since it doesn't blow up everything else.
Added a timeout to the 'after all' hook, as it is possible this can take longer than two seconds.

Also made the callbacks into 'it' regular functions instead of arrow functions for consistency with the 'after all' hook.
 * With arrow functions, the 'this' binding for 'this.timeout' does not point to the desired target, and the 'after' hook threw an error if I tried to use the original approach I had with the 'it' blocks.
@biancadanforth biancadanforth force-pushed the 122-js-test-harness branch 4 times, most recently from e3bc99a to 3bbbb34 Compare August 20, 2019 01:37
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.
Move the set up and tear down commands inside of 'npm test' instead of just in '.travis.yml'.
@biancadanforth biancadanforth merged commit b04d519 into master Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant