I was wondering what are people doing in terms of unit testing their plugins? I am thinking of going down the jest route, but was wondering if Adobe had a recommendation in this area.
I’m not sure if we have an official Adobe suggestion (looping in @kerrishotts for that).
I can say that (as a plugin developer, before joining Adobe ), I experimented with several tech stacks for that.
While these were plugins for XD, the general stuff should stay the same for Photoshop (it’s only different host APIs you have to mock, of course).
For my Lorem Ipsum plugin, I used Jest for unit testing. Using Jest, as far as I remember, worked pretty well. Of course, it “only” covers unit testing, which depending on the type of plugin, might not be enough, but yeah: I’ve used it, and it works well. You can also look at the sources (since the plugin is open-source): GitHub - pklaschka/lorem-ipsum-plugin: A small plugin for Adobe XD to insert placeholder text.
If you, at some point, needed to do something like component/integration testing (I realize you’re asking about unit testing, but to make this answer a bit more “feature-complete” ), things get a little more interesting. For example, for my “Document Chat” plugin, I could get the Cypress React Component testing to work (I had to find a lot of workarounds, though). We published our pilot episode of “Creative Cloud Developer Conversations” yesterday, where I also talked specifically about using Cypress. If you’re interested, you can find that here: Creative Cloud Developer Conversations | Developing Document Chat (Pilot) - YouTube (Cypress stuff starts at around 27:00).
So, overall: Yes, Jest works fine. However, my opinion on this isn’t an “official Adobe recommendation”, though. Just a plugin developer’s thoughts on / positive experience with this .
Thanks @pklaschka for the info! I will definitely check out the video and your code.
You’re right, I would have eventually looked into more end to end testing and something like Cypress seems like a good solution. I have some experience with React Testing Library, but I’m not sure if that would transfer well over in the Photoshop context.
End-to-end testing is something that’s being worked on – @Sujai for more information, but it will mean you’ll be able to write e2e tests for your plugins and have them execute in the host app as part of your build process.
For unit tests, it’s really entirely up to you. Jest is often used internally (being often used in conjunction with React), but most unit testing libraries should work fine.
@Liz we just now released the ability to run tests using UDT CLI. Can you please take a look at: https://github.com/adobe-uxp/devtools-cli/releases/tag/v1.5.1
This repo is private right now.
@Jarda can you recheck now please.
Yes, it looks good now…
Thanks @Sujai! Will take a look.
Will there be any attention given to this CLI or has it been forgotten about? I mean it doesn’t even install, we had to do a pile of work arounds just to use some of the basic functionality.
Two questions:
- is the the best way to run the tests?
- wasn’t devtools-cli abandoned?