Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jan 10, 2022
1 parent f53ffe7 commit 4733547
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/core/integration-tests/test/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5836,6 +5836,49 @@ describe('cache', function () {
}
});

it('properly watches included files after a transformer error', async function () {
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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4733547

Please sign in to comment.