You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
760 B

'use strict';
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const common = require('../common');
const fixtures = path.join(__dirname, '..', 'fixtures');
// Basic usage tests.
assert.throws(function() {
fs.watchFile('./some-file');
}, /watchFile requires a listener function/);
assert.throws(function() {
fs.watchFile('./another-file', {}, 'bad listener');
}, /watchFile requires a listener function/);
assert.throws(function() {
fs.watchFile(new Object(), function() {});
}, /Path must be a string/);
// Test ENOENT. Should fire once.
const enoentFile = path.join(fixtures, 'empty', 'non-existent-file');
fs.watchFile(enoentFile, common.mustCall(function(curr, prev) {
fs.unwatchFile(enoentFile);
}));