node/test/parallel/test-fs-read-file-assert-encoding.js
Vinícius do Carmo b19334e566 test: expand test coverage of fs.js
* test reading a file passing a not valid enconding

Refs: https://coverage.nodejs.org/coverage-067be658f966dafe/root/internal/fs.js.html
PR-URL: https://github.com/nodejs/node/pull/10947
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-01-27 16:21:59 +00:00

14 lines
283 B
JavaScript

'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}$`)
);