What's the recommended way to test my workflow?
Closed this issue · 10 comments
I can't find any test script in the linked packages.
Maybe calling alfy.debug()
to simulate the alfred environment?
I haven't really thought of that, but thanks for bringing it up. Workflow files are inherently singletons, so the safest and easiest would be to spawn the JS file with some test input and check the output. I can add a helper for that here and some docs.
Any thoughts? Do you need to test anything other than input/output?
The first thing came to my mind is to be able to mock the network (both success and failure).
Just a though, but wouldn't it be better if we separated the testing logic from the core in a alfy-test
or alfy/test
package?
I had issues with nock
and got
when trying to write tests (but I am also a JS newbie, so dont take me too serious here).
I think the main question here is, what we actually want to test. I managed to separate my code far enough from alfy to test it in isolation (executing a HTTP request and create the items) in https://github.com/spinscale/alfred-workflow-elastic-docs
What would be handy from my point of view, is a helper that tests the packaged workflow as a final integration test after the unit tests ran - but again, not sure if thats the intended scope here.
Just a though, but wouldn't it be better if we separated the testing logic from the core in a alfy-test or alfy/test package?
Yes, alfy/test
sounds good.
I just created alfy-test which will help you test your Alfy
workflows.
Wait untill alfy-test@0.2.0
is released (today or tomorrow), there is a breaking change coming up :).
@SamVerschueren We should add a tip or something here about using alfy-test
to test workflows.
Good point, thought I already did that.
Fixed by 46062ca.