Repository: parcel-bundler/parcel
File: packages/core/integration-tests/test/javascript.js (JavaScript)

Code before:

    let dist = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(
      dist.includes(
        xplatPath(
          'require("path").join(__dirname, "../test/integration/env-node-replacements")',
        ),
      ),
    );
    assert(
      dist.includes(
        xplatPath(
          'require("path").join(__dirname, "../test/integration/env-node-replacements", "index.js")',
        ),
      ),
    );
    let f = await run(b);
    let output = f();
    assert.equal(output.data, 'hello');
    assert(
      output.firstDirnameTest.includes(
        xplatPath(
          'integration-tests/test/integration/env-node-replacements/data',
        ),
      ),
    );
    assert(
      output.secondDirnameTest.includes(
        xplatPath(
          'integration-tests/test/integration/env-node-replacements/other-data',
        ),
      ),
    );
    assert(
      output.firstFilenameTest.includes(
        xplatPath(
          'integration-tests/test/integration/env-node-replacements/index.js',
        ),
      ),
    );
    assert(
      output.secondFilenameTest.includes(
        xplatPath(
          'integration-tests/test/integration/env-node-replacements/index.js?query-string=test',
        ),
      ),
    );
  });

  it('should work when multiple files use globals with scope hoisting', async function () {
    let b = await bundle(

Review comment (suggestion):
I think something like
```js
assert.equals(output.firstDirnameTest, path.join(__dirname, '/integration/env-node-replacements/data'));
```
would be better here. That also covers using the appropriate path separators for the current platform

Code after:
      dist.includes(
        'require("path").resolve(__dirname, "../test/integration/env-node-replacements")',
      ),
    );
    assert(
      dist.includes(
        'require("path").resolve(__dirname, "../test/integration/env-node-replacements/other")',
      ),
    );
    assert(
      dist.includes(
        'require("path").resolve(__dirname, "../test/integration/env-node-replacements", "index.js")',
      ),
    );
    assert(
      dist.includes(
        'require("path").resolve(__dirname, "../test/integration/env-node-replacements/sub")',
      ),
    );
    assert(
      dist.includes(
        'require("path").resolve(__dirname, "../test/integration/env-node-replacements/sub", "index.js")',
      ),
    );
    let f = await run(b);
    let output = f();
    assert.equal(output.data, 'hello');
    assert.equal(output.other, 'hello');
    assert.equal(
      output.firstDirnameTest,
      path.join(__dirname, '/integration/env-node-replacements/data'),
    );
    assert.equal(
      output.secondDirnameTest,
      path.join(__dirname, '/integration/env-node-replacements/other-data'),
    );
    assert.equal(
      output.firstFilenameTest,
      path.join(__dirname, '/integration/env-node-replacements/index.js'),
    );
    assert.equal(
      output.secondFilenameTest,
      path.join(
        __dirname,
        '/integration/env-node-replacements/index.js?query-string=test',
      ),
    );
    assert.equal(
      output.sub.dirname,
      path.join(__dirname, '/integration/env-node-replacements/sub'),
    );