Choice of Language and Framework for Unit Tests on HUD

39 views
Skip to first unread message

Najam Ul Saqib

unread,
Sep 25, 2023, 9:45:47 AM9/25/23
to ZAP Developer Group
Hi,

By working on HUD these days, I see that primarily Java is being used for unit tests on HUD (which inherently is a JS project) so I was thinking if it would be fine if I grow the unit tests using Javascript? It would be much easier for me to do so since I am more comfortable with JS.

If yes, currently we're using ava when we have much more established frameworks like mocha and chai; should I move our current unit tests to one of the frameworks which we decide mutually?

Also, JS vs TS can also be debated upon.

Discussing it with thc202 in IRC; he suggested that moving to JS can be concerning for other devs since most of you here are using Java.

Let me know your thoughts on this.

psiinon

unread,
Sep 25, 2023, 10:05:21 AM9/25/23
to ZAP Developer Group
FWIW the Browser Extension https://github.com/zaproxy/browser-extension uses jest for testing.
Keeping these 2 projects fairly compatible would be a very good thing IMO.

If enough HUD integration tests are written in JS/TS then I'd be happy for those to replace the Java integration tests.

The Browser Extension is also written in Type Script, which I personally think is a more robust language for these sort of projects ;)
However the HUD works in very different way - we inject JS directly into the target application.
We can also currently change the HUD JS code in ZAP and see changes immediatelly reflected in the HUD.
I like that feature, but I also have not been able to spend much time on HUD development :)

Other points of view gratefully received, especially from people who might contribute to HUD development!

Cheers,

Simon

Najam Ul Saqib

unread,
Sep 26, 2023, 3:03:55 AM9/26/23
to ZAP Developer Group

Alright, so should we consider Jest for HUD?

We can begin with writing unit tests in TS and then slowly make the transition.

If there are more suggestions, I am up for it so please mention it beforehand, it will be tough to change the approach once the work has started.

psiinon

unread,
Sep 26, 2023, 3:52:15 AM9/26/23
to ZAP Developer Group
I think thats a good approach.

Thoughts from anyone else?

Cheers,

Simon

Najam Ul Saqib

unread,
Sep 26, 2023, 4:33:19 AM9/26/23
to ZAP Developer Group

We should also consider moving to modules from ES6; currently we're using commonJS in HUD.

psiinon

unread,
Sep 26, 2023, 4:58:12 AM9/26/23
to ZAP Developer Group
In general I'm all for using the latest, greatest options :)
But what are the full implications of such a move?

Cheers,

Simon

Najam Ul Saqib

unread,
Sep 26, 2023, 4:59:48 AM9/26/23
to ZAP Developer Group
To be honest, I am not aware of the implications; the migration is simple but since the JS code is being used by ZAP so it can break the app.

psiinon

unread,
Sep 26, 2023, 5:03:22 AM9/26/23
to ZAP Developer Group
Try it and see then :D

Najam Ul Saqib

unread,
Sep 26, 2023, 6:02:01 AM9/26/23
to ZAP Developer Group
will do so once we have other more important tasks done like unit test fixes, jest migration, etc.

psiinon

unread,
Sep 26, 2023, 6:07:48 AM9/26/23
to ZAP Developer Group
That makes sense.
Reply all
Reply to author
Forward
0 new messages