From e7daa5cf99a31ebe6223c5aa573e8f6f53f58d41 Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Mon, 30 Nov 2020 19:27:03 +0100 Subject: [PATCH] Fix another Windows test issue This one is a bit tricky. Instead of testing at the root folder of the drive, this test is now relative to the current directory. This resolves the difference between "/pkgs/a" and "d:\pkgs\a" --- .../cli/src/lib/versioning/packages.test.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/lib/versioning/packages.test.ts b/packages/cli/src/lib/versioning/packages.test.ts index 8155d4b5c0..b0f1c46e8a 100644 --- a/packages/cli/src/lib/versioning/packages.test.ts +++ b/packages/cli/src/lib/versioning/packages.test.ts @@ -15,6 +15,7 @@ */ import mockFs from 'mock-fs'; +import path from 'path'; import * as runObj from '../run'; import { paths } from '../paths'; import { fetchPackageInfo, mapDependencies } from './packages'; @@ -54,16 +55,16 @@ describe('mapDependencies', () => { await project.getPackages(); mockFs({ - '/lerna.json': JSON.stringify({ + 'lerna.json': JSON.stringify({ packages: ['pkgs/*'], }), - '/pkgs/a/package.json': JSON.stringify({ + 'pkgs/a/package.json': JSON.stringify({ name: 'a', dependencies: { '@backstage/core': '1 || 2', }, }), - '/pkgs/b/package.json': JSON.stringify({ + 'pkgs/b/package.json': JSON.stringify({ name: 'b', dependencies: { '@backstage/core': '3', @@ -72,9 +73,6 @@ describe('mapDependencies', () => { }), }); - const oldDir = paths.targetDir; - paths.targetDir = '/'; - const dependencyMap = await mapDependencies(paths.targetDir); expect(Array.from(dependencyMap)).toEqual([ [ @@ -83,12 +81,12 @@ describe('mapDependencies', () => { { name: 'a', range: '1 || 2', - location: '/pkgs/a', + location: path.resolve('pkgs', 'a'), }, { name: 'b', range: '3', - location: '/pkgs/b', + location: path.resolve('pkgs', 'b'), }, ], ], @@ -98,12 +96,10 @@ describe('mapDependencies', () => { { name: 'b', range: '^0', - location: '/pkgs/b', + location: path.resolve('pkgs', 'b'), }, ], ], ]); - - paths.targetDir = oldDir; }); });