Skip to content

Commit

Permalink
feat(jest-config): add support for inline snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanaubrey committed Nov 18, 2024
1 parent 820943a commit e800440
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 36 deletions.
12 changes: 10 additions & 2 deletions .syncpackrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
const config = require('@repodog/syncpack-config');
const { versionGroups, ...rest } = require('@repodog/syncpack-config');

module.exports = {
...config,
...rest,
versionGroups: [
{
dependencies: ['prettier'],
isIgnored: true,
packages: ['@repodog/jest-config'],
},
...versionGroups,
],
};
14 changes: 14 additions & 0 deletions configs/jest-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ module.exports = {
}
```

### Inline snapshots

The config includes `prettier@^2` as a dependency so you can continue to use Jest inline snapshots without much additional configuration. All that is needed is to add a `.prettierrc` to the root of your project. This file will not conflict with the `prettier.config.mjs` file used by `@repodog/eslint-config` to format the rest of your code.

```jsonc
// .prettierrc
{
"arrowParens": "avoid",
"printWidth": 120,
"singleQuote": true,
"trailingComa": "all"
}
```

### Environment variables

#### `COMPILER` = `'babel' || 'swc'`
Expand Down
1 change: 1 addition & 0 deletions configs/jest-config/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const config = ({ compilerOptions = {} } = {}) => {
extensionsToTreatAsEsm: isCjs ? [] : ['.jsx', '.ts', '.tsx'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs', 'cjs', 'jsx', 'json'],
moduleNameMapper,
prettierPath: require.resolve('prettier'),
rootDir: packageDir,
testEnvironment: isJsEnvWeb ? 'jsdom' : 'node',
testMatch,
Expand Down
3 changes: 2 additions & 1 deletion configs/jest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"access": "public"
},
"dependencies": {
"identity-obj-proxy": "^3.0.0"
"identity-obj-proxy": "^3.0.0",
"prettier": "^2.8.8"
},
"peerDependencies": {
"@jest/globals": "<30",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
"ws": ">=8.17.1"
}
}
}
}
55 changes: 23 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e800440

Please sign in to comment.