From 8bfe583dc8e6fa9ad3cb1372750337ae8e3a8d74 Mon Sep 17 00:00:00 2001 From: adrianromanski Date: Sun, 5 Jan 2025 15:01:27 +0100 Subject: [PATCH] tests: change manual NX_CACHE_PROJECT_GRAPH setting to stubEnv --- projects/nx-verdaccio/src/plugin/caching.unit-test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/nx-verdaccio/src/plugin/caching.unit-test.ts b/projects/nx-verdaccio/src/plugin/caching.unit-test.ts index e74ffbd..afb1246 100644 --- a/projects/nx-verdaccio/src/plugin/caching.unit-test.ts +++ b/projects/nx-verdaccio/src/plugin/caching.unit-test.ts @@ -119,7 +119,7 @@ describe('readTargetsCache', (): void => { }); it('should return empty object if NX_CACHE_PROJECT_GRAPH = false', (): void => { - process.env.NX_CACHE_PROJECT_GRAPH = 'false'; + vi.stubEnv('NX_CACHE_PROJECT_GRAPH', 'false'); expect(readTargetsCache(path)).toEqual({}); }); @@ -130,7 +130,7 @@ describe('readTargetsCache', (): void => { it('should return empty object if existsSync returns false, and NX_CACHE_PROJECT_GRAPH = false', (): void => { existsSyncSpy.mockImplementation((): boolean => false); - process.env.NX_CACHE_PROJECT_GRAPH = 'false'; + vi.stubEnv('NX_CACHE_PROJECT_GRAPH', 'false'); expect(readTargetsCache(path)).toEqual({}); }); }); @@ -145,7 +145,7 @@ describe('writeTargetsToCache', (): void => { afterEach((): void => { writeJsonFile.mockRestore(); - delete process.env.NX_CACHE_PROJECT_GRAPH; + vi.clearAllMocks(); }); it('should call writeJsonFile once with correct arguments if process.env.NX_CACHE_PROJECT_GRAPH !== false', (): void => {