GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add common.expectRequiredModule() · nodejs/node@1f8eaec

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/common
    • index.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const net = require('net');
3232
const path = require('path');
3333
const { inspect } = require('util');
3434
const { isMainThread } = require('worker_threads');
35+
const { isModuleNamespaceObject } = require('util/types');
3536

3637
const tmpdir = require('./tmpdir');
3738
const bits = ['arm64', 'loong64', 'mips', 'mipsel', 'ppc64', 'riscv64', 's390x', 'x64']
@@ -938,6 +939,18 @@ function getPrintedStackTrace(stderr) {
938939
return result;
939940
}
940941

942+
/**
943+
* Check the exports of require(esm).
944+
* TODO(joyeecheung): use it in all the test-require-module-* tests to minimize changes
945+
* if/when we change the layout of the result returned by require(esm).
946+
* @param {object} mod result returned by require()
947+
* @param {object} expectation shape of expected namespace.
948+
*/
949+
function expectRequiredModule(mod, expectation) {
950+
assert(isModuleNamespaceObject(mod));
951+
assert.deepStrictEqual({ ...mod }, { ...expectation });
952+
}
953+
941954
const common = {
942955
allowGlobals,
943956
buildType,
@@ -946,6 +959,7 @@ const common = {
946959
createZeroFilledFile,
947960
defaultAutoSelectFamilyAttemptTimeout,
948961
expectsError,
962+
expectRequiredModule,
949963
expectWarning,
950964
gcUntil,
951965
getArrayBufferViews,

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.