Unit Testing with UXP Plugin

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.

2 Likes

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 :stuck_out_tongue_winking_eye: ), 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” :stuck_out_tongue_winking_eye: ), 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 :wink:.

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.

1 Like

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.

3 Likes

@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

@kerrishotts @pklaschka FYI

2 Likes

This repo is private right now.

1 Like

@Jarda can you recheck now please.

1 Like

Yes, it looks good now…

1 Like

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.