Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/unit/test_is_test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
23 changes: 23 additions & 0 deletions utils/files/is_test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down