Skip to content

Commit

Permalink
tests: use stubEnv instead of manual NX_CACHE_PROJECT_GRAPH setting
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianRomanski committed Jan 3, 2025
1 parent 138d786 commit 207eafd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/nx-verdaccio/src/plugin/caching.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ describe('writeTargetsToCache', (): void => {
});

it('should call writeJsonFile once with correct arguments if process.env.NX_CACHE_PROJECT_GRAPH !== false', (): void => {
process.env.NX_CACHE_PROJECT_GRAPH = 'true';
vi.stubEnv('NX_CACHE_PROJECT_GRAPH', 'true');
writeTargetsToCache(path, MOCK_TARGETS_CACHE);
expect(writeJsonFile).toHaveBeenCalledTimes(1);
expect(writeJsonFile).toHaveBeenCalledWith(path, MOCK_TARGETS_CACHE);
});

it('should not call writeJsonFile if process.env.NX_CACHE_PROJECT_GRAPH == false', (): void => {
process.env.NX_CACHE_PROJECT_GRAPH = 'false';
vi.stubEnv('NX_CACHE_PROJECT_GRAPH', 'false');
writeTargetsToCache(path, MOCK_TARGETS_CACHE);
expect(writeJsonFile).toHaveBeenCalledTimes(0);
});
Expand Down

0 comments on commit 207eafd

Please sign in to comment.