Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: add coverage for FSWatcher exception
Cover an previously uncovered exception possible in the internal start
function for FSWatcher.
  • Loading branch information
Trott committed Mar 1, 2020
commit 92ffbb8817daf90361487b4710feb56a8974e36c
22 changes: 22 additions & 0 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,25 @@ tmpdir.refresh();
);
oldhandle.close(); // clean up
}

{
let oldhandle;
assert.throws(
() => {
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
const protoSymbols =
Object.getOwnPropertySymbols(Object.getPrototypeOf(w));
const kFSWatchStart =
protoSymbols.find((val) => val.toString() === 'Symbol(kFSWatchStart)');
w._handle = {};
w[kFSWatchStart]();
},
{
name: 'TypeError',
code: 'ERR_UNEXPECTED_INSTANCE',
message: 'handle must have FSEvent in its prototype chain',
}
);
oldhandle.close(); // clean up
}