Skip to content

Commit 83e9a3e

Browse files
TrottMylesBorins
authored andcommitted
test: add coverage for FSWatcher exception
Cover an previously uncovered exception possible in the internal start function for FSWatcher. Signed-off-by: Rich Trott <[email protected]> PR-URL: #32057 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Anto Aravinth <[email protected]>
1 parent 89987b3 commit 83e9a3e

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)