-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Refactor plugin-manager.test.js
#11861
Refactor plugin-manager.test.js
#11861
Conversation
weird failed test. I tried to run in my local
|
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #11861 +/- ##
=======================================
Coverage 86.61% 86.61%
=======================================
Files 314 314
Lines 13181 13181
=======================================
Hits 11417 11417
Misses 1764 1764 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
@sleepwithcoffee great thanks for the effort, still let's not adjust the old tests like that.
If we're about to do any work of them, they should be refactored to runServerless
usage, See https://github.com/serverless/serverless/tree/main/test#unit-tests
hi @medikoo these are only meant to be syntactical changes, I do not intend to change the way they work (yet). |
Thanks @sleepwithcoffee. Let's not introduce such syntactical changes. They do not seem to add value, while there's extra maintenance cost added |
sure, maybe let me scope down this PR a bit. Some of them are still quite meaningful including highlighting async functions that we might have missed out earlier. |
@sleepwithcoffee you're doing great work here. What's important in case of old tests (those not configured with Best improvement would be to simply replace them with |
…ss it is one-liner return remove `sinon-chai`from this file
3a4a53d
to
49b37e0
Compare
reverted all minor syntax changes, focuses on 3 main points:
|
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.
@sleepwithcoffee Thanks for this input, still again, let's refrain from refactoring old tests.
As I mentioned I'll be happy to welcome PR that coverts them to runServerless
util.
Otherwise the only changes that are acceptable are those where e.g. we remove the dependency as blubird
}); | ||
|
||
await pluginManager.asyncPluginInit(); | ||
expect(plugin1.asyncInit.calledOnce).to.be.true; |
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.
Let's not introce such stylistic changes (to.equal(true)
into to.be.true
), it brings on extra value, while increases maintenance cost
const servicePlugins = ['ServicePluginMock3', 'ServicePluginMock1']; | ||
|
||
return expect(pluginManager.loadAllPlugins(servicePlugins)).to.be.rejectedWith( | ||
await expect(pluginManager.loadAllPlugins(servicePlugins)).to.eventually.be.rejectedWith( |
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.
If to.be.rejectedWith
works, let's keep it that way
}); | ||
// Happens when `plugins` property exists but is empty | ||
it('should not error if plugins = null', async () => | ||
expect(pluginManager.resolveServicePlugins(null)).to.eventually.be.fulfilled); |
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.
Let's not use be.fulfilled
(as we agreed in other PR, let's just await promise in such case)
@@ -852,23 +846,23 @@ describe('PluginManager', () => { | |||
}, | |||
}; | |||
expect(() => pluginManager.createCommandAlias('cmd1:alias2', 'mycmd')).to.throw( | |||
/Alias "cmd1:alias2" is already defined/ | |||
'Alias "cmd1:alias2" is already defined' |
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.
Lert's not introduce such stylistic changes (as mentioned before, those tests are scheduled to be removed, we should increase maintenance cost of them)
I am closing this PR |
Related issues: #8603 #7171
This is a follow up of PR #11853
Under this PR, I refactor
plugin-manager.test.js
to conform with several common code conventions.bind(this)
if arrow function is already sufficientto.eventually.be.rejectedWith
instead ofto.be.rejectedWith
, more verbose but screams out promiseto.eventually.be.fulfilled
instead ofto.not.be.rejected
await
over promises, unless it is a one-line return statement (best practice is always usingawait
within function brackets)