diff --git a/tests/unit/test_is_test_file.py b/tests/unit/test_is_test_file.py index ac2a7c9f4..4a542f48e 100644 --- a/tests/unit/test_is_test_file.py +++ b/tests/unit/test_is_test_file.py @@ -18,6 +18,42 @@ ("ApiMock.java", True), ("ApiMocks.java", True), (".github/workflows/ci.yml", True), + # Snapshot files + ("__snapshots__/Button.test.tsx.snap", True), + ("component.snap", True), + ("src/__snapshots__/Header.test.js.snap", True), + ("component.spec.snap", True), + ("component.test.snap", True), + # Fixtures + ("__fixtures__/user.json", True), + ("src/__fixtures__/data.json", True), + ("fixtures/sample_data.json", True), + ("tests/fixtures/user.json", True), + ("user.fixture.ts", True), + ("data.fixture.js", True), + # Test config files + ("jest.config.js", True), + ("jest.config.ts", True), + ("vitest.config.ts", True), + ("vitest.config.js", True), + ("karma.conf.js", True), + # Test helpers + ("setupTests.js", True), + ("setupTests.ts", True), + ("testSetup.ts", True), + ("src/testSetup.ts", True), + ("test-setup.js", True), + ("test_setup.py", True), + ("test-utils/helpers.js", True), + ("src/test-utils/api.ts", True), + ("test_helpers/utils.py", True), + ("test_utils/database.py", True), + # Storybook + ("Button.stories.tsx", True), + ("Header.stories.js", True), + ("stories/Header.tsx", True), + ("src/stories/Button.tsx", True), + # Should NOT be test files ("README.md", False), ("main.py", False), ("utils/file.py", False), diff --git a/utils/files/is_test_file.py b/utils/files/is_test_file.py index 274984657..832a74b66 100644 --- a/utils/files/is_test_file.py +++ b/utils/files/is_test_file.py @@ -41,6 +41,29 @@ def is_test_file(filename: str) -> bool: r"\.mock\.", # api.mock.ts, database.mock.js r"mock\.", # ApiMock.java, DatabaseMock.cs r"mocks\.", # ApiMocks.java, DatabaseMocks.cs + # Snapshot files (Jest, Vitest, etc.) + r"/__snapshots__/", # __snapshots__/Button.test.tsx.snap + r"\.snap$", # any .snap file + # Test fixtures and data + r"(^|/)__fixtures__/", # __fixtures__/user.json + r"(^|/)fixtures/", # fixtures/sample_data.json + r"\.fixture\.", # user.fixture.ts + # Test configuration files + r"jest\.config\.", # jest.config.js, jest.config.ts + r"vitest\.config\.", # vitest.config.js + r"karma\.conf\.", # karma.conf.js + r"\.spec\.snap$", # component.spec.snap + r"\.test\.snap$", # component.test.snap + # Test helpers and utilities + r"(^|/)test[-_]utils?/", # test-utils/, test_utils/ + r"(^|/)test[-_]helpers?/", # test-helpers/, test_helper/ + r"(^|/)setuptests\.", # setupTests.js, setupTests.ts + r"(^|/)testsetup\.", # testSetup.js, testSetup.ts + r"^testsetup\.", # testSetup.js at root + r"(^|/)test[-_]setup\.", # test-setup.js, test_setup.py + # Storybook files (visual testing) + r"\.stories\.", # Button.stories.tsx + r"(^|/)stories/", # stories/Button.tsx # Common test file names r"^test\.", # test.js, test.py r"^spec\.", # spec.rb, spec.js