Warnings API for deprecated features#918
Conversation
There was a problem hiding this comment.
the console.warn call needs to be abstracted. Otherwise you'll need to check for it every time you trigger a warning.
Also, the messages could be stored on a dictionary object, easier to keep.
There was a problem hiding this comment.
I tried to implement this idea in aee09a2, what do you think?
|
We should focus initially on the warning abstracted implementation and then on the places we should have it. The implementation should consider:
In the mean time, I should provide a complete list containing all the deprecated parts, including:
Needs discussion or implementation:
I need to check if anything is missing but this list is at least closer to reflect all the pre-2.0 deprecations. |
|
Sorry about delay |
There was a problem hiding this comment.
you may blend this warningMessage to the if statement above. It cost less to check for it before at first too.
|
I agree with you that's not abstract. But in the case of the Like: new Test({
warning: warningMessage,So the best approach is: var warning = QUnit.warning.deprecated.test;
QUnit.warning( "test" ); // or "qunit-test"Or: In addition to print, return the message var warning = QUnit.warning( "test" ); |
There was a problem hiding this comment.
We may avoid the new warning variable calling the function directly with it, less use of memory.
Also: I still believe it's better to map the messages as string keys, the point is that we may want to trigger only once for each warning. If you find another way to solve this (the single trigger) you don't need to worry on the key map.
|
Ouch! some bugs found on legacy browsers. https://travis-ci.org/jquery/qunit/builds/106548000 The Warning API is getting great, we're close to move this forward. |
|
@leobalter can you check out the latest changes? |
|
I need two udpates:
Extra (probably for an extra PR in the future): you may try using QUnit.stack to mention where the first of each kind of deprecation has happened. |
0de40ca to
2d6e227
Compare
|
Updated @leobalter |
|
We are close. Now we need to disable the warnings on the regular runs. Maybe a The other improvements might come after these changes, potentially on another PR. |
| } | ||
| } | ||
|
|
||
| QUnit.warning( "testDone-duration" ); |
There was a problem hiding this comment.
Warnings shouldn't be generated when there's nothing the user can do about it. I'd like to see this appear only in a getter for duration where Object.defineProperty exists.
|
@leobalter about the tests for QUnit.warning, do you think it's better to create a separate file ( |
|
yes. I wanna make sure we trigger warnings only on isolated cases. This will help us to update the main tests before the next major release. |
| }); | ||
|
|
||
| require( [ "qunit", "./amd" ], function( QUnit, tests ) { | ||
| QUnit.warning.off(); |
There was a problem hiding this comment.
these specific tests should not worry about triggering it off. That should occur only for the main test or anything else that are still covering deprecated API.
|
@leobalter see the lastest updates. Chek if this tests make sense to you? |
ea7a6a0 to
2191cfc
Compare
| return QUnit[ key ].apply( this, arguments ); | ||
| }; | ||
| } | ||
|
|
|
@leobalter check last changes :) |
|
there's still some pending comments above, like: #918 (comment) |
| times = {}; | ||
|
|
||
| ( function() { | ||
| (function() { |
There was a problem hiding this comment.
Undo? Seems like an accidental change.
|
Overall this seems okay to me, just a few minor comments |
|
Sorry for letting this sit for so long. @leobalter is this still desirable/needed? I wasn't super involved here, so I'm unsure what the entire goal of the API was. I'd be fine to just use a simple warning as well for things like #986. |
|
Makes more sense for now. Looking at this seems the warnings API is overkill at this point. @raphamorim I'm closing this for now, thanks for the hard work and I'm sorry to not help with it so much. |
|
No problemo :) |
Ref: #881
Please don't merge this PR yet
I will finalize the PR if you have no problems with this implementation.
done()return all warnings.startstopreset(this might need an extra discussion before removal, but it's deprecated)asyncTesttest()pushinitmodule()