| 67 | // helper function to resolve the path from the test directory to actual assets |
| 68 | // Helper to read from package.json in a given path |
| 69 | const readFromPkgJSON = (path) => { |
| 70 | const pkgJSONPath = join(path, "package.json"); |
| 71 | |
| 72 | if (!existsSync(pkgJSONPath)) { |
| 73 | return {}; |
| 74 | } |
| 75 | |
| 76 | const pkgJSON = JSON.parse(readFileSync(pkgJSONPath, "utf8")); |
| 77 | const { devDependencies: devDeps } = pkgJSON; |
| 78 | |
| 79 | // Update devDeps versions to be x.x.x to prevent frequent snapshot updates |
| 80 | for (const dep of Object.keys(devDeps)) devDeps[dep] = "x.x.x"; |
| 81 | |
| 82 | return { ...pkgJSON, devDependencies: devDeps }; |
| 83 | }; |
| 84 | |
| 85 | // Helper to read from webpack.config.js or webpack.config.ts in a given path |
| 86 | const readFromWebpackConfig = (path, filename = "webpack.config.js") => |