How to use the chokidar.watcher function in chokidar

To help you get started, we’ve selected a few chokidar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheBrainFamily / chimpy / src / __tests__ / chimp-spec.js View on Github external
it('all listener is registered after watcher is ready', function () {

      var chokidar = require('chokidar');
      var Chimp = require('../lib/chimp.js');

      var options = {path: 'abc'};
      var chimp = new Chimp(options);

      chimp.run = jest.genMockFunction();
      chokidar.watcher.on = jest.genMockFunction();

      chimp.watch();
      expect(chokidar.watcher.once.mock.calls[0][0]).toBe('ready');

      var readyCallback = chokidar.watcher.once.mock.calls[0][1];

      readyCallback();
      expect(chokidar.watcher.on.mock.calls[0][0]).toBe('all');

    });
github TheBrainFamily / chimpy / src / __tests__ / chimp-spec.js View on Github external
it('all listener is registered after watcher is ready', function () {

      var chokidar = require('chokidar');
      var Chimp = require('../lib/chimp.js');

      var options = {path: 'abc'};
      var chimp = new Chimp(options);

      chimp.run = jest.genMockFunction();
      chokidar.watcher.on = jest.genMockFunction();

      chimp.watch();
      expect(chokidar.watcher.once.mock.calls[0][0]).toBe('ready');

      var readyCallback = chokidar.watcher.once.mock.calls[0][1];

      readyCallback();
      expect(chokidar.watcher.on.mock.calls[0][0]).toBe('all');

    });
github TheBrainFamily / chimpy / src / __tests__ / chimp-spec.js View on Github external
it('a deleted feature does not trigger the interrupt and run sequence', function () {

      var chokidar = require('chokidar');
      var Chimp = require('../lib/chimp.js');

      //var _on = process.on;
      //process.on = jest.genMockFunction();

      var chimp = new Chimp();

      chimp.run = jest.genMockFunction();

      chimp.watch();

      var readyCallback = chokidar.watcher.once.mock.calls[0][1];
      readyCallback();

      var allCallback = chokidar.watcher.on.mock.calls[0][1];

      chimp.rerun = jest.genMockFunction();

      allCallback('unlink', '/path/some.feature');

      expect(chimp.rerun.mock.calls.length).toBe(0);

      //process.on = _on;

    });
github TheBrainFamily / chimpy / __tests__ / monkey-spec.js View on Github external
it('all listener is registered after watcher is ready', function () {

      var chokidar = require('chokidar');
      var Monkey = require('../lib/monkey.js');

      var options = {path: 'abc'};
      var monkey = new Monkey(options);

      monkey.run = jest.genMockFunction();
      chokidar.watcher.on = jest.genMockFunction();

      monkey.watch();
      expect(chokidar.watcher.on.mock.calls[0][0]).toBe('ready');

      var readyCallback = chokidar.watcher.on.mock.calls[0][1];

      readyCallback();
      expect(chokidar.watcher.on.mock.calls[1][0]).toBe('all');

    });
github TheBrainFamily / chimpy / __tests__ / monkey-spec.js View on Github external
var chokidar = require('chokidar');
      var Monkey = require('../lib/monkey.js');

      var options = {path: 'abc'};
      var monkey = new Monkey(options);

      monkey.run = jest.genMockFunction();
      chokidar.watcher.on = jest.genMockFunction();

      monkey.watch();
      expect(chokidar.watcher.on.mock.calls[0][0]).toBe('ready');

      var readyCallback = chokidar.watcher.on.mock.calls[0][1];

      readyCallback();
      expect(chokidar.watcher.on.mock.calls[1][0]).toBe('all');

    });
github TheBrainFamily / chimpy / src / __tests__ / chimp-spec.js View on Github external
var chimp = new Chimp();

      chimp.run = jest.genMockFunction();

      var self = this;
      self.func = null;
      self.timeout = null;
      chimp._getDebouncedFunction = function(func, timeout) {
        self.allCallback = func;
        self.timeout = timeout;
      };

      chimp.watch();

      var readyCallback = chokidar.watcher.once.mock.calls[0][1];
      readyCallback();

      chimp.rerun = jest.genMockFunction();

      self.allCallback('not-unlink');

      expect(chimp.rerun.mock.calls.length).toBe(1);

    });

chokidar

Minimal and efficient cross-platform file watching library

MIT
Latest version published 1 year ago

Package Health Score

81 / 100
Full package analysis