Skip to content

Commit ca4a8e4

Browse files
committed
test fixup
1 parent a4539ba commit ca4a8e4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/resolver_sync.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,23 @@ test('sync: #121 - treating an existing file as a dir when no basedir', function
236236
});
237237

238238
t.test('with a trailing slash', function (st) {
239-
function run() { return resolve.sync('./' + testFile + '/'); }
240-
241-
st.throws(run, 'throws an error');
239+
var path = './' + testFile + '/';
240+
function run() { return resolve.sync(path); }
242241

242+
var result, error;
243243
try {
244-
run();
244+
result = run();
245245
} catch (e) {
246-
st.equal(e.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
247-
st.equal(
248-
e.message,
249-
'Cannot find module \'./' + testFile + '/\' from \'' + __dirname + '\'',
250-
'can not find nonexistent module'
251-
);
246+
error = e;
252247
}
248+
st.ok(error, 'there is an error');
249+
st.notOk(result, 'no result');
250+
st.equal(error && error.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');
251+
st.equal(
252+
error && error.message,
253+
'Cannot find module \'' + path + '\' from \'' + __dirname + '\'',
254+
'can not find nonexistent module'
255+
);
253256

254257
st.end();
255258
});

0 commit comments

Comments
 (0)