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

Code before:
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/interop-require-es-module-code-split-intermediate/main.js',
        ),
      );

      assert.equal(await run(b), 'bar:bar');
    });

    it('should not insert interop default for commonjs modules with default export', async function () {
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/interop-require-commonjs/a.js',
        ),
      );

      let output = await run(b);
      let obj = {
        test: 2,
      };
      obj.default = obj;
      assert.deepEqual(output.default, obj);
    });

    it('should add a default interop for a CJS module', async function () {
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/interop-commonjs/a.js',
        ),
      );

      let output = await run(b);
      assert.equal(output, 2);
    });

    it('should not insert default interop for wrapped CJS modules', async function () {
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/interop-require-commonjs-wrapped/a.js',
        ),
      );

      let output = await run(b);
      assert.equal(output, 'default');
    });

    it('should support multiple requires in the same variable declaration', async function () {
      let b = await bundle(

Review comment (suggestion):
This description could be made more specific, e.g.

```suggestion
    it('should add a default interop for a CJS module used dynamically in a hybrid module', async function () {
```

Code after:
        b.getBundles()[0].filePath,
        'utf8',
      );
      assert(contents.includes('foo'));
      assert(!contents.includes('bar'));
    });

    it('supports removing an unused inline export with uglify minification', async function () {
      // Uglify does strange things to multiple assignments in a line.
      // See https://github.com/parcel-bundler/parcel/issues/1549
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/export-local/a.js',
        ),
        {
          defaultTargetOptions: {
            shouldOptimize: true,
          },
        },
      );

      let output = await run(b);
      assert.deepEqual(output, 3);
    });

    it('should support sideEffects: false', async function () {
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/side-effects-false/a.js',
        ),
      );

      let output = await run(b);
      assert.deepEqual(output, 9);
    });

    it('can bundle browserify-produced umd bundles', async function () {
      let b = await bundle(
        path.join(
          __dirname,
          '/integration/scope-hoisting/commonjs/browserify-compat/index.js',
        ),
      );

      assert.equal(await run(b), 'foo');
    });

    it('replaces properties of require with undefined', async function () {
      let b = await bundle(