Skip to content

Commit b1d4c13

Browse files
committed
test: add coverage for FSWatcher exception
Cover an previously uncovered exception possible in the internal start function for FSWatcher. Signed-off-by: Rich Trott <rtrott@gmail.com> PR-URL: nodejs#32057 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent 616a729 commit b1d4c13

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/sequential/test-fs-watch.js

+22
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,31 @@ tmpdir.refresh();
125125
w.close();
126126
},
127127
{
128+
name: 'Error',
129+
code: 'ERR_INTERNAL_ASSERTION',
128130
message: /^handle must be a FSEvent/,
131+
}
132+
);
133+
oldhandle.close(); // clean up
134+
}
135+
136+
{
137+
let oldhandle;
138+
assert.throws(
139+
() => {
140+
const w = fs.watch(__filename, common.mustNotCall());
141+
oldhandle = w._handle;
142+
const protoSymbols =
143+
Object.getOwnPropertySymbols(Object.getPrototypeOf(w));
144+
const kFSWatchStart =
145+
protoSymbols.find((val) => val.toString() === 'Symbol(kFSWatchStart)');
146+
w._handle = {};
147+
w[kFSWatchStart]();
148+
},
149+
{
129150
name: 'Error',
130151
code: 'ERR_INTERNAL_ASSERTION',
152+
message: /^handle must be a FSEvent/,
131153
}
132154
);
133155
oldhandle.close(); // clean up

0 commit comments

Comments
 (0)