webcomponents / webcomponents.github.io

WebComponents.org is where community-members document Web Components best practices
http://webcomponents.org
733 stars 118 forks source link

Article explaining how to do Unit Testing in Custom Elements #80

Closed zenorocha closed 9 years ago

zenorocha commented 10 years ago

This is another topic that is pretty important to cover.

I noticed that most Polymer/X-Tag elements contains unit tests. So maybe we can get someone from these teams to write about it. What do you think @addyosmani @robdodson @potch @sole @csuwildcat?

cironunes commented 10 years ago

I would be happy to work on this. I just need someone to review my work.

addyosmani commented 10 years ago

On the Polymer side we're hoping to get out an article about how we recommend unit testing at some point in the next few months, but I'd be really keen to see how this is applied to raw custom elements.

Fwiw, happy to review. We currently use Mocha and Chai for the testing side of things and it works quite well.

cironunes commented 10 years ago

I still need to figure out how to do that. Probably using something like di.js to simplify mocking the DOM.

Do you guys have any suggestions?

zenorocha commented 10 years ago

Here are some nice studies from @eee-c:

addyosmani commented 10 years ago

I've resumed my work on a Unit Testing primer for Polymer elements. We've been holding off due to some changes we wanted to land in seed-element, but with these now complete we should be able to get out more guidance on this topic soon.

@zenorocha There are some specific patterns we prefer to use for testing that aren't quite captured in the articles Chris has written, but we'll do our best to get this guide up in the next few weeks.

zenorocha commented 10 years ago

That's great to hear, thanks @addyosmani :)

Nevraeka commented 9 years ago

With the standardization of webcomponents-tester I think we do this now. @addyosmani - I would love to collaborate on an article for my own selfish desire to be better at testing components. If not, one of us could do it on our own. Let me know :)

addyosmani commented 9 years ago

I wrote https://www.polymer-project.org/0.5/articles/unit-testing-elements.html after my original comment which tried to walk through web-component-tester. We could definitely use a 1.0 update to this for the Polymer site, but it might make more sense there vs wc.org. That said, I'd also be interested in seeing a separate Custom Elements + WCT tutorial at some point :)

zenorocha commented 9 years ago

Closing this one for now since there was no action since last year, if there's anyone up to do that please send a PR.