1

I am running through some test suites, but the trouble is the test assertions are coming back negative because I cannot seem to access the pulled through content of the slot!

Basically looking for some resources and guidance on polymer 2 testing practices for slotted content

Any help appreciated

Intervalia
  • 10,248
  • 2
  • 30
  • 60
Ian Warner
  • 1,058
  • 13
  • 32

1 Answers1

1

Something like this might help to assert the contents of slots:

    var slots = this.shadowRoot.querySelectorAll("slot")
    for (var i = 0, len = slots.length; i < len; i++) {
        console.log("slot: ", slots[i].assignedNodes());
        if (slots[i].assignedNodes().length != 0) {
            // assert something
...

This queries the slots of the shadowRoot and iterates them. With assignedNodes you get the contents of the respective slot.