From 55ac214fd51f5699033b90aca4cc9de2ba76ebe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Cie=C5=9Blak?= Date: Thu, 17 Oct 2019 23:10:20 +0000 Subject: [PATCH] Test #2479: Watcher should stay up even if files are broken --- test/fixtures/watcher/crash/broken.scss | 1 + test/watcher.js | 46 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/fixtures/watcher/crash/broken.scss diff --git a/test/fixtures/watcher/crash/broken.scss b/test/fixtures/watcher/crash/broken.scss new file mode 100644 index 000000000..f7df9d4fd --- /dev/null +++ b/test/fixtures/watcher/crash/broken.scss @@ -0,0 +1 @@ +h1 { } diff --git a/test/watcher.js b/test/watcher.js index c96d39875..964b14c3a 100644 --- a/test/watcher.js +++ b/test/watcher.js @@ -499,5 +499,51 @@ describe('watcher', function() { }); }); }); + describe('with syntax errors', function() { + it('should produce a one-file graph', function() { + fs.copySync( + path.join(origin, 'crash', 'broken.scss'), + path.join(main, 'one.scss') + ); + var files = watcher.reset({ + src: path.join(main, 'one.scss'), + includePath: [main] + }); + assert.deepEqual(files.sort(), [ + path.join(main, 'one.scss'), + ].sort()); + fs.copySync( + path.join(origin, 'main', 'one.scss'), + path.join(main, 'one.scss') + ); + files = watcher.changed( + path.join(main, 'one.scss') + ); + assert.deepEqual(files.changed.sort(), [ + path.join(main, 'one.scss'), + ]); + }); + it('should keep the graph even if a file gets broken', function() { + var files = watcher.reset({ + src: path.join(main, 'one.scss'), + includePath: [main] + }); + assert.deepEqual(files.sort(), [ + path.join(main, 'one.scss'), + path.join(main, 'partials', '_one.scss'), + path.join(main, 'partials', '_three.scss'), + ].sort()); + fs.copySync( + path.join(origin, 'crash', 'broken.scss'), + path.join(main, 'one.scss') + ); + files = watcher.changed( + path.join(main, 'one.scss') + ); + assert.deepEqual(files.changed.sort(), [ + path.join(main, 'one.scss'), + ]); + }); + }); }); });