File
Blob: src/workerd/api/node/tests/module-nodejs-test.js
| 1 | // Copyright (c) 2025 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | import module from 'node:module'; |
| 5 | import { ok, deepStrictEqual } from 'node:assert'; |
| 6 | |
| 7 | export const testUnimplemented = { |
| 8 | async test() { |
| 9 | const fields = [ |
| 10 | '_cache', |
| 11 | '_pathCache', |
| 12 | '_extensions', |
| 13 | 'globalPaths', |
| 14 | '_debug', |
| 15 | 'isBuiltin', |
| 16 | '_findPath', |
| 17 | '_nodeModulePaths', |
| 18 | '_resolveLookupPaths', |
| 19 | '_load', |
| 20 | '_resolveFilename', |
| 21 | 'createRequire', |
| 22 | '_initPaths', |
| 23 | '_preloadModules', |
| 24 | 'syncBuiltinESMExports', |
| 25 | 'Module', |
| 26 | 'registerHooks', |
| 27 | 'builtinModules', |
| 28 | 'runMain', |
| 29 | 'register', |
| 30 | 'constants', |
| 31 | 'enableCompileCache', |
| 32 | 'findPackageJSON', |
| 33 | 'flushCompileCache', |
| 34 | 'stripTypeScriptTypes', |
| 35 | 'getCompileCacheDir', |
| 36 | 'findSourceMap', |
| 37 | 'SourceMap', |
| 38 | 'getSourceMapsSupport', |
| 39 | 'setSourceMapsSupport', |
| 40 | ]; |
| 41 | |
| 42 | for (const field of fields) { |
| 43 | ok(field in module, `${field} is not in module`); |
| 44 | ok(module[field] != null, `${field} is ${typeof module[field]}`); |
| 45 | } |
| 46 | |
| 47 | deepStrictEqual(Object.keys(module.Module.prototype), [ |
| 48 | 'load', |
| 49 | 'require', |
| 50 | '_compile', |
| 51 | ]); |
| 52 | }, |
| 53 | }; |