Skip to content

Commit

Permalink
test fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 12, 2018
1 parent b1fb413 commit 74e39bb
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/resolver_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,23 @@ test('sync: #121 - treating an existing file as a dir when no basedir', function
});

t.test('with a trailing slash', function (st) {
function run() { return resolve.sync('./' + testFile + '/'); }

st.throws(run, 'throws an error');
var path = './' + testFile + '/';
function run() { return resolve.sync(path); }

var result, error;
try {
run();
result = run();
} catch (e) {
st.equal(e.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
st.equal(
e.message,
'Cannot find module \'./' + testFile + '/\' from \'' + __dirname + '\'',
'can not find nonexistent module'
);
error = e;
}
st.ok(error, 'there is an error');
st.notOk(result, 'no result');
st.equal(error && error.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
st.equal(
error && error.message,
'Cannot find module \'' + path + '\' from \'' + __dirname + '\'',
'can not find nonexistent module'
);

st.end();
});
Expand Down

0 comments on commit 74e39bb

Please sign in to comment.