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

Migrate to Web Test Runner and fix broken tests #137

Merged
merged 14 commits into from
May 6, 2022
Merged

Conversation

usergenic
Copy link
Contributor

Added a helpers.js to export a shared wait() function that we can use in tests to wait for renders to complete.

@usergenic usergenic changed the base branch from master to npm-audit-fix April 29, 2022 04:35
@usergenic usergenic requested a review from graynorton April 29, 2022 19:16
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz left a comment

Choose a reason for hiding this comment

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

Should the tests pass in this PR?
When I ran npm i, npm run bootstrap, and then npm run test, I get a test error.

virtualize > uses the provided method to render items
  Error: ResizeObserver loop limit exceeded

Otherwise looking great and only tiny license nits.

@usergenic
Copy link
Contributor Author

@AndrewJakubowicz thanks for running the tests locally-- I have gotten that error only once since switching so I thought I managed to work out how to await the reflows correctly. Looks like I have to dig in and get a more solid solution.

@graynorton
Copy link

@usergenic I don't think this is a timing issue with the tests. The ResizeObserver loop limit error is a genuine but (I believe) benign error that results from virtualizer's specific use of ResizeObserver, so I think what we'll want to do is catch this error and prevent it from causing the tests to fail. See #112 for a bit more background, and we can discuss.

Base automatically changed from npm-audit-fix to master May 3, 2022 17:44
@usergenic
Copy link
Contributor Author

I added a helper to specifically swallow errors captured by window.onerror which matched the ResizeObserver loop limit exceeded case in test/helpers.js called ignoreBenignErrors. It can be added basically once per file so that it attaches setup/teardown to the Mocha context properly. It still outputs a warning to console so we can see when they happen, but it won't fail tests now.

 🚧 Browser logs:
      Error: IGNORE_ME
        at test/scenarios/testing-setup.test.js:18:19
      Ignored Error: Uncaught Error: IGNORE_ME

test/scenarios/smoke.test.js:

 🚧 Browser logs:
      null
      Ignored Error: ResizeObserver loop limit exceeded

Chrome: |██████████████████████████████| 3/3 test files | 4 passed, 0 failed

@usergenic usergenic requested a review from AndrewJakubowicz May 4, 2022 05:06
import { ignoreWindowErrors, wait } from "../helpers.js";
import { expect } from "@esm-bundle/chai";

describe('ignoreWindowErrors helper', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Some additional tests:

  • A test where the thrown error doesn't match the regex and isn't caught.
  • Maybe a test that checks that afterEach is cleaning up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure how to use Mocha to test Mocha hooks just yet. But I added a nested case and an explicit error if teardown encounters an unexpected value in window.onerror...

Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz left a comment

Choose a reason for hiding this comment

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

Sorry for these questions, this is looking great. These are just for context.

Will migrating the screenshot.js tests come in a follow up PR? Currently npm run test:screenshot doesn't work.

Thank you!

@usergenic
Copy link
Contributor Author

@AndrewJakubowicz yeah I am not deleting screenshot tests yet, but getting them fixed will be a much different undertaking. I tried messing with them but it got really fiddly really fast and there were enough changes in this one.

@usergenic usergenic requested a review from AndrewJakubowicz May 5, 2022 15:38
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

@graynorton graynorton left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

3 participants