Skip to content

Commit 4ea2aad

Browse files
committed
Fix Jest tests
1 parent ec494fa commit 4ea2aad

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

packages/cra-template/template.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"@testing-library/user-event": "^14.6.1",
99
"@types/testing-library__jest-dom": "^6.0.0",
1010
"jest": "^30.0.5",
11+
"jest-environment-jsdom": "^30.0.5",
12+
"jest-watch-typeahead": "^3.0.1",
1113
"eslint": "^9.32.0"
1214
}
1315
}

packages/react-scripts/config/jest/cssTransform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
module.exports = {
1515
process() {
16-
return 'module.exports = {};';
16+
return { code: 'module.exports = {};' };
1717
},
1818
getCacheKey() {
1919
// The output is always the same.

packages/react-scripts/config/jest/fileTransform.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,26 @@ module.exports = {
1717
pascalCase: true,
1818
});
1919
const componentName = `Svg${pascalCaseFilename}`;
20-
return `const React = require('react');
21-
module.exports = {
22-
__esModule: true,
23-
default: ${assetFilename},
24-
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
25-
return {
26-
$$typeof: Symbol.for('react.element'),
27-
type: 'svg',
28-
ref: ref,
29-
key: null,
30-
props: Object.assign({}, props, {
31-
children: ${assetFilename}
32-
})
33-
};
34-
}),
35-
};`;
20+
return {
21+
code: `const React = require('react');
22+
module.exports = {
23+
__esModule: true,
24+
default: ${assetFilename},
25+
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
26+
return {
27+
$$typeof: Symbol.for('react.element'),
28+
type: 'svg',
29+
ref: ref,
30+
key: null,
31+
props: Object.assign({}, props, {
32+
children: ${assetFilename}
33+
})
34+
};
35+
}),
36+
};`,
37+
};
3638
}
3739

38-
return `module.exports = ${assetFilename};`;
40+
return { code: `module.exports = ${assetFilename};` };
3941
},
4042
};

0 commit comments

Comments
 (0)