-
Notifications
You must be signed in to change notification settings - Fork 1
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(chai-retry-plugin): collision with chai-as-promised
plugin
#392
fix(chai-retry-plugin): collision with chai-as-promised
plugin
#392
Conversation
chai-as-promised
and other plugins chai-as-promised
plugin
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.
@olehrakwix see my comments.
@@ -4,8 +4,9 @@ import { retryFunctionAndAssertions } from './helpers'; | |||
import type { AssertionMethod, FunctionToRetry, AssertionStackItem, RetryOptions, PromiseLikeAssertion } from './types'; | |||
|
|||
/** | |||
* Plugin that allows to re-run function passed to `expect` with new `retry` method, retrying would be performed until | |||
* the result will pass the chained assertion or timeout exceeded or retries limit reached. | |||
* Plugin that allows to re-run function passed to `expect`, in order to achieve that use new `retry` method, retrying would be performed until |
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 don't understand this. The words don't connect into a sentence.
Change to:
This plugin allows to retry an assertion until it succeeds or a timeout is reached.
@@ -29,67 +30,71 @@ import type { AssertionMethod, FunctionToRetry, AssertionStackItem, RetryOptions | |||
* await expect(funcToRetry).retry().and.have.property('success').and.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.
Use a more realistic example:
await expect(() => document.title).retry({ timeout: 10_000 }).to.equal('hello');
const description = utils.flag(this, 'message') as string; | ||
export const chaiRetryPlugin = function (_: typeof Chai, { flag, inspect }: Chai.ChaiUtils) { | ||
Object.defineProperty(Chai.Assertion.prototype, 'retry', { | ||
value: function (retryOptions: RetryOptions = {}): PromiseLikeAssertion { |
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.
Extract this to a named function instead of increasing indentation even further.
import { chaiRetryPlugin } from '../chai-retry-plugin/chai-retry-plugin'; | ||
|
||
Chai.use(chaiRetryPlugin); | ||
// `chai-as-promised` should be used in order to test collision between plugins |
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.
"Should be used" or "is used"?
await expect(resultFunction).retry({ delay: 200 }).to.equal('Success'); | ||
}); | ||
|
||
it('should return value that was asserted successfully', async () => { |
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.
What do you mean by "asserted successfully"? There's no assertion here.
Fixes incompatibility with
chai-as-promised
plugin and other minor improvements