Skip to content

Make @testing-library/dom a peer dependency instead #122

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

Closed
zikaari opened this issue Jul 8, 2020 · 13 comments · Fixed by #125
Closed

Make @testing-library/dom a peer dependency instead #122

zikaari opened this issue Jul 8, 2020 · 13 comments · Fixed by #125
Labels

Comments

@zikaari
Copy link

zikaari commented Jul 8, 2020

@testing-library/angular provides queries straight from @testing-library/dom except that it's always a locked version. Meaning that one cannot receive any bug fixes and enhancements related to queries without also updating both @testing-library/angular and @angular/core itself.

People who are on Angular 8, for example cannot have these critical fixes without upgrading to Angular 9 at the very least (which isn't always an option):

Making @testing-library/dom a peer dep will give people a lot of wiggle room to what can be achieved as they see fit as opposed to being locked down.

@zikaari zikaari changed the title Make @testing-library/dom a peer dependency instead. Make @testing-library/dom a peer dependency instead Jul 8, 2020
@timdeschryver
Copy link
Member

I'm hesitant to do this, because consumers will have to install both packages.
You do make a good point tho.

What about the following options:

  • What about making Angular a peer dependency
  • We could release a new version with the latest DOM package and Angular 8

@timdeschryver
Copy link
Member

The other packages use a peer dependency to the framework, so I guess we should do that.

@zikaari
Copy link
Author

zikaari commented Jul 10, 2020

The other packages use a peer dependency to the framework

Unless this package relies on specific angular API's (like ngZone for example), which might not be always interoperable across different versions which will force this package to only work with limited versions of angular at a time. Although we can write an adaptor for the API's required by this package which can interoperate calls across versions. This way any version of this library can support any version of angular (within reason of course)

@zikaari
Copy link
Author

zikaari commented Jul 10, 2020

We could release a new version with the latest DOM package and Angular 8

And this doesn't scale up very well. I mean how far can one stretch things like this.

@timdeschryver
Copy link
Member

Oh we're already having Angular as a peer dependency 😅.

And this doesn't scale up very well. I mean how far can one stretch things like this.

Correct, this would only be done for the previous version of Angular and when the change has a big impact.

I think you should be able to run ATL v10 with Angular 9.
Have you tried it?

@zikaari
Copy link
Author

zikaari commented Jul 10, 2020

Oh we're already having Angular as a peer dependency

... which will force this package to only work with limited versions of angular at a time

I think you should be able to run ATL v10 with Angular 9

We're on Angular 8 with no immediate plans to upgrade.

@timdeschryver
Copy link
Member

But have you tried using this package latest version with Angular 8?

@timdeschryver
Copy link
Member

AFAIK, version 10 of this package should be compatible with earlier versions of Angular.
Is it the recommended way? No, but should work.

@zikaari
Copy link
Author

zikaari commented Jul 23, 2020

No mate it doesn't work:

image

TypeError: testing.TestBed.inject is not a function

      at Object.<anonymous> (projects/testing-library/src/lib/testing-library.ts:124:33)
      at step (node_modules/tslib/tslib.es6.js:100:23)
      at Object.next (node_modules/tslib/tslib.es6.js:81:53)
      at fulfilled (node_modules/@testing-library/angular/bundles/testing-library-angular.umd.js:329:32)
      at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:391:26)
      at ProxyZoneSpec.onInvoke (node_modules/zone.js/dist/proxy.js:129:39)
      at ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:390:52)
      at Zone.run (node_modules/zone.js/dist/zone.js:150:43)
      at node_modules/zone.js/dist/zone.js:910:34
      at ZoneDelegate.invokeTask (node_modules/zone.js/dist/zone.js:423:31)
      at ProxyZoneSpec.onInvokeTask (node_modules/zone.js/dist/proxy.js:160:39)
      at ZoneDelegate.invokeTask (node_modules/zone.js/dist/zone.js:422:60)
      at Zone.runTask (node_modules/zone.js/dist/zone.js:195:47)
      at drainMicroTaskQueue (node_modules/zone.js/dist/zone.js:601:35)

@timdeschryver
Copy link
Member

🎉 This issue has been resolved in version 10.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@timdeschryver
Copy link
Member

timdeschryver commented Jul 27, 2020

@NeekSandhu that problem should be resolved in v10.0.1, if that's the only problem I don't want to add dom as a peer depedency.

@zikaari
Copy link
Author

zikaari commented Jul 27, 2020

@timdeschryver works great! however, there are some peer dep warnings that can be addressed because it's now functional with angular 8 as well:

warning " > @testing-library/angular@10.0.1" has incorrect peer dependency "@angular/common@^10.0.0".
warning " > @testing-library/angular@10.0.1" has incorrect peer dependency "@angular/platform-browser@^10.0.0".
warning " > @testing-library/angular@10.0.1" has incorrect peer dependency "@angular/animations@^10.0.0".
warning " > @testing-library/angular@10.0.1" has incorrect peer dependency "@angular/router@^10.0.0".
warning " > @testing-library/angular@10.0.1" has incorrect peer dependency "@angular/core@^10.0.0".

@timdeschryver
Copy link
Member

I would like to keep it this way.
It's supported to be used in earlier versions, but it isn't recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants