JavaScript Unit Testing

Re: JavaScript Unit Testing

by Guy Thomas -
Number of replies: 0
Picture of Core developers Picture of Plugin developers

Great exploratory work Andrew! Has anyone revisited the possibility of JS unit testing since Moodle moved over to AMD?

I'd love to get code coverage for javascript in one way or another - I was thinking an alternative might be to hook something into Behat. Let me stress, that Behat purists would definitely not be cool with that but I think Moodle uses Behat more for acceptance testing than BDD anyway, so not an issue to further misuse Behat IMO.

I've been playing with http://blanketjs.org/

I had the idea of hooking it into behat so that it would provide a report on JS code coverage at the end of the test.

I know that this isn't unit testing as such but still nice to know if your acceptance tests are passing and all your JS is being hit by the test.

Would get round all the issues mentioned in the post about AJAX / strings, etc..