From e3717ebd28719f99c8d637f569f12314b584492d Mon Sep 17 00:00:00 2001 From: Chakradhar Palaparthi Date: Fri, 7 Aug 2020 13:19:49 +0530 Subject: [PATCH] fix: test case runOnChangeOnly true Fixed the problem in lib/monitor/run and made this test to run. Script will create a tmp file, which should not happen as runOnChangeOnly is set to true. --- test/monitor/run.test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/monitor/run.test.js b/test/monitor/run.test.js index b7cc3521..3c55bb55 100644 --- a/test/monitor/run.test.js +++ b/test/monitor/run.test.js @@ -140,17 +140,23 @@ describe('when nodemon runs (2)', function () { }); }); - // FIXME this test was never working properly - it.skip('should not run command on startup if runOnChangeOnly is true', + // Fixed! FIXME this test was previously not working properly + // corrected the test case + // script should not be run i.e, + // file should not be created + it('should not run command on startup if runOnChangeOnly is true', function (done) { - fs.writeFileSync(tmp, 'console.log("testing 1 2 3")'); + var script = "var touch = require('touch');\n" + + "touch.sync(" + tmp2 + ");\n" + fs.writeFileSync(tmp, script); nodemon({ script: tmp, runOnChangeOnly: true, stdout: false, }).on('start', function () { - assert(false, 'script should not start'); + // file exists check + assert(!fs.existsSync(tmp2), 'script should not start'); }).once('exit', function () { done(); });