1'use strict'; 2const common = require('../common'); 3 4// This test checks that the `stop` event is emitted asynchronously. 5// 6// If it isn't asynchronous, then the listener will be called during the 7// execution of `watch.stop()`. That would be a bug. 8// 9// If it is asynchronous, then the listener will be removed before the event is 10// emitted. 11 12const fs = require('fs'); 13 14const listener = common.mustNotCall( 15 'listener should have been removed before the event was emitted' 16); 17 18const watch = fs.watchFile(__filename, common.mustNotCall()); 19watch.once('stop', listener); 20watch.stop(); 21watch.removeListener('stop', listener); 22