devtools-highlighter icon indicating copy to clipboard operation
devtools-highlighter copied to clipboard

Implement tests!

Open captainbrosset opened this issue 7 years ago • 3 comments

This was hacked up together in one evening, so of course tests were the last thing on my mind. But it won't be able to survive much longer without proper testing.

captainbrosset avatar Dec 08 '17 08:12 captainbrosset

I want to do that, but I don't have any experience. Maybe you can give me some source, or names how I should google it to learn it? @captainbrosset ? @juliandescottes

AugustasV avatar Jan 04 '18 17:01 AugustasV

Thanks @AugustasV !

There are no "extension-specific" tests we could easily implement, so the best to get started would be to pick a javascript unit test framework and write unit tests after extracting the main logic of the extension to dedicated files.

Some devtools repositories use jest, so that might be an option. Let me know if you need pointers on how to set this up for this project. Setting up a unit-testing solution will already be a great step forward here.

Regarding actually writing test, it can be done afterwards. I haven't read the code in too much details so @captainbrosset probably can point to which part of the code would be worth testing at the moment?

juliandescottes avatar Jan 07 '18 23:01 juliandescottes

This sounds like a good plan. Thank you @juliandescottes.

In terms of what to test, an interesting part is in https://github.com/captainbrosset/devtools-highlighter/blob/master/src/devtools/panel/devtools-panel.js

This is where the code that displays nodes and handles UI interactions currently lives. It can, indeed, be broken up into smaller files that are easier to test.

The other part is in https://github.com/captainbrosset/devtools-highlighter/blob/master/src/content_scripts/content.js That's the code that is responsible for finding nodes in the page based on search queries. The most complex code is the one that parses and executes CSS computed style queries. Adding tests for this would be awesome. And, again, moving this to its own file would be great too.

captainbrosset avatar Jan 08 '18 09:01 captainbrosset