google / google/closure-compiler
Rewrite method names (passed in as strings) to mocking functions (e.g., goog.testing.MockControl.prototype.createMethodMock)
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
At my place of work, we like to compile our JavaScript unit tests. Because advanced mode does not rewrite the methods named in strings, it is hard to leverage closure's mocking libraries. For example,
goog.testing.MockControl.prototype.createMethodMock
fails when the test is run compiled.
In the book "Closure: The Definitive Guide" it mentions a similar problem for the PropertyReplacer; it also mentions, "It would be possible to extend the Compiler so it rewrites calls to replace() and setPath() in a special way in Advanced mode, similar to how the Compiler must rewrite calls to goog.base()". (p. 478)
Is there any good way around these issues? Has the issue with the PropertyReplacer already been addressed? Right now we retrieving the renamed method names on a class by retrieving and filtering the keys on the class' prototype object.
Contributor guide
Assessment
This issue has not been assessed yet.