Skip to content

[no-duplicate-hooks]: allow subsequent describe.each? #642

@kwonoj

Description

@kwonoj

Is there way to allow no-duplicate-hooks allow to work with describe.each, or is there recommended hook setup conforms those rules?

image

Interestingly, this doesn't error out for all describe.each but only if top-level describe includes subsequent nested describe.each.

repo: https://github.com/kwonoj/eslint-jest-duplicated-hooks

code:

describe('top', () => {
  describe.each(['approve', 'decline'])('inner1', () => {
		beforeEach(() => {
      console.log('set');
		});

		it('renders correctly', () => {
      expect(true).toBeTruthy();
		});
	});

	describe.each(['approve', 'decline'])('inner2', () => {
		beforeEach(() => {
			console.log('set2');
		});

		it('renders correctly 2', () => {
			expect(true).toBeTruthy
		});
	});
});

config:

module.exports = {
    "env": {
        "browser": true,
        "commonjs": true,
        "es2020": true,
        "jest/globals": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 11
    },
    "plugins": [
        "jest"
    ],
    "rules": {
        "jest/no-duplicate-hooks": "error"
    }
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions