Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Polymer error only on command line #3165

Open 6palace opened 7 years ago

6palace commented 7 years ago

We execute tests on some polymer elements both using command line wct and directly as html files. Recently, without significant changes in source or test code, we are getting a polymer error on the flush command. Stacktrace here:


  Cannot read property '_useContent' of null
    <unknown> at         HTMLElement._composeTree at /components/uaa-dashboard/app/bower_components/polymer/polymer-mini.html:1850:0
    <unknown> at    HTMLElement._finishDistribute at /components/uaa-dashboard/app/bower_components/polymer/polymer-mini.html:1767:0
    <unknown> at   HTMLElement._distributeContent at /components/uaa-dashboard/app/bower_components/polymer/polymer-mini.html:1747:0
    <unknown> at               Debouncer.complete at /components/uaa-dashboard/app/bower_components/polymer/polymer-mini.html:2085:0
    <unknown> at                   Function.flush at /components/uaa-dashboard/app/bower_components/polymer/polymer-mini.html:1287:0
    <unknown> at              Context.<anonymous> at test.html:682:0

The error shows up only on one test in the suite, even though all tests use the flush function, and all subsequent tests pass. Also, the failure is not test-specific: commenting out the failing test results in the next test failing instead, and then all other tests in the suite passing.

This error furthermore only shows up when running tests in command line, and does not occur when loading test.html directly. It is looking very mysterious to me, thanks for the help!

justinfagnani commented 7 years ago

@6palace can you post a minimal reproduction at all?

6palace commented 7 years ago

I haven't been able to localize the error yet, since it's so particular, so not immediately. The project is not open source, but I might be able to isolate it down to a subset of source code and send you that to reproduce. Would that be okay?

justinfagnani commented 7 years ago

That's better than nothing :)

A few shots in the dark: Do you have a setup function in your tests? Are you using test-fixture?

6palace commented 7 years ago

Yes, we do use test-fixture, our setup creates a sinon fakeserver as well as the createFixture command.

Also, a little more digging: our wct config points towards a test index that loadSuites all our individual element tests. The number of suites being loaded in affects whether the failure manifests, so I don't think I'll be able to narrow the source code.

The whole thing feels like a performance problem to me, maybe our polymer elements are getting too complicated? We are doing a lot of element nesting, could that cause this sort of error?

6palace commented 7 years ago

Hi @justinfagnani, so I've managed to get around this error in two ways.

  1. Refactoring of the tested element. I moved the biggest nested element into a slot instead of being directly in the parent element. That element is being tested separately. This suggests that the error is performance-related.

  2. Our tested element calls a refresh on the attached hook, which initiates an ajax call that in our tests is caught and returned by sinon. When I switched this refresh to happen on an observer instead, and then manually called it in the tests before the failing flush function, the error does not show up. Possibly this means there's some timing confusion between the first flush and the attached handler?

We can close the issue, but bug is still hidden somewhere, so your choice.

Incidentally, (maybe a separate issue) when a test fails in the beforeEach call in using wct command, the failures do not show up in the test results, my only indication is in the lowered test coverage. Is there a way around this?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.