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

New rule proposal: Disallow calling of a known spy object created in the same spec #364

Open
KevinPartingtonTR opened this issue Mar 5, 2024 · 0 comments

Comments

@KevinPartingtonTR
Copy link

Is your feature request related to a problem? Please describe.

I'm seeing developers in my codebase do the following absolute nonsense:

describe('a suite', () => {
  it('a spec', () => {
    // arrange
    const objUnderTest = createObjectUnderTest();
    spyOn(objUnderTest, 'someMethod');

    // act
    objUnderTest.someMethod();

    // assert
    expect(objUnderTest.someMethod).toHaveBeenCalled();
  });
});

Describe the solution you'd like

I would like a rule which checks, within a spec, that an object/property pair that are passed to a spyOn call are not then called as a function within the same spec.

Describe alternatives you've considered

Firing my developers hasn't been an option, but I'm working on that...

I could create a custom rule pretty easily (and I probably will), but I wanted to suggest it for eslint-plugin-jasmine since it seems like a use case people would universally want to prevent.

Additional context

N/A

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

No branches or pull requests

1 participant