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

Switch to jsdom for tests. #935

Merged
merged 7 commits into from
Nov 30, 2017
Merged

Switch to jsdom for tests. #935

merged 7 commits into from
Nov 30, 2017

Conversation

DylanPiercey
Copy link
Contributor

Description

Switches test suite from phantomjs to jsdom. This decreases test run time from ~7:30 to ~1:30 on my machine. Also several (large) dev dependencies were able to be removed.

Motivation and Context

Improve amount of time it takes to run tests.

Checklist:

  • My code follows the code style of this project.
  • I have updated/added documentation affected by my changes.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DylanPiercey DylanPiercey force-pushed the jsdom-tests branch 4 times, most recently from f5f70d8 to 84d074a Compare November 28, 2017 00:09
@coveralls
Copy link

Coverage Status

Coverage decreased (-10.8%) to 79.824% when pulling 1509ad8 on jsdom-tests into ae2066f on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage decreased (-10.8%) to 79.824% when pulling 1509ad8 on jsdom-tests into ae2066f on master.

@codecov
Copy link

codecov bot commented Nov 28, 2017

Codecov Report

Merging #935 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #935   +/-   ##
=======================================
  Coverage   90.57%   90.57%           
=======================================
  Files         309      309           
  Lines       11390    11390           
=======================================
  Hits        10317    10317           
  Misses       1073     1073

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae2066f...a485463. Read the comment docs.

.travis.yml Outdated
@@ -1,8 +1,8 @@
sudo: false
node_js:
- "4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize jsdom doesn't support Node 4, but Marko 4 still does. This means we will either have to strengthen our linting rules to ensure we aren't breaking Node 4, or this is a major version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Michael and I were talking about this. I agree it should be under a major. We were debating if it would make sense to just release a Marko v5 (and start releasing mostly non breaking majors more often) or I may just switch back to jsdom 9. We can hash this out tomorrow morning though.

runner.on('end', function () {
cleanup();
runner.stats.failures.length
? reject(new Error(''))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we report the errors? Perhaps .join them?

return new Promise(function (resolve, reject) {
window.addEventListener('load', function () {
var runner = window.MOCHA_RUNNER;
runner.on('end', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the runner never emits end, will the tests infinitely hang?

@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage decreased (-10.8%) to 79.824% when pulling 6a221ba on jsdom-tests into ae2066f on master.

@coveralls
Copy link

coveralls commented Nov 28, 2017

Coverage Status

Coverage increased (+0.009%) to 90.588% when pulling 31505d4 on jsdom-tests into ae2066f on master.

runner.on('end', function () {
if (shouldCover) {
var coverageFile = getCoverageFile(options.testsFile);
fs.writeFileSync(coverageFile, JSON.stringify(window.__coverage__));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If writeFileSync throws, the tests will hang because the promise will never reject. Additionally, since this code is already async, why not just use fs.writeFile instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I thought of switching it but it was just left over from copy pasting.

I’ll clean that up.

@@ -124,23 +118,35 @@ function generate(options) {

function runTests(options) {
return generate(options).then(generated => {
console.log(`Running ${generated.url} using mocha-phantomjs...`);
var mochaPhantomJSOptions = { useColors: true };
var cleanup = JSDOM(fs.readFileSync(generated.url, 'utf-8'), {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this does not have to be sync either

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 87.986% when pulling e4e1386 on jsdom-tests into ae2066f on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 87.986% when pulling e4e1386 on jsdom-tests into ae2066f on master.

@coveralls
Copy link

coveralls commented Nov 30, 2017

Coverage Status

Coverage decreased (-2.6%) to 87.986% when pulling e4e1386 on jsdom-tests into ae2066f on master.

@coveralls
Copy link

coveralls commented Nov 30, 2017

Coverage Status

Coverage decreased (-2.6%) to 87.986% when pulling fbd58d5 on jsdom-tests into ae2066f on master.

@coveralls
Copy link

coveralls commented Nov 30, 2017

Coverage Status

Coverage remained the same at 90.579% when pulling a485463 on jsdom-tests into ae2066f on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 90.579% when pulling a485463 on jsdom-tests into ae2066f on master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 30, 2017

Coverage Status

Coverage remained the same at 90.579% when pulling a485463 on jsdom-tests into ae2066f on master.

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.

4 participants