Skip to content
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

Merged
merged 2 commits into from
May 2, 2023

Conversation

vladyslav-baliuk
Copy link
Contributor

@vladyslav-baliuk vladyslav-baliuk commented Apr 28, 2023

Fixes incompatibility with chai-as-promised plugin and other minor improvements

@vladyslav-baliuk vladyslav-baliuk self-assigned this Apr 28, 2023
@vladyslav-baliuk vladyslav-baliuk marked this pull request as ready for review April 28, 2023 16:21
@vladyslav-baliuk vladyslav-baliuk changed the title fix(chai-retry-plugin): collision with chai-as-promised and other plugins fix(chai-retry-plugin): collision with chai-as-promised plugin Apr 28, 2023
@vladyslav-baliuk vladyslav-baliuk requested review from alisey and olehrakwix and removed request for yurii-ve May 2, 2023 07:31
@vladyslav-baliuk vladyslav-baliuk merged commit 8f4864b into master May 2, 2023
@vladyslav-baliuk vladyslav-baliuk deleted the vladyslav-b/retry_plugin_collision_fix branch May 2, 2023 09:34
Copy link
Contributor

@alisey alisey left a 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
Copy link
Contributor

@alisey alisey May 2, 2023

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;
Copy link
Contributor

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 {
Copy link
Contributor

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
Copy link
Contributor

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 () => {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants