chartjs/chartjs-test-utils

Change karma and jasmine to peer deps?

snoozbuster opened this issue · 2 comments

I found this package while looking at how the main chartjs repo does their testing, because I wanted to see if I could integrate canvas testing into a project at my org. The fact that all the hairy fuzzy matching logic is part of a package was great, but I was bummed to find that it depended on karma and jasmine. Reading through the code, it looks like there is a single dependency on jasmine and a single dependency on karma, both of which are environment-based rather than explicit imports. We don't use karma or jasmine in this project (specifically, I was hoping to adapt the matchers to cypress, whose assertion library is based on mocha) but it seems like a shame to install these dependencies just for these two references. The jasmine one can be easily removed by changing the signature to something like function addMatchers(jasmine) - karma.__files__ I am less sure about (I couldn't even find documentation on this magic string) but if I don't use addMatchers or specsFromFixtures, these dependencies are totally unused.

Would it be possible to open a PR to change jasmine and karma to be peer deps instead of hard dependencies? Ideally, I would love the utils to be exported in a framework-agnostic way, and have separate layers on top for karma/jasmine and cypress/mocha (or jest/node-canvas, or whatever) but that's a much larger change and in the meantime I can write my own conversion utility to convert the matchers from jasmine -> mocha so that's not particularly a blocker. Mostly just wanted to open this and get some eyes on it to make sure I wouldn't open a PR that no one will ever look at.

I don't think changing those to peer deps would cause any problems in packages using this. I suppose all have karma and jasmine as local dependency anyway. So my opinion is yes, that would probably be a good idea.

Some initial thoughts: It would be good to have the framework specific things available as separate/sub packages for others to use. So if someone has a project utilizing jest and chart.js and would like to use these utils, there would be community drive package for that.

yes, I would love that too - but I don't have the time to do it myself. I'll see if I can open a PR this evening to change the dependencies to peer deps!