New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix EZP-21671: add tests for Promise part of the CAPI #25
Conversation
@@ -121,10 +121,15 @@ module.exports = function(grunt) { | |||
grunt.loadNpmTasks('grunt-contrib-yuidoc'); | |||
grunt.loadNpmTasks('grunt-shell'); | |||
|
|||
// Helper task required to provide the "q" library to instrumented version of the "PromiseService" module | |||
grunt.registerTask('prepareQ', 'Copy q library into instrument folder', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is more a workaround than a real solution and actually this happens because Q is loaded with a relative path to node_modules which is considered as a bad practice. So instead of this, you should try to get rid of the relative path to load Q. (normally npm packages are loaded automatically by requirejs/r.js but I guess the baseUrl being set to src breaks this somehow)
Well, I didn't find a way to load "q" properly and without much hassle yet. 2 alternatives to achieve "best practice":
I've managed to replace copying hack by usage of the |
Another solution might be to install Q in |
Do you mean actual installing via npm? |
I was more thinking of putting a package.json file in those folders with the Q dependency. Maybe @jakobwesthoff you can give your pov or an alternative as none of those solutions seems really perfect. |
expect(promiseCAPI.andSomethingElse).not.toBeDefined(); | ||
}); | ||
|
||
it("is calling generated promise versions of services correctly (and they are singletons)", function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this up into two tests. As ensuring the services are correctly called is a different requirement, then them being singletons :)
Regarding the problem of loading QLoading the Q library is indeed a problem. First of all it needs to be decided if Q should be bundled with the CAPI or not. I tend to not bundle it, but simply require it as a dependency if the PromiseCAPI is used. Furthermore I tend to distribute/create two versions of the CAPI. One including the Promise wrappers and therefore having a dependency on Q, one without the Promise wrappers, without any external dependency. This would solve the problem regarding the distribution of Q. The second problem is the need for Q during the execution of tests. Unfortunately there is no really nice way of solving this problem. The currently utilized solution is quite acceptable in my opinion. However I would use paths: {
"q": "../node_modules/q/q"
} The corresponding documentation can be found here. Another solution the grunt-contrib-symlink plugin to symlink Q from the |
big +1 on having separate builds of the promise and non promise version. For Q not being included, I tend to agree as well even if I don't have a strong opinion on this. |
The reason for not including Q (even int the promise build) was to give the user of the library the highest possible flexibility regarding choice of the used package management (requirejs, manual download, commonjs, ...). As we are able to provide this flexibility to the user by utilizing requirejs, I don't see a real reason for taking part of this away by bundling Q statically. Nevertheless it is not a must have :) |
Jakob, thanks for additional remarks. I'll fix them right away. @dpobel, ok with you if I'll fix the test issues here, merge them, and then implement separate builds in a new branch? |
of course in a separate branch |
Silencing q false positive warning on rejection handling, CS cookbook fixes
dealing with q
dealing with q
Branch rebased. Fixes according to Jackob's hints (except custom matcher for error handling)
Custom matcher for error handling.
Fixed. |
fixing case in filename
seems OK to me. Just make sure |
JIRA issue: https://jira.ez.no/browse/EZP-21671
Done.