Skip to content

Commit

Permalink
[Tests] skip some tests for a broken require.resolve in node v8.9, …
Browse files Browse the repository at this point in the history
…v9.0-v9.2

See nodejs/node#17113
  • Loading branch information
ljharb committed Oct 10, 2023
1 parent 75d3bb9 commit f0930c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"func-name-matching": 0,
"func-style": 0,
"global-require": 1,
"id-length": [2, { "min": 1, "max": 30 }],
"id-length": [2, { "min": 1, "max": 40 }],
"max-lines": [2, 350],
"max-lines-per-function": 0,
"max-nested-callbacks": 0,
Expand Down
9 changes: 6 additions & 3 deletions test/resolver_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var sync = require('../sync');
var requireResolveSupportsPaths = require.resolve.length > 1
&& !(/^v12\.[012]\./).test(process.version); // broken in v12.0-12.2, see https://github.com/nodejs/node/issues/27794

var requireResolveDefaultPathsBroken = (/^v8\.9\.|^v9\.[01]\.0|^v9\.2\./).test(process.version);
// broken in node v8.9.x, v9.0, v9.1, v9.2.x. see https://github.com/nodejs/node/pull/17113

test('`./sync` entry point', function (t) {
t.equal(resolve.sync, sync, '`./sync` entry point is the same as `.sync` on `main`');
t.end();
Expand Down Expand Up @@ -75,7 +78,7 @@ test('bar', function (t) {
path.join(dir, 'bar/node_modules/foo/index.js'),
'foo in bar'
);
if (requireResolveSupportsPaths) {
if (!requireResolveDefaultPathsBroken && requireResolveSupportsPaths) {
t.equal(
resolve.sync('foo', { basedir: basedir }),
require.resolve('foo', { paths: [basedir] }),
Expand Down Expand Up @@ -125,7 +128,7 @@ test('biz', function (t) {
resolve.sync('tiv', { basedir: tivDir }),
path.join(dir, 'tiv/index.js')
);
if (requireResolveSupportsPaths) {
if (!requireResolveDefaultPathsBroken && requireResolveSupportsPaths) {
t.equal(
resolve.sync('tiv', { basedir: tivDir }),
require.resolve('tiv', { paths: [tivDir] }),
Expand All @@ -138,7 +141,7 @@ test('biz', function (t) {
resolve.sync('grux', { basedir: gruxDir }),
path.join(dir, 'grux/index.js')
);
if (requireResolveSupportsPaths) {
if (!requireResolveDefaultPathsBroken && requireResolveSupportsPaths) {
t.equal(
resolve.sync('grux', { basedir: gruxDir }),
require.resolve('grux', { paths: [gruxDir] }),
Expand Down

0 comments on commit f0930c0

Please sign in to comment.