mirror of
https://github.com/jimeh/update-tags-action.git
synced 2026-02-18 17:26:38 +00:00
test: move tests and fixtures to top-level "tests" directory (#29)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -98,7 +98,7 @@ typings/
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
tests/runner/*
|
||||
|
||||
# IDE files
|
||||
.idea
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -7,8 +7,7 @@
|
||||
},
|
||||
"exclude": ["dist", "node_modules"],
|
||||
"include": [
|
||||
"__fixtures__",
|
||||
"__tests__",
|
||||
"tests",
|
||||
"src",
|
||||
"eslint.config.mjs",
|
||||
"jest.config.js",
|
||||
|
||||
@@ -6,6 +6,6 @@
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"exclude": ["__fixtures__", "__tests__", "coverage", "dist", "node_modules"],
|
||||
"exclude": ["tests", "coverage", "dist", "node_modules"],
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user