Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Add testing framework #13

Open
matt-fidd opened this issue Mar 1, 2022 · 8 comments
Open

Add testing framework #13

matt-fidd opened this issue Mar 1, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@matt-fidd
Copy link
Member

I think that we should start early in our approach to testing.

Adding a testing framework at this stage will prevent regression (albeit there's little to regress), make sure that the css builds as expected and that the builder class can handle erroneous data.

It will also allow us to build a github action that automatically runs tests against pull requests as an extra layer of certainty before approving and merging.

@matt-fidd matt-fidd added the enhancement New feature or request label Mar 1, 2022
@matt-fidd matt-fidd changed the title Add tests Add testing framework Mar 1, 2022
@rugulous
Copy link
Member

rugulous commented Mar 1, 2022

Yeah there's defo improvements that can be made (I've broken it several times) so not a bad shout!

@matt-fidd matt-fidd self-assigned this Mar 2, 2022
@matt-fidd
Copy link
Member Author

The tests I propose are

General

  • Sass sheet builds with no errors

Builder class

  • Can set self.vars
  • Retrieves vars correctly
  • Can build with no vars
  • Builds correctly with overwrites
  • Does something (need to look into an intended action) with erroneous data

@rugulous
Copy link
Member

rugulous commented Mar 2, 2022

@matt-fidd would agree.

Guess the erroneous data could be e.g. $default: #FFFFFFFFFFFFF (obviously wrong colour) or $error: null etc?

@matt-fidd
Copy link
Member Author

That was my thinking, what do reckon the intended action should be? If the value isn't something we expect we throw an error? Or just throw away that value?

And are we assuming that the only valid type is a 6 digit hex code with # at the start? I know there are a lot more options than that but how are we going to check for them?

@rugulous
Copy link
Member

rugulous commented Mar 2, 2022

Tbh I'm not too sure - should we validate here?

Just thinking that a colour can be in many formats (#FFF, #123456, #12345678, rgb(0,0,0), rgba(3,78,90,0.5), probably others ...) so it will be rather difficult to validate just these values.

Then there's validating if we pass other values e.g. font names, sizings, paddings, margins...

Perhaps this method allows any value to be passed, then when build is called and the SCSS compiler either builds or throws and error it can be properly picked up?

@matt-fidd
Copy link
Member Author

That makes most sense I think, I imagine sass will just throw an error itself if we do something stupid, we can always handle that error gracefully if we wanted or just let it bubble up.

@rugulous
Copy link
Member

rugulous commented Mar 2, 2022

Yep, build will throw an error like this if

  1. the variable contains something stupid
  2. we've messed up the actual scss files

image

So does seem like a good place to catch it!

@matt-fidd
Copy link
Member Author

Sorry, forgot about this issue.

In that case I propose that we keep the Builder as it is, and allow those errors to bubble up to the calling scope so that they can be handled there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants