summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-watch-enoent.js
blob: 38f10e1430a3601207921ddd27b6a979a84b39a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';
const common = require('../common');
const assert = require('assert');
const fs = require('fs');

assert.throws(function() {
  fs.watch('non-existent-file');
}, function(err) {
  assert(err);
  assert(/non-existent-file/.test(err));
  assert.strictEqual(err.filename, 'non-existent-file');
  return true;
});

const watcher = fs.watch(__filename);
watcher.on('error', common.mustCall(function(err) {
  assert(err);
  assert(/non-existent-file/.test(err));
  assert.strictEqual(err.filename, 'non-existent-file');
}));
watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file');