Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user home config conflicting with the test suite #2725

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion __tests__/commands/_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export async function run<T, R>(
await fs.mkdirp(path.join(cwd, '.yarn-link'));
await fs.mkdirp(path.join(cwd, '.yarn-cache'));
await fs.mkdirp(path.join(cwd, 'node_modules'));
await fs.mkdirp(path.join(cwd, '.yarn-home'));

// make sure the cache folder been created in temp folder
if (flags.cacheFolder) {
Expand All @@ -128,7 +129,7 @@ export async function run<T, R>(
production: flags.production,
}, reporter);

const install = await factory(args, flags, config, reporter, lockfile, () => out);
const install = await factory(args, flags, config, reporter, lockfile, () => out, path.join(cwd, '.yarn-home'));

if (checkInstalled) {
await checkInstalled(config, reporter, install);
Expand Down
13 changes: 11 additions & 2 deletions __tests__/commands/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import type {CLIFunctionReturn} from '../../src/types.js';
import {ConsoleReporter} from '../../src/reporters/index.js';
import {run as buildRun} from './_helpers.js';
import {run as global} from '../../src/cli/commands/global.js';
import * as fs from '../../src/util/fs.js';
const isCI = require('is-ci');

Expand All @@ -17,7 +16,17 @@ const runGlobal = buildRun.bind(
null,
ConsoleReporter,
fixturesLoc,
(args, flags, config, reporter): CLIFunctionReturn => {
(args, flags, config, reporter, _lockfile, _out, homeFolderLocation): CLIFunctionReturn => {
const automock = jest.genMockFromModule('../../src/constants');
jest.setMock('../../src/constants', Object.assign(automock, {
GLOBAL_MODULE_DIRECTORY: homeFolderLocation,
}));

jest.resetModules();
jest.mock('../../src/constants');

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