diff --git a/.gitignore b/.gitignore index 4c2a407..5388b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -98,7 +98,7 @@ typings/ Thumbs.db # Ignore built ts files -__tests__/runner/* +tests/runner/* # IDE files .idea diff --git a/AGENTS.md b/AGENTS.md index 69e0270..1af6f8f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,7 +35,7 @@ npm run package # Build src/index.ts -> dist/index.js via Rollup npm run bundle # Alias: format + package # Run a single test file -NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest __tests__/main.test.ts +NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 npx jest tests/main.test.ts # CI variants (suppress warnings) npm run ci-test # Run tests in CI mode @@ -65,7 +65,7 @@ npm run package:watch # Auto-rebuild on changes - `processTag()`: Creates/updates individual tags based on `when_exists` mode - `resolveRefToSha()`: Converts git refs to commit SHAs (private helper) - **[action.yml](action.yml)**: GitHub Action metadata (inputs/outputs) -- **[\_\_fixtures\_\_/](__fixtures__)**: Mock implementations of @actions/core, +- **[tests/fixtures/](tests/fixtures)**: Mock implementations of @actions/core, @actions/github, and csv-parse for testing ### Tag Input Parsing @@ -97,12 +97,12 @@ jest.unstable_mockModule('@actions/core', () => core) const { run } = await import('../src/main.ts') ``` -Mock fixtures live in `__fixtures__/` (e.g., `core.ts` mocks @actions/core). +Mock fixtures live in `tests/fixtures/` (e.g., `core.ts` mocks @actions/core). ### Testing Best Practices - Consider edge cases as well as the main success path -- Tests live in `__tests__/` directory, fixtures in `__fixtures__/` +- Tests live in `tests/` directory, fixtures in `tests/fixtures/` - Run tests after any refactoring to ensure coverage requirements are met - Use `@actions/core` package for logging (not `console`) for GitHub Actions compatibility diff --git a/__fixtures__/core.ts b/tests/fixtures/core.ts similarity index 100% rename from __fixtures__/core.ts rename to tests/fixtures/core.ts diff --git a/__fixtures__/csv-parse.ts b/tests/fixtures/csv-parse.ts similarity index 100% rename from __fixtures__/csv-parse.ts rename to tests/fixtures/csv-parse.ts diff --git a/__fixtures__/github.ts b/tests/fixtures/github.ts similarity index 100% rename from __fixtures__/github.ts rename to tests/fixtures/github.ts diff --git a/__tests__/main.test.ts b/tests/main.test.ts similarity index 99% rename from __tests__/main.test.ts rename to tests/main.test.ts index 0a06294..d16090e 100644 --- a/__tests__/main.test.ts +++ b/tests/main.test.ts @@ -2,9 +2,9 @@ * Unit tests for the action's main functionality, src/main.ts */ import { jest } from '@jest/globals' -import * as core from '../__fixtures__/core.js' -import * as github from '../__fixtures__/github.js' -import * as csvParse from '../__fixtures__/csv-parse.js' +import * as core from './fixtures/core.js' +import * as github from './fixtures/github.js' +import * as csvParse from './fixtures/csv-parse.js' // Mocks should be declared before the module being tested is imported. jest.unstable_mockModule('@actions/core', () => core) diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 7a00c40..219fb6d 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -7,8 +7,7 @@ }, "exclude": ["dist", "node_modules"], "include": [ - "__fixtures__", - "__tests__", + "tests", "src", "eslint.config.mjs", "jest.config.js", diff --git a/tsconfig.json b/tsconfig.json index b65a760..ac52c83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,6 @@ "moduleResolution": "NodeNext", "outDir": "./dist" }, - "exclude": ["__fixtures__", "__tests__", "coverage", "dist", "node_modules"], + "exclude": ["tests", "coverage", "dist", "node_modules"], "include": ["src"] }