node/test/parallel/test-module-loading-error.js
Gibson Fahnestock 7a0e462f9f test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.

PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2017-01-11 11:43:52 +00:00

39 lines
851 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
console.error('load test-module-loading-error.js');
const error_desc = {
win32: ['%1 is not a valid Win32 application'],
linux: ['file too short', 'Exec format error'],
sunos: ['unknown file type', 'not an ELF file'],
darwin: ['file too short']
};
const dlerror_msg = error_desc[process.platform];
if (!dlerror_msg) {
common.skip('platform not supported.');
return;
}
try {
require('../fixtures/module-loading-error.node');
} catch (e) {
assert.strictEqual(dlerror_msg.some((errMsgCase) => {
return e.toString().indexOf(errMsgCase) !== -1;
}), true);
}
try {
require();
} catch (e) {
assert.ok(e.toString().includes('missing path'));
}
try {
require({});
} catch (e) {
assert.ok(e.toString().includes('path must be a string'));
}