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

Feature request: no-describe-context #177

Open
quiqueg opened this issue Jan 16, 2019 · 0 comments
Open

Feature request: no-describe-context #177

quiqueg opened this issue Jan 16, 2019 · 0 comments

Comments

@quiqueg
Copy link

quiqueg commented Jan 16, 2019

Do you want to request a feature or report a bug?
Feature

What is the current behavior?
The no-describe-variables rule prevents developers from creating variables inside describe blocks, instead encouraging them to make use of Jasmine's user context feature (this inside before*, it, and after*). However, developers may not know that the user context feature doesn't work inside describe blocks, so they may try to do something like this:

describe('my test', function () {
  this.incorrectUse = 'of UserContext';

  it('uses UserContext incorrectly', function () {
    // ...
  });
});

Not only is this incorrect, it is dangerous, as the context of describe blocks is the Jasmine Suite object itself. Setting a property on this object may interfere with Jasmine's internals (e.g., setting this.result will overwrite the test results, setting this.id changes the id of the suite, etc.).

What is the expected behavior?
An eslint-plugin-jasmine rule called no-describe-context should prevent this behavior. Detect and warn about usage of this directly inside describe blocks (probably only for un-bound / non-arrow functions).

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

No branches or pull requests

1 participant