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

Our tests should be running in real browsers as well as Node #2359

Open
dead-claudia opened this issue Jan 17, 2019 · 0 comments
Open

Our tests should be running in real browsers as well as Node #2359

dead-claudia opened this issue Jan 17, 2019 · 0 comments
Labels
Area: Workflow For anything dealing with Mithril's internal tooling, including the mocks and bundler, but not ospec Type: Bug For bugs and any other unexpected breakage Type: Meta/Feedback For high-level discussion around the project and/or community itself

Comments

@dead-claudia
Copy link
Member

We need to start testing our code in real browsers and in ES5 environments to avoid issues like this, reported on Gitter. It'd also make it much easier to detect and test for IE bugs, if we could get on either BrowserStack's or Sauce Labs' open source plans, but we first need to get our end together so we can even use it.

Here's the state of everything:

  • All our browser tests have a web page with all the relevant tests loaded via <script src="..."></script>.
  • Our browser test pages rely on a require pseudo-polyfill that doesn't even wrap modules in a closure when executing them.
  • Our tests exclusively use DOM mocks, missing 100% of browser-specific bugs.
  • We're only actively testing it in the latest Node, using our own mocks instead of something like JSDOM.

This is low priority for now, but I am working on it partially in my local Rollup migration branch (slated for a future PR). Here's my plan, some of which I've already got resolved locally:

  • Migrate the tests to grab their mocks from a global instance, created from a test bundle rather than the individual files.
  • Migrate the web pages to load only the tests and the generated test bundle.
  • Make ospec on npm test load the generated test bundle before executing tests in Node.
  • Create a karma-ospec to tell Karma how to handle ospec results
    • I'll need to add a feature for async test reporting, so Karma doesn't go ballistic over not receiving a single event in the ~3 seconds it takes to run everything, in case the browser briefly disconnects in the middle of test execution. (Karma's timeout is 2000ms = 2 seconds, which is a problem.)
  • Switch our browser test runner to Karma
  • Set up Travis to run it in Chrome, Firefox, and Safari using their respective launchers.
    • This is probably going to be the easiest part of this.
  • Migrate the DOM tests off of the mocks as much as practically possible.
    • Testing for ev.preventDefault() is as simple as checking ev.defaultPrevented
    • Testing for ev.stopPropagation() is as simple as firing an event that can propagate and ensuring it doesn't get found by the parent.
    • The valueSetter and typeSetter spies could just be replaced with an interim hack for elem.value and input.type, which we'd remove once we incorporate IE into the test matrix. (We can do this on Travis with their early stage Windows CI support, but note that Edge is not available without something like Sauce Labs or BrowserStack.)
  • Set up Travis to run tests in IE via karma-ie-launcher. This includes the promise polyfill, streams, and everything.
  • And then, we can then confidently say things actually work and aren't a house of cards ready to fall over and collapse.

As for the above, I only locally have the first done completely and the second done for /api/tests/*.js only.

@dead-claudia dead-claudia added Type: Bug For bugs and any other unexpected breakage Area: Workflow For anything dealing with Mithril's internal tooling, including the mocks and bundler, but not ospec Type: Meta/Feedback For high-level discussion around the project and/or community itself labels Jan 17, 2019
@dead-claudia dead-claudia moved this to Low priority in Triage/bugs Sep 2, 2024
@dead-claudia dead-claudia mentioned this issue Oct 13, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Workflow For anything dealing with Mithril's internal tooling, including the mocks and bundler, but not ospec Type: Bug For bugs and any other unexpected breakage Type: Meta/Feedback For high-level discussion around the project and/or community itself
Projects
Status: Low priority
Development

No branches or pull requests

1 participant