From 130c12933082f22c962f7f9c6eec1d9099e0032a Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 22 Jun 2022 07:07:37 -0700 Subject: [PATCH] chore: fix global test fixture for windows --- tap-snapshots/test/lib/commands/query.js.test.cjs | 4 ++-- test/lib/commands/query.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tap-snapshots/test/lib/commands/query.js.test.cjs b/tap-snapshots/test/lib/commands/query.js.test.cjs index ee87fd3b32233..430f7e143a628 100644 --- a/tap-snapshots/test/lib/commands/query.js.test.cjs +++ b/tap-snapshots/test/lib/commands/query.js.test.cjs @@ -13,8 +13,8 @@ exports[`test/lib/commands/query.js TAP global > should return global package 1` "_id": "lorem@2.0.0", "pkgid": "lorem@2.0.0", "location": "node_modules/lorem", - "path": "{CWD}/test/lib/commands/tap-testdir-query-global/global/lib/node_modules/lorem", - "realpath": "{CWD}/test/lib/commands/tap-testdir-query-global/global/lib/node_modules/lorem", + "path": "{CWD}/test/lib/commands/tap-testdir-query-global/global/node_modules/lorem", + "realpath": "{CWD}/test/lib/commands/tap-testdir-query-global/global/node_modules/lorem", "resolved": null, "isLink": false, "isWorkspace": false diff --git a/test/lib/commands/query.js b/test/lib/commands/query.js index d4e98f28c69b3..48b002fedac70 100644 --- a/test/lib/commands/query.js +++ b/test/lib/commands/query.js @@ -7,6 +7,8 @@ t.cleanSnapshot = (str) => { .replace(/\r\n/g, '\n') return normalizePath(str) .replace(new RegExp(normalizePath(process.cwd()), 'g'), '{CWD}') + // normalize between windows and posix + .replace(new RegExp('lib/node_modules', 'g'), 'node_modules') } t.test('simple query', async t => { @@ -101,7 +103,17 @@ t.test('global', async t => { config: { global: true, }, + // This is a global dir that works in both windows and non-windows, that's + // why it has two node_modules folders globalPrefixDir: { + node_modules: { + lorem: { + 'package.json': JSON.stringify({ + name: 'lorem', + version: '2.0.0', + }), + }, + }, lib: { node_modules: { lorem: {