[pigment-css] Improve testing of fixtures#41389
Conversation
Netlify deploy previewhttps://deploy-preview-41389--material-ui.netlify.app/ Bundle size report |
1cc1377 to
a6df0ba
Compare
siriwatknp
left a comment
There was a problem hiding this comment.
@brijeshb42 I split the pigment.test.ts into features and create a testUtils.ts file to reuse the transformation logic. It lets me run a specific test with it.only and the applying a theme per test.
| const CUSTOM_ERROR = | ||
| 'The file contents have changed. Run "test:update" command to update the file if this is expected.'; | ||
|
|
||
| describe('Pigment CSS - styled', () => { |
There was a problem hiding this comment.
All the test files are repetitive in code. Only thing that is changing is the file path.
Creating new tests means copying the same content everytime. This was already solved in the previous implementation.
There was a problem hiding this comment.
Added a comment above that'll handle duplication while still keeping the tests independent.
There was a problem hiding this comment.
Creating new tests means copying the same content everytime. This was already solved in the previous implementation.
I'd argue this. The previous implementation does not let me use the test infra APIs like it.only() to run a specific test. Also, a specific theme for each test is not possible.
This made me think of The wrong abstraction. The agree that there are duplications but the tests should also be flexible to add/remove/alter as well.
cc @mnajdova for 3rd opinion.
Now, no need to manually create and write to files. If the output files don't exist, they'll be created with the expected content. If the contents itself change, use "test:update" command to automatically update the fixtures.
c7b35e5 to
540871b
Compare
Co-authored-by: siriwatknp <siriwatkunaporn@gmail.com>
Now, no need to manually create and write to files. If the output files don't exist, they'll be created with the expected content.
If the contents itself change, use "test:update"
command to automatically update the fixtures.