Reduce dependency count
See original GitHub issueDescribe the feature youβd like:
Reduce the number of dependencies installed when installing dom-testing-library
. The feature set of this package is fantastic for anyone writing tests against the DOM.
Being able to query against the DOM in the language of your users and using waitFor & other techniques to deal with asynchronous frameworks is really really nice.
Currently when I install this library I get
βββ¬ @testing-library/dom@7.5.2
β βββ¬ @babel/runtime@7.9.6
β β βββ regenerator-runtime@0.13.5
β βββ¬ aria-query@4.0.2
β β βββ @babel/runtime@7.9.6 deduped
β β βββ¬ @babel/runtime-corejs3@7.9.6
β β βββ core-js-pure@3.6.5
β β βββ regenerator-runtime@0.13.5 deduped
β βββ dom-accessibility-api@0.4.3
β βββ¬ pretty-format@26.0.1
β βββ¬ @jest/types@26.0.1
β β βββ @types/istanbul-lib-coverage@2.0.1
β β βββ¬ @types/istanbul-reports@1.1.1
β β β βββ @types/istanbul-lib-coverage@2.0.1 deduped
β β β βββ¬ @types/istanbul-lib-report@3.0.0
β β β βββ @types/istanbul-lib-coverage@2.0.1 deduped
β β βββ¬ @types/yargs@15.0.4
β β β βββ @types/yargs-parser@15.0.0
β β βββ¬ chalk@4.0.0
β β βββ ansi-styles@4.2.1 deduped
β β βββ¬ supports-color@7.1.0
β β βββ has-flag@4.0.0
β βββ ansi-regex@5.0.0
β βββ¬ ansi-styles@4.2.1
β β βββ @types/color-name@1.1.1
β β βββ¬ color-convert@2.0.1
β β βββ color-name@1.1.4 deduped
β βββ react-is@16.13.1
29 dependencies, from these it looks like only ( @testing-library/dom
; dom-accessibility-api
; aria-query
; pretty-format
; ansi-styles
; color-convert
; color-name
) are useful dependencies.
It would be great if installing this library only installed 3 dependencies and if it had 4 optional dependencies ( pretty-format
& ansi-*
make great optional dependencies )
Suggested implementation:
To reduce dependency count the following could be implemented
- Removing babel dependency
- Remove nested babel dependency from
aria-query
- Make
pretty-format
an optional dependencies - Remove
@jest/types
frompretty-format
or replacepretty-format
with a smaller library.
Describe alternatives youβve considered:
π€·
Teachability, Documentation, Adoption, Migration Strategy:
Having an optional dependency does require teaching users that pretty-format
can be installed to pretty print the errors and warnings generated by dom-testing-library
.
Your tests will work fine as is but might not be as pretty when looking at the output of a test failure without having installed pretty-format
An optional dependency looks like
let prettyFormat
try {
prettyFormat = require('pretty-format')
} catch (err) {
console.warn('If you would like a pretty error; please npm install pretty-format')
}
/* ... */
// In the library itself; wrap every usage of `prettyFormat` in a ternary or if statement
console.log(prettyFormat ? prettyFormat(x) : x)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Thanks for sharing your opinions @Raynos, but I think thereβs a values misalignment here so I donβt expect this to go anywhere. Sorry.
So we would need to maintain it rather than the folks over at
jest
? That doesnβt sound like a solution to me.I understand the general concern but I donβt agree with the extreme step to simply cut it. All of the listed dependencies (with the exception of
dom-accessibility-api
maybe) are maintained either by large orgs or long term OSS maintainers.The security risk they pose seems to be on the same level as using testing-library itself. It sounds like there is some subtext here Iβm not getting. Could you explain why
pretty-format
is such an issue for you?