adhocracy3
adhocracy3 copied to clipboard
Frontend unit tests failing when used with blanket
If I run the frontend unit tests in the browser, many tests fail. If I run the exact same tests in exactly the same setup, but without blanket, everything works fine. This is not related to #1683 or #1684.
The errors look something like this:
RangeError: Maximum call stack size exceeded
at ResourceWidget.CommentCreate.createDirective (<anonymous>:720:52)
at ResourceWidget.CommentCreate.createDirective (<anonymous>:722:50)
at ResourceWidget.CommentCreate.createDirective (<anonymous>:722:50)
at ResourceWidget.CommentCreate.createDirective (<anonymous>:722:50)
at ResourceWidget.CommentCreate.createDirective (<anonymous>:722:50)
at ResourceWidget.CommentCreate.createDirective (<anonymous>:722:50)
TL;DR: We should switch to istanbul.
I found the issue:
In order to track code coverage, blanket fetches the code, manipulates it, and then executes the manipulated code. If branch tracking is enabled, the following conversion will happen (simplified):
var x = false ? 1 : (fn(), 2);
var x = trackBranch(false) ? 1 : fn(), 2;
Note that the parantheses are missing in the second line. This bug manifests in the __extends
function, which typescript uses for inheritance. The effect is that subclasses change the superclass instead of inheriting from it.
When I went to create an issue at the blanket repo, I found that the project is not actively maintained. istanbul is mentioned as an alternative.
Istanbul seems to have a very different approach and is probably hard to integrate into the browser. It might work well with jasmine-node though.