Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
#389 it.only/it.skip no longer triggers mocha-no-side-effect-code
Browse files Browse the repository at this point in the history
closes #389
  • Loading branch information
HamletDRC committed Apr 17, 2018
1 parent 2efd796 commit 696fb9d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/tests/MochaNoSideEffectCodeRuleTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@ describe('mochaNoSideEffectCodeRule', () : void => {
TestHelper.assertViolations(ruleName, script, [ ]);
});

it('should pass on usage of skip/only', () : void => {
const script : string = `
describe('someTest', (): void => {
it.skip((): void => {
});
describe.skip((): void => {
it.skip((): void => {
});
});
it.only((): void => {
});
describe.only((): void => {
it.only((): void => {
});
});
});
`;

TestHelper.assertViolations(ruleName, script, [ ]);
});

it('should pass on function declarations', () : void => {
const script : string = `
describe('someTest', (): void => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/MochaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export module MochaUtils {
*/
export function isLifecycleMethod(call: ts.CallExpression): boolean {
const functionName: string = AstUtils.getFunctionName(call);
const callText: string = call.expression.getText();
return functionName === 'it' || functionName === 'specify'
|| functionName === 'before' || functionName === 'beforeEach' || functionName === 'beforeAll'
|| functionName === 'after' || functionName === 'afterEach' || functionName === 'afterAll';
|| functionName === 'after' || functionName === 'afterEach' || functionName === 'afterAll'
|| callText === 'it.skip' || callText === 'it.only';
}
}

1 comment on commit 696fb9d

@astorije
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @HamletDRC, do you have any plans to release this anytime soon? :)
Thanks for your hard work!!

Please sign in to comment.