File tree Expand file tree Collapse file tree 4 files changed +35
-35
lines changed
packages/json-map-keys-jest Expand file tree Collapse file tree 4 files changed +35
-35
lines changed Original file line number Diff line number Diff line change 22
33> Jest transformer to replace json values with the key path.
44
5+ ``` js
6+ /** @type {import('jest').Config} */
7+ export default {
8+ transform: {
9+ ' data\\ .json$' : [' json-map-keys-jest' , { prefix: ' [name]:' }]
10+ }
11+ }
12+ ```
13+
514## License
615
716JSON Map Keys Jest © 2020 by Tiago Porto is licensed under [ MIT License] ( LICENSE ) .
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import jsonParser from 'json-map-keys'
2+ import { interpolateName } from 'loader-utils'
3+
4+ export default {
5+ process ( sourceText , sourcePath , { transformerConfig } ) {
6+ let prefix = ''
7+ if ( transformerConfig && transformerConfig . prefix ) {
8+ prefix = interpolateName (
9+ { resourcePath : sourcePath } ,
10+ transformerConfig . prefix ,
11+ {
12+ sourceText,
13+ } ,
14+ )
15+ }
16+ const resources = jsonParser ( JSON . parse ( sourceText ) , prefix )
17+
18+ return {
19+ code : JSON . stringify ( resources ) ,
20+ }
21+ } ,
22+ }
Original file line number Diff line number Diff line change 1818 },
1919 "funding" : " https://github.com/sponsors/tiagoporto" ,
2020 "license" : " MIT" ,
21- "main" : " ./index.js" ,
21+ "type" : " module" ,
22+ "main" : " ./index.mjs" ,
2223 "dependencies" : {
2324 "json-map-keys" : " ^1.0.0-beta.1" ,
24- "loader-utils" : " ^2.0.0 "
25+ "loader-utils" : " ^3.3.1 "
2526 },
2627 "peerDependencies" : {
27- "jest" : " >= 24 "
28+ "jest" : " >= 27 "
2829 }
2930}
You can’t perform that action at this time.
0 commit comments