|
| 1 | +# Contributing to vitest-environment-prisma-postgres |
| 2 | + |
| 3 | +## 🙏 Thank You |
| 4 | + |
| 5 | +Thank you for considering contributing to vitest-environment-prisma-postgres! Whether you're fixing a typo, reporting a bug, or proposing a new feature, your contribution helps make database testing faster and easier for the entire Vitest and Prisma community. This is a small project maintained in limited time, and every contribution is genuinely appreciated. |
| 6 | + |
| 7 | +## 💡 How You Can Contribute |
| 8 | + |
| 9 | +Contributions come in many forms, and all of them are valued: |
| 10 | + |
| 11 | +- **Report bugs** and suggest improvements |
| 12 | +- **Improve documentation** (README, code comments, examples) |
| 13 | +- **Answer questions** in GitHub issues |
| 14 | +- **Review pull requests** from other contributors |
| 15 | +- **Share your experience** using the library with the community |
| 16 | + |
| 17 | +You don't need to write code to make a meaningful impact! |
| 18 | + |
| 19 | +## 🐛 Reporting Issues |
| 20 | + |
| 21 | +Before creating a new issue, please: |
| 22 | + |
| 23 | +1. **Search existing issues** (including closed ones) to avoid duplicates |
| 24 | +2. **Check the [README](./README.md)** to ensure you've followed the setup correctly |
| 25 | + |
| 26 | +When reporting a bug, please include: |
| 27 | + |
| 28 | +- A **clear description** of the problem |
| 29 | +- **Steps to reproduce** the issue with a minimal example |
| 30 | +- **Expected behavior** vs. **actual behavior** |
| 31 | +- **Version information**: |
| 32 | + - Node.js version (`node --version`) |
| 33 | + - Package version |
| 34 | + - Vitest version |
| 35 | + - Prisma version |
| 36 | + - PostgreSQL version |
| 37 | +- **Error messages** or stack traces if applicable |
| 38 | + |
| 39 | +The more details you provide, the easier it is to understand and fix the issue. |
| 40 | + |
| 41 | +## 💻 Development Setup |
| 42 | + |
| 43 | +### Prerequisites |
| 44 | + |
| 45 | +- **Node.js** >= 24.0.0 |
| 46 | +- **pnpm** 9.12.3 or higher (this project uses pnpm, not npm or yarn) |
| 47 | + |
| 48 | +### Installation |
| 49 | + |
| 50 | +1. **Fork the repository** on GitHub |
| 51 | + |
| 52 | +2. **Clone your fork** locally: |
| 53 | + ```bash |
| 54 | + git clone https://github.com/YOUR_USERNAME/vitest-environment-prisma-postgres.git |
| 55 | + cd vitest-environment-prisma-postgres |
| 56 | + ``` |
| 57 | + |
| 58 | +3. **Install dependencies**: |
| 59 | + ```bash |
| 60 | + pnpm install |
| 61 | + ``` |
| 62 | + |
| 63 | +### Running Tests |
| 64 | + |
| 65 | +```bash |
| 66 | +pnpm test # Run all tests with coverage |
| 67 | +pnpm test -- --watch # Run tests in watch mode |
| 68 | +``` |
| 69 | + |
| 70 | +All tests must pass before submitting a pull request. |
| 71 | + |
| 72 | +### Code Quality Checks |
| 73 | + |
| 74 | +This project uses [Biome](https://biomejs.dev/) for linting and formatting: |
| 75 | + |
| 76 | +```bash |
| 77 | +pnpm run lint # Check for linting issues |
| 78 | +pnpm run format:check # Check code formatting |
| 79 | +pnpm run format # Auto-format code |
| 80 | +pnpm run typecheck # Run TypeScript type checking |
| 81 | +``` |
| 82 | + |
| 83 | +All checks must pass before submitting a pull request. |
| 84 | + |
| 85 | +### Building |
| 86 | + |
| 87 | +```bash |
| 88 | +pnpm run build # Build the package |
| 89 | +``` |
| 90 | + |
| 91 | +The build output will be in the `dist/` directory. |
| 92 | + |
| 93 | +## ✨ Submitting Changes |
| 94 | + |
| 95 | +### Before You Start |
| 96 | + |
| 97 | +For **non-trivial changes** (new features, significant refactoring, architectural changes), please **open an issue first** to discuss your proposed changes. This helps: |
| 98 | + |
| 99 | +- Avoid duplicate work |
| 100 | +- Ensure the change aligns with the project's goals and scope |
| 101 | +- Get early feedback on your approach |
| 102 | +- Save your time if the change isn't a good fit |
| 103 | + |
| 104 | +For **small fixes** (typos, small bug fixes, documentation improvements), feel free to submit a pull request directly. |
| 105 | + |
| 106 | +### Creating a Pull Request |
| 107 | + |
| 108 | +1. **Create a feature branch** from `main`: |
| 109 | + ```bash |
| 110 | + git checkout -b feat/your-feature-name |
| 111 | + # or |
| 112 | + git checkout -b fix/your-bug-fix |
| 113 | + ``` |
| 114 | + |
| 115 | +2. **Make your changes**: |
| 116 | + - Write or update tests for your changes |
| 117 | + - Ensure all tests pass: `pnpm test` |
| 118 | + - Run code quality checks: `pnpm run lint && pnpm run format:check && pnpm run typecheck` |
| 119 | + - Update documentation if needed (README, code comments, etc.) |
| 120 | + |
| 121 | +3. **Commit your changes** following our [commit message guidelines](#📝-commit-message-guidelines) |
| 122 | + |
| 123 | +4. **Push to your fork**: |
| 124 | + ```bash |
| 125 | + git push origin feat/your-feature-name |
| 126 | + ``` |
| 127 | + |
| 128 | +5. **Create a pull request** on GitHub with a descriptive title and description |
| 129 | + |
| 130 | +6. **In your PR description**, include: |
| 131 | + - **What problem you're solving** or what feature you're adding |
| 132 | + - **How you solved it** (your approach) |
| 133 | + - **References to related issues** (e.g., "Fixes #123" or "Closes #456") |
| 134 | + - **Breaking changes** if any (and migration instructions) |
| 135 | + - **Screenshots or examples** if applicable |
| 136 | + |
| 137 | +7. **Enable the checkbox** to allow maintainer edits so we can make minor adjustments if needed |
| 138 | + |
| 139 | +### PR Review Process |
| 140 | + |
| 141 | +- PRs are typically reviewed within a few days |
| 142 | +- You may be asked to make changes - please respond to feedback constructively |
| 143 | +- Once approved, your PR will be merged using "Squash and Merge" |
| 144 | +- Your contribution will be included in the next release with automated changelog generation |
| 145 | + |
| 146 | +## 📝 Commit Message Guidelines |
| 147 | + |
| 148 | +This project uses [Conventional Commits](https://www.conventionalcommits.org/) for automated changelog generation and semantic versioning. |
| 149 | + |
| 150 | +### Format |
| 151 | + |
| 152 | +``` |
| 153 | +<type>: <description> |
| 154 | +``` |
| 155 | + |
| 156 | +### Types |
| 157 | + |
| 158 | +Based on the project's release configuration, use one of these types: |
| 159 | + |
| 160 | +- `feat:` - New features (appears in changelog as ✨ **New Features**) |
| 161 | +- `fix:` - Bug fixes (appears in changelog as 🐛 **Bug Fixes**) |
| 162 | +- `docs:` - Documentation changes (appears in changelog as 📚 **Documentation**) |
| 163 | +- `perf:` - Performance improvements (appears in changelog as 🚀 **Performance**) |
| 164 | +- `ci:` - CI/CD changes (appears in changelog as ⚙️ **CI**) |
| 165 | +- `test:` - Test additions or changes (not in changelog) |
| 166 | +- `refactor:` - Code refactoring (not in changelog) |
| 167 | +- `chore:` - Maintenance tasks (not in changelog) |
| 168 | +- `build:` - Build system changes (not in changelog) |
| 169 | + |
| 170 | +### Examples |
| 171 | + |
| 172 | +```bash |
| 173 | +feat: add support for nested transactions |
| 174 | +fix: prevent memory leak in transaction rollback |
| 175 | +docs: clarify setup instructions for Testcontainers |
| 176 | +perf: optimize transaction initialization |
| 177 | +test: add tests for edge cases in rollback logic |
| 178 | +refactor: simplify client creation logic |
| 179 | +``` |
| 180 | +
|
| 181 | +Include a detailed description in the commit body explaining: |
| 182 | +- What changed |
| 183 | +- Why it changed |
| 184 | +- How to migrate from the old behavior |
| 185 | +
|
| 186 | +### Tips |
| 187 | +
|
| 188 | +- **Keep it concise**: The description should be clear and to the point |
| 189 | +- **Use imperative mood**: "add feature" not "added feature" or "adds feature" |
| 190 | +- **Don't capitalize** the first letter of the description |
| 191 | +- **No period** at the end of the description |
| 192 | +
|
| 193 | +## 🧪 Testing Guidelines |
| 194 | +
|
| 195 | +Every code contribution should include appropriate tests. |
| 196 | +
|
| 197 | +### Test Structure |
| 198 | +
|
| 199 | +- Tests are located in the `src/` directory alongside the source code |
| 200 | +- Test files use the `.test.ts` extension (e.g., `index.test.ts`, `context.test.ts`) |
| 201 | +
|
| 202 | +### Writing Tests |
| 203 | +
|
| 204 | +- Use Vitest's testing APIs (`describe`, `it`, `expect`, etc.) |
| 205 | +- Test both **success cases** and **failure cases** |
| 206 | +- Ensure tests are **isolated** (don't depend on other tests or their execution order) |
| 207 | +- Keep tests **focused** (one concept per test) |
| 208 | +- Use **descriptive test names** that explain what is being tested |
| 209 | +
|
| 210 | +### Example |
| 211 | +
|
| 212 | +```ts |
| 213 | +import { describe, it, expect } from 'vitest'; |
| 214 | +
|
| 215 | +describe('MyFeature', () => { |
| 216 | + it('should handle valid input correctly', () => { |
| 217 | + // Test implementation |
| 218 | + }); |
| 219 | +
|
| 220 | + it('should throw error for invalid input', () => { |
| 221 | + expect(() => myFunction(invalidInput)).toThrow(); |
| 222 | + }); |
| 223 | +}); |
| 224 | +``` |
| 225 | + |
| 226 | +## 💬 Getting Help |
| 227 | + |
| 228 | +- **Usage questions?** Check the [README](./README.md) first |
| 229 | +- **Found a bug?** [Open an issue](https://github.com/codepunkt/vitest-environment-prisma-postgres/issues/new) |
| 230 | +- **Want to discuss a feature?** [Open an issue](https://github.com/codepunkt/vitest-environment-prisma-postgres/issues/new) for discussion |
| 231 | +- **General questions?** Feel free to start a discussion or comment on relevant issues |
| 232 | + |
| 233 | +## 📜 License |
| 234 | + |
| 235 | +By contributing to vitest-environment-prisma-postgres, you agree that your contributions will be licensed under the [MIT License](./LICENSE). |
0 commit comments