blade-ui-kit icon indicating copy to clipboard operation
blade-ui-kit copied to clipboard

Improve `assertComponentRenders` from ComponentTestCase.

Open mattcookdev opened this issue 5 years ago • 3 comments
trafficstars

Wanted to try have a go at PRing some of the component suggestions, but when it comes to writing tests it was made basically impossible (or at least very unenjoyable) by the fact that assertComponentRenders includes what I assume is EOL or something of a similar nature. (Invisible Characters)

My tests were outputting pretty much exactly what was expected, except for like 1 random "space" that didn't exist. Even after completely disabling EOL/Linebreak in my editor, it continued to happen in the tests.

Not sure if there is something I'm unaware of since I'm pretty new to OSS, and I'm not sure if this is something that can really be improved or fixed, but I think it would help people contribute a lot easier if this wasn't an issue (or there was some documentation explaining what/why it happens in the contributor section and what we should do to deal with it.) because while I was developing some of the components, I spent maybe 15-20 minutes actually writing the components, and then an additional 2 hours trying to get the tests to pass when this issue stated was pretty much the only reason they weren't passing.

Hopefully this can be looked into, and I'm happy to try help solve it if necessary. Just figured I would post this since I'm only really assuming what I said above is the issue and not 100% certain.

mattcookdev avatar Sep 07 '20 08:09 mattcookdev

Sigh, I know. While I was developing Blade UI Kit I spent a lot of time searching for a HTML formatting library for PHP but there's nothing decent out there unfortunately. So I had to "homebrew" my own solution which is indeed not very feasible. I realise this is off putting in writing tests but I've maxed my limits atm at improving it. I'm hoping someone comes along that can help out here or that a decent HTML formatting library gets released at some point.

driesvints avatar Sep 09 '20 20:09 driesvints

Yeah I've had issues in the past finding similar libraries. They are a nightmare... 😅

Not sure exactly, but perhaps it would be easier/better for us to just strip white space out completely if possible? E.g this;

<div>
    <p></p>
</div>

Becomes this;

<div><p></p></div>

And we can assert against that.

I think this would also lead to the tests being more "reliable" since HTML itself doesn't really care about indentation/whitespace, so by removing it I think it would improve the tests by removing that variable from it entirely.😊

This also promotes the tests being more about the component output itself as opposed to worrying about whitespace which I think is a huge plus!

mattcookdev avatar Sep 10 '20 00:09 mattcookdev

Not sure exactly, but perhaps it would be easier/better for us to just strip white space out completely if possible?

I'd rather not tbh. That would clutter up the tests and make them very unreadable. I really want to dig into a better HTML formatter if possible.

driesvints avatar Sep 10 '20 08:09 driesvints

@driesvints now that this PR (https://github.com/blade-ui-kit/blade-ui-kit/pull/154) is merged, I think you can close this issue.

alexmanase avatar Mar 29 '24 15:03 alexmanase

Thanks @alexmanase!

driesvints avatar Apr 02 '24 08:04 driesvints