diff --git a/test/parallel/test-fs-read-file-assert-encoding.js b/test/parallel/test-fs-read-file-assert-encoding.js new file mode 100644 index 00000000000000..897bcd3bc98795 --- /dev/null +++ b/test/parallel/test-fs-read-file-assert-encoding.js @@ -0,0 +1,13 @@ +'use strict'; +require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const encoding = 'foo-8'; +const filename = 'bar.txt'; + +assert.throws( + fs.readFile.bind(fs, filename, { encoding }, () => {}), + new RegExp(`Error: Unknown encoding: ${encoding}$`) +);