Skip to content

Commit

Permalink
Mock constants global directory instead
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Apr 23, 2017
1 parent 48e7656 commit d2ce0ad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions __tests__/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ const runGlobal = buildRun.bind(
ConsoleReporter,
fixturesLoc,
(args, flags, config, reporter, _lockfile, _out, homeFolderLocation): CLIFunctionReturn => {
const automock = jest.genMockFromModule('../../src/util/user-home-dir');
jest.setMock('../../src/util/user-home-dir', Object.assign(automock, homeFolderLocation));
const automock = jest.genMockFromModule('../../src/constants');
jest.setMock('../../src/constants', Object.assign(automock, {
GLOBAL_MODULE_DIRECTORY: homeFolderLocation,
}));

jest.resetModules();
jest.mock('../../src/util/user-home-dir');
jest.mock('../../src/constants');

const global = require('../../src/cli/commands/global.js').run;
jest.unmock('../../src/util/user-home-dir');
jest.unmock('../../src/constants');
return global(config, reporter, flags, args);
},
);
Expand Down

0 comments on commit d2ce0ad

Please sign in to comment.