Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve assertComponentRenders from ComponentTestCase. #55

Closed
mattcookdev opened this issue Sep 7, 2020 · 5 comments
Closed

Improve assertComponentRenders from ComponentTestCase. #55

mattcookdev opened this issue Sep 7, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@mattcookdev
Copy link

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.

@driesvints
Copy link
Member

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 driesvints added the enhancement New feature or request label Sep 9, 2020
@mattcookdev
Copy link
Author

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!

@driesvints
Copy link
Member

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.

@alexmanase
Copy link
Contributor

@driesvints now that this PR (#154) is merged, I think you can close this issue.

@driesvints
Copy link
Member

Thanks @alexmanase!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants