Open joshuatz opened 4 years ago
I'd vote for both. The end-to-end test w/ playwright could test whether the LI APIs break with assertions like expect(resume.projects).not.toBeEmpty()
. A mocked API would be appropriate for testing the resume-forming logic against a known version of the API.
I'd be happy to set up mocked APIs for unit testing, and I'd be interested to see how end-to-end tests would work.
Coming back to this, I'm definitely less enthusiastic about the end-to-end browser test. There are just a lot of things that would make that really hard to set up:
.env
file (or wherever the token is stored for tests) would have to be updated constantly, or else tests will start failingplaywright
But, for API mocking, I think that would be great, and cover the parts of the tool most likely to break with code changes anyways. If you are going to work on them, I would suggest checking out my (WIP) notes on the unofficial API here.
re: end-to-end browser testing: I took another look through LI's TOS. Turns out they forbid any automated access, so browser testing's out.
re: API mocking: I'm going with jest
, mocking just the profileView
endpoint. To get functions into jest
without using rewire
, I've had to refactor to a module-based setup.
Yeah, re: TOS, that is why I choose to be very specific in my wording around this project (lol). To be fair, its intended use really is just for users to export their own data (that is why I built it, for my own personal JSON powered resume). I think going down the whole developer API route is not currently worth the trouble, and I'm good with just doing API mocking. I always do a "smoke test" for every release as well, where I sideload a fresh build and test it.
I'm good with jest
. And refactoring is fine (and probably appreciated; this was one of my earlier programming projects, and it kind of shows 😅).
With how often this is needing updates, it would be nice to establish some sort of test or simple check to verify the shape of the output.
This could be something like a real-life integration test with snapshot...
.env
file, extension runs viaplaywright
, JSON Resume output is collected and compared to snapshot... Or, to avoid needing a real LI profile and using real LI endpoints, could mock the LI API