{"_id":"@dbarrett24/jest-config","_rev":"3-acfcb5c709351b9da7b5f37c0b14da99","name":"@dbarrett24/jest-config","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@dbarrett24/jest-config","version":"1.0.0","keywords":["jest","testing","react","typescript"],"author":{"name":"Your Name"},"license":"MIT","_id":"@dbarrett24/jest-config@1.0.0","maintainers":[{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"}],"dist":{"shasum":"885c5f40ed04a6213a2f5c669b4d4ff5c428a318","tarball":"https://registry.npmjs.org/@dbarrett24/jest-config/-/jest-config-1.0.0.tgz","fileCount":3,"integrity":"sha512-YOgM9Ho728TQAEZ9eo2TNHBfFdk2/9NAEMFcKzupyzPYyF74jjTYywT/ZAA6IpfoiVPeVyEjrQ7i04VFeLcvXg==","signatures":[{"sig":"MEQCIAcGYF+NydYp05noYhcUo997SuZ5xg1dtUF67y1xwZnMAiB67Zzdy//9VIsClbuq9CoRlYtuPXoXea0EyigrsjRchA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5670},"main":"jest.config.js","_from":"file:dbarrett24-jest-config-1.0.0.tgz","_npmUser":{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"},"_resolved":"/private/var/folders/q_/z4dwy_td5ts0fdx2klqhf_900000gn/T/52c80b2e4151a9ab60d82265d656f9c0/dbarrett24-jest-config-1.0.0.tgz","_integrity":"sha512-YOgM9Ho728TQAEZ9eo2TNHBfFdk2/9NAEMFcKzupyzPYyF74jjTYywT/ZAA6IpfoiVPeVyEjrQ7i04VFeLcvXg==","_npmVersion":"10.9.3","description":"Shared Jest configuration for React/Next.js applications","directories":{},"_nodeVersion":"22.18.0","dependencies":{"@testing-library/react":"^16.3.0","jest-environment-jsdom":"^29.7.0","@testing-library/jest-dom":"^6.6.3","@testing-library/user-event":"^14.6.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"jest":">=29","react":">=18","react-dom":">=18"},"_npmOperationalInternal":{"tmp":"tmp/jest-config_1.0.0_1769474807506_0.052882116213219366","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@dbarrett24/jest-config","version":"1.0.1","keywords":["jest","testing","react","typescript"],"author":{"name":"dbarrett24"},"license":"MIT","_id":"@dbarrett24/jest-config@1.0.1","maintainers":[{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"}],"homepage":"https://github.com/dbarrett24/evolve-ui#readme","bugs":{"url":"https://github.com/dbarrett24/evolve-ui/issues"},"dist":{"shasum":"6f8d3da0222a652dd8f480a0e51e2b8e74a2f480","tarball":"https://registry.npmjs.org/@dbarrett24/jest-config/-/jest-config-1.0.1.tgz","fileCount":3,"integrity":"sha512-3CcfmxuVwG0B6z56GvYT2MJw9ZYj95QJyB5L0/ETtHroWTXD1RA/UB0lwRRnOjcsTPUUX7LTTN48vErAM+jgMA==","signatures":[{"sig":"MEQCIDTo5ZRuJmxgGqaVAuAbvJJOrFdoyRO+DKy1uzbeVFr+AiBqzvey+buDTSewZsQcOQn2aUc0q7mPcPKVuJGwjyoMpw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7727},"main":"jest.config.js","_from":"file:dbarrett24-jest-config-1.0.1.tgz","_npmUser":{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"},"_resolved":"/private/var/folders/q_/z4dwy_td5ts0fdx2klqhf_900000gn/T/884b211be92fe2435e7e7766347a0104/dbarrett24-jest-config-1.0.1.tgz","_integrity":"sha512-3CcfmxuVwG0B6z56GvYT2MJw9ZYj95QJyB5L0/ETtHroWTXD1RA/UB0lwRRnOjcsTPUUX7LTTN48vErAM+jgMA==","repository":{"url":"git+https://github.com/dbarrett24/evolve-ui.git","type":"git","directory":"shared-configs/jest-config"},"_npmVersion":"11.8.0","description":"Shared Jest configuration for React/Next.js applications","directories":{},"_nodeVersion":"25.5.0","dependencies":{"@swc/core":"^1.15.11","@swc/jest":"^0.2.39","@testing-library/react":"^16.3.0","jest-environment-jsdom":"^30.0.0","@testing-library/jest-dom":"^6.6.3","@testing-library/user-event":"^14.6.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"jest":">=30","react":">=18","react-dom":">=18"},"_npmOperationalInternal":{"tmp":"tmp/jest-config_1.0.1_1785214505078_0.45276242375310893","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@dbarrett24/jest-config","version":"1.0.2","description":"Shared Jest configuration for React/Next.js applications","main":"jest.config.js","keywords":["jest","testing","react","typescript"],"author":{"name":"dbarrett24"},"license":"MIT","dependencies":{"@swc/core":"^1.15.11","@swc/jest":"^0.2.39","@testing-library/jest-dom":"^6.6.3","@testing-library/react":"^16.3.0","@testing-library/user-event":"^14.6.1","jest-environment-jsdom":"^30.0.0"},"peerDependencies":{"jest":">=30","react":">=18","react-dom":">=18"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/dbarrett24/evolve-ui.git","directory":"shared-configs/jest-config"},"_id":"@dbarrett24/jest-config@1.0.2","bugs":{"url":"https://github.com/dbarrett24/evolve-ui/issues"},"homepage":"https://github.com/dbarrett24/evolve-ui#readme","_integrity":"sha512-us0kscy6b+p9xkMByZibVmiXYtse62mxP6p5Tu8MmMb8owJlktqnmJb1GGRxM6hUgGOm63uAZZH7E3I/VGuKrw==","_resolved":"/private/var/folders/q_/z4dwy_td5ts0fdx2klqhf_900000gn/T/a575b957d8a9a2cd726398d6bb212007/dbarrett24-jest-config-1.0.2.tgz","_from":"file:dbarrett24-jest-config-1.0.2.tgz","_nodeVersion":"25.5.0","_npmVersion":"11.8.0","dist":{"integrity":"sha512-us0kscy6b+p9xkMByZibVmiXYtse62mxP6p5Tu8MmMb8owJlktqnmJb1GGRxM6hUgGOm63uAZZH7E3I/VGuKrw==","shasum":"9d0184540a9a5b6c36cd29c544add90a3da402a1","tarball":"https://registry.npmjs.org/@dbarrett24/jest-config/-/jest-config-1.0.2.tgz","fileCount":5,"unpackedSize":9470,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCeA1Y+TAI38hlkQT4k8VGVafz4cNKF74mLuEWLlJUuJgIgNS6mu8C39SUDAhON52YcnAFicNOj34B5YXQ9qsg6MRQ="}]},"_npmUser":{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"},"directories":{},"maintainers":[{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/jest-config_1.0.2_1785251410714_0.946168375954719"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-27T00:46:47.404Z","modified":"2026-07-28T15:10:11.077Z","1.0.0":"2026-01-27T00:46:47.660Z","1.0.1":"2026-07-28T04:55:05.225Z","1.0.2":"2026-07-28T15:10:10.883Z"},"bugs":{"url":"https://github.com/dbarrett24/evolve-ui/issues"},"author":{"name":"dbarrett24"},"license":"MIT","homepage":"https://github.com/dbarrett24/evolve-ui#readme","keywords":["jest","testing","react","typescript"],"repository":{"type":"git","url":"git+https://github.com/dbarrett24/evolve-ui.git","directory":"shared-configs/jest-config"},"description":"Shared Jest configuration for React/Next.js applications","maintainers":[{"name":"dbarrett24","email":"dev.davebarrett@gmail.com"}],"readme":"# @dbarrett24/jest-config\n\nShared Jest configuration for React/Next.js applications in the monorepo.\n\n## Features\n\n- ✅ **Fast test execution** with @swc/jest (20-30x faster than babel-jest)\n- ✅ **Automatic JSX runtime** (no React imports needed)\n- ✅ **jsdom environment** for React component testing\n- ✅ **Coverage thresholds** (90% for apps)\n- ✅ **Path alias support** (`@/*` mapped to `src/*`)\n- ✅ **Asset mocking** (CSS, images)\n\n## Usage\n\n### In Your Package\n\n1. **Install the config**:\n   ```json\n   {\n     \"devDependencies\": {\n       \"@dbarrett24/jest-config\": \"workspace:*\",\n       \"jest\": \"^29.7.0\"\n     }\n   }\n   ```\n\n2. **Create `jest.config.js`**:\n   ```javascript\n   module.exports = require('@dbarrett24/jest-config');\n   ```\n\n3. **Create test setup file** at `testing/setupTests.ts`:\n   ```typescript\n   import '@testing-library/jest-dom';\n   ```\n\n4. **Add test scripts** to `package.json`:\n   ```json\n   {\n     \"scripts\": {\n       \"test\": \"jest\",\n       \"test:watch\": \"jest --watch\",\n       \"test:coverage\": \"jest --coverage\"\n     }\n   }\n   ```\n\n### Extending the Configuration\n\nIf you need to customize the config:\n\n```javascript\nconst baseConfig = require('@dbarrett24/jest-config');\n\nmodule.exports = {\n    ...baseConfig,\n    displayName: 'my-app',\n    // Add your overrides here\n    testPathIgnorePatterns: [\n        ...baseConfig.testPathIgnorePatterns,\n        '/custom-folder/',\n    ],\n};\n```\n\n## Configuration Details\n\n### Test Environment\n- **Environment**: `jsdom` (for React/DOM testing)\n- **Setup**: Loads `testing/setupTests.ts` after environment setup\n\n### Coverage Thresholds\n- **Statements**: 90%\n- **Branches**: 90%\n- **Functions**: 90%\n- **Lines**: 90%\n\n### Path Aliases\n- `@/*` → `<rootDir>/src/*`\n\n### Asset Mocking\n- CSS files → `testing/__mocks__/styleMock.js`\n- Images → `testing/__mocks__/fileMock.js`\n\n### File Transform\nUses `@swc/jest` with automatic JSX runtime:\n```javascript\ntransform: {\n    '^.+\\\\.(t|j)sx?$': [\n        '@swc/jest',\n        {\n            jsc: {\n                transform: {\n                    react: {\n                        runtime: 'automatic', // No React imports needed!\n                    },\n                },\n            },\n        },\n    ],\n}\n```\n\n## Library Configuration\n\nFor component libraries, use `@dbarrett24/jest-config-library` instead. It extends this config with:\n- Higher coverage thresholds (95%)\n- Additional ignore patterns for Storybook\n- Library-specific display name\n\n## Testing Patterns\n\n### Component Tests\n\n```typescript\nimport { render, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { MyComponent } from './MyComponent';\n\ndescribe('MyComponent', () => {\n    it('renders correctly', () => {\n        render(<MyComponent title=\"Hello\" />);\n        expect(screen.getByText('Hello')).toBeVisible();\n    });\n\n    it('handles click events', async () => {\n        const handleClick = jest.fn();\n        render(<MyComponent onClick={handleClick} />);\n        \n        await userEvent.click(screen.getByRole('button'));\n        expect(handleClick).toHaveBeenCalledTimes(1);\n    });\n});\n```\n\n### No React Imports Needed\n\nThanks to @swc/jest with automatic JSX runtime:\n\n```typescript\n// ✅ CORRECT - No React import\nimport { render } from '@testing-library/react';\nimport { Button } from './Button';\n\n// ❌ WRONG - Don't import React\nimport React from 'react';\n```\n\n## Troubleshooting\n\n### \"React is not defined\" error\n\nIf you see this error, your @swc/jest transform is not configured correctly. Ensure your `jest.config.js` includes the `react.runtime: 'automatic'` setting.\n\n### Coverage thresholds not enforced\n\nMake sure you're running `jest --coverage` to enable coverage checks.\n\n### Path aliases not working\n\nVerify your `tsconfig.json` has matching path mappings:\n```json\n{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@/*\": [\"./src/*\"]\n    }\n  }\n}\n```\n\n## Performance\n\n**@swc/jest vs babel-jest**:\n- ✅ 20-30x faster test execution\n- ✅ No Babel dependencies required\n- ✅ Rust-based transpilation\n- ✅ Native TypeScript & JSX support\n\n## Related Packages\n\n- `@dbarrett24/jest-config-library` - For component libraries (95% coverage)\n- `@dbarrett24/testing-utils` - Shared test utilities and mocks\n- `@dbarrett24/typescript-config` - TypeScript configurations\n\n## Migration from babel-jest\n\nIf migrating from an older setup with babel-jest:\n\n1. Remove Babel dependencies:\n   ```bash\n   pnpm remove babel-jest @babel/preset-env @babel/preset-react @babel/preset-typescript\n   ```\n\n2. Install @swc packages (already in this config):\n   ```bash\n   pnpm install\n   ```\n\n3. Remove React imports from component files:\n   ```typescript\n   // Before\n   import React from 'react';\n   \n   // After\n   // (remove the import)\n   ```\n\n4. Run tests to verify:\n   ```bash\n   pnpm test\n   ```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}