testing-library / pptr-testing-library

puppeteer + dom-testing-library = 💖
MIT License
287 stars 29 forks source link

feat: export configure function with data-testid override #39

Closed silviuaavram closed 4 years ago

silviuaavram commented 4 years ago

Closes https://github.com/testing-library/pptr-testing-library/issues/32.

Replaces all occurrences of testIdAttribute: 'data-testid' with testIdAttribute: '<custom-attribute-name>' in the imported stringified dom-testing-library. Also keeps the original string just in case we need to perform subsequent changes.

Adds 2 unit tests to cover the changes.

Adds a new type that accepts only the supported parameter from configure.

export interface IConfigureOptions {
  testIdAttribute: string;
}
silviuaavram commented 4 years ago

Thank you for the review @patrickhulce and for getting back so soon, I will address the comments! I was not sure about the solutions so I wanted to create a PoC for it. All the suggestion make sense, thanks! Will ping you once I finish the improvements.

silviuaavram commented 4 years ago

@patrickhulce it's done, let me know what you think. It's not ideal, as string replacing in this case is fragile, but it's how we can get it done with minimal changes + we are covered by unit tests, just in case we update dom testing library and there are changes to the strings we replace.

patrickhulce commented 4 years ago

SG @silviuaavram this looks great to me if you could just cleanup the lint errors! yarn test:lint --fix should cleanup some of them and look to my previous suggestions for how to fix the rest

silviuaavram commented 4 years ago

This is cool, thank you so much for the feedback! Looking forward to seeing it released and used!

patrickhulce commented 4 years ago

published in 0.6.2 :)