title: Node.js List All Modules Required in a File
body: <p>I must be missing something here. I have a mocha test file that is set up like so:</p>
  
  <pre><code>require('globals');
  var library1 = require('library1'),
    library2 = require('library2');
  
  it('tests stuff', function() {
    ...
  });
  </code></pre>
  
  <p>Where the <code>globals</code> file just contains a <code>before</code> and <code>afterEach</code> block, so that they apply to all my test files.</p>
  
  <p>What I'm trying to do is determine, within the <code>before</code> and <code>afterEach</code> blocks, which files that I have <code>require</code>'d in the test file that those blocks are currently running in. So in the example test file I gave, I would need <code>afterEach</code> to output a list that contains <code>globals</code>, <code>library1</code>, and <code>library2</code>.</p>
  
  <p>I have attempted to use Node.js's <code>module.children</code> property, but for some reason that is only returning me <code>globals</code>, and excluding <code>library1</code> and <code>library2</code>.</p>
  
  <p><strong>Edit:</strong> What am I missing that <code>module.children</code> wouldn't be returning <code>library1</code> and <code>library2</code>?</p>