Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is another follow-up of #2445.
The proposal suggests to introduce a unit testing framework for Javascript code in ILIAS.
I had a look Jasmine, Mocha and Jest. This PR goes with Mocha.
js-unit-test.md
Jasmine, Mocha and Jest are the three most popular unit testing frameworks I found. Jest is the most popular one, originally based on Jasmine (which is the oldest one), but improving things like performance and adding features like snapshots, see [1].
I started with Jest. One of the features I was looking for was ES6 module support. Unfortunately this is not fully implemented in Jest, see [2] and [3]. So I gave Mocha a try and was quickly able so setup a simple example.
Mocha's architecture is modular and adds assertion or mock/spy features through additional libraries like Chai or Sinon. So the main reasons to suggest Mocha were ES6 module support, flexibility and popularity.
However this choice is open for discussion. Also which other aspects must be covered in a first basic version of such a guideline.
Please add your comments and thoughts in the PR. You are also invited to join the ILIAS Offline Group [4].
[1] https://medium.com/welldone-software/an-overview-of-javascript-testing-7ce7298b9870
[2] jestjs/jest#4842
[3] jestjs/jest#9430
[4] https://docu.ilias.de/goto_docu_grp_8190.html