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

Code before:
    this.timeout(15000);
    let subscription;
    let fixture = path.join(__dirname, '/integration/included-file');
    try {
      let b = bundler(path.join(fixture, 'index.txt'), {
        inputFS: overlayFS,
        shouldDisableCache: false,
      });
      await overlayFS.mkdirp(fixture);
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'a');
      subscription = await b.watch();
      let event = await getNextBuild(b);
      invariant(event.type === 'buildSuccess');
      let output1 = await overlayFS.readFile(
        event.bundleGraph.getBundles()[0].filePath,
        'utf8',
      );
      assert.strictEqual(output1, 'a');

      // Change included file
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'ERROR');
      event = await getNextBuild(b);
      invariant(event.type === 'buildFailure');
      assert.strictEqual(event.diagnostics[0].message, 'Custom error');

      // Change included file back
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'b');
      event = await getNextBuild(b);
      invariant(event.type === 'buildSuccess');
      let output3 = await overlayFS.readFile(
        event.bundleGraph.getBundles()[0].filePath,
        'utf8',
      );
      assert.strictEqual(output3, 'b');
    } finally {
      if (subscription) {
        await subscription.unsubscribe();
        subscription = null;
      }
    }
  });

  it('should support moving the project root', async function () {
    // This test relies on the real filesystem because the memory fs doesn't support renames.
    // But renameSync is broken on windows in CI with EPERM errors. Just skip this test for now.
    if (process.platform === 'win32') {
      return;
    }

    let b = await testCache({
      inputFS,

Review comment (suggestion):
```suggestion
      // Clear transformer error
```

Code after:
    this.timeout(15000);
    let subscription;
    let fixture = path.join(__dirname, '/integration/included-file');
    try {
      let b = bundler(path.join(fixture, 'index.txt'), {
        inputFS: overlayFS,
        shouldDisableCache: false,
      });
      await overlayFS.mkdirp(fixture);
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'a');
      subscription = await b.watch();
      let event = await getNextBuild(b);
      invariant(event.type === 'buildSuccess');
      let output1 = await overlayFS.readFile(
        event.bundleGraph.getBundles()[0].filePath,
        'utf8',
      );
      assert.strictEqual(output1, 'a');

      // Change included file
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'ERROR');
      event = await getNextBuild(b);
      invariant(event.type === 'buildFailure');
      assert.strictEqual(event.diagnostics[0].message, 'Custom error');

      // Clear transformer error
      await overlayFS.writeFile(path.join(fixture, 'included.txt'), 'b');
      event = await getNextBuild(b);
      invariant(event.type === 'buildSuccess');
      let output3 = await overlayFS.readFile(
        event.bundleGraph.getBundles()[0].filePath,
        'utf8',
      );
      assert.strictEqual(output3, 'b');
    } finally {
      if (subscription) {
        await subscription.unsubscribe();
        subscription = null;
      }
    }
  });

  it('should support moving the project root', async function () {
    // This test relies on the real filesystem because the memory fs doesn't support renames.
    // But renameSync is broken on windows in CI with EPERM errors. Just skip this test for now.
    if (process.platform === 'win32') {
      return;
    }

    let b = await testCache({
      inputFS,