• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const fixtures = require('../common/fixtures');
6
7common.expectWarning({
8  Warning: [
9    ["Accessing non-existent property 'missingPropB' " +
10     'of module exports inside circular dependency'],
11    ["Accessing non-existent property 'Symbol(someSymbol)' " +
12     'of module exports inside circular dependency'],
13    ["Accessing non-existent property 'missingPropModuleExportsB' " +
14     'of module exports inside circular dependency'],
15  ]
16});
17const required = require(fixtures.path('cycles', 'warning-a.js'));
18assert.strictEqual(Object.getPrototypeOf(required), Object.prototype);
19
20const requiredWithModuleExportsOverridden =
21  require(fixtures.path('cycles', 'warning-moduleexports-a.js'));
22assert.strictEqual(Object.getPrototypeOf(requiredWithModuleExportsOverridden),
23                   Object.prototype);
24
25// If module.exports is not a regular object, no warning should be emitted.
26const classExport =
27  require(fixtures.path('cycles', 'warning-moduleexports-class-a.js'));
28assert.strictEqual(Object.getPrototypeOf(classExport).name, 'Parent');
29
30// If module.exports.__esModule is set, no warning should be emitted.
31const esmTranspiledExport =
32  require(fixtures.path('cycles', 'warning-esm-transpiled-a.js'));
33assert.strictEqual(esmTranspiledExport.__esModule, true);
34
35// If module.exports.__esModule is being accessed but is not present, e.g.
36// because only the one of the files is a transpiled ES module, no warning
37// should be emitted.
38const halfTranspiledExport =
39  require(fixtures.path('cycles', 'warning-esm-half-transpiled-a.js'));
40assert.strictEqual(halfTranspiledExport.__esModule, undefined);
41
42// No circular check is done to prevent triggering proxy traps, if
43// module.exports is set to a proxy that contains a `getPrototypeOf` or
44// `setPrototypeOf` trap.
45require(fixtures.path('cycles', 'warning-skip-proxy-traps-a.js'));
46