* Build a `mock.module` options bag whose exports read live from the * given wrapper object. * @param {Record } target wrapped namespace * @returns {Record } options accepted by the running Node's `mock.module`
(target)
| 88 | * @returns {Record<string, unknown>} options accepted by the running Node's `mock.module` |
| 89 | */ |
| 90 | function mockModuleOptions(target) { |
| 91 | if (NODE_MAJOR < 24) { |
| 92 | return { namedExports: target, defaultExport: target }; |
| 93 | } |
| 94 | |
| 95 | const liveExports = {}; |
| 96 | |
| 97 | for (const key of Object.keys(target)) { |
| 98 | Object.defineProperty(liveExports, key, { |
| 99 | enumerable: true, |
| 100 | get: () => target[key], |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | Object.defineProperty(liveExports, "default", { |
| 105 | enumerable: true, |
| 106 | get: () => target, |
| 107 | }); |
| 108 | |
| 109 | return { exports: liveExports }; |
| 110 | } |
| 111 | |
| 112 | mock.module(sassEsmURL, mockModuleOptions(sass)); |
| 113 | mock.module(sassEmbeddedEsmURL, mockModuleOptions(sassEmbedded)); |
no outgoing calls
no test coverage detected
searching dependent graphs…