From 74e39bb39a2e1d0b7a157a7db16254a93d7eb8a2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 11 Apr 2018 22:42:43 -0700 Subject: [PATCH] test fixup --- test/resolver_sync.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/resolver_sync.js b/test/resolver_sync.js index 057505cc..10965a80 100644 --- a/test/resolver_sync.js +++ b/test/resolver_sync.js @@ -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(); });