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

ProjectConfig.name to ProjectConfig.id #10592

Closed
wants to merge 9 commits into from
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
8 changes: 4 additions & 4 deletions e2e/__tests__/multiProjectRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ test('resolves projects and their <rootDir> properly', () => {
},
}),
'project1.conf.json': JSON.stringify({
name: 'project1',
id: 'project1',
rootDir: './project1',
// root dir should be this project's directory
setupFiles: ['<rootDir>/project1_setup.js'],
Expand All @@ -357,7 +357,7 @@ test('resolves projects and their <rootDir> properly', () => {
'project1/project1_setup.js': 'global.project1 = true;',
'project2/__tests__/test.test.js': `test('project2', () => expect(global.project2).toBe(true))`,
'project2/project2.conf.json': JSON.stringify({
name: 'project2',
id: 'project2',
rootDir: '../', // root dir is set to the top level
setupFiles: ['<rootDir>/project2/project2_setup.js'], // rootDir shold be of the
testEnvironment: 'node',
Expand Down Expand Up @@ -513,7 +513,7 @@ describe("doesn't bleed module file extensions resolution with multiple workers"

expect(configs).toHaveLength(2);

const [{name: name1}, {name: name2}] = configs;
const [{id: name1}, {id: name2}] = configs;

expect(name1).toEqual(expect.any(String));
expect(name2).toEqual(expect.any(String));
Expand Down Expand Up @@ -556,7 +556,7 @@ describe("doesn't bleed module file extensions resolution with multiple workers"

expect(configs).toHaveLength(2);

const [{name: name1}, {name: name2}] = configs;
const [{id: name1}, {id: name2}] = configs;

expect(name1).toEqual(expect.any(String));
expect(name2).toEqual(expect.any(String));
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/showConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('--showConfig outputs config info and exits', () => {
.replace(/\\\\\.pnp\\\\\.\[\^[/\\]+\]\+\$/g, '<<REPLACED_PNP_PATH>>')
.replace(/\\\\(?:([^.]+?)|$)/g, '/$1')
.replace(/"cacheDirectory": "(.+)"/g, '"cacheDirectory": "/tmp/jest"')
.replace(/"name": "(.+)"/g, '"name": "[md5 hash]"')
.replace(/"id": "(.+)"/g, '"id": "[md5 hash]"')
.replace(/"version": "(.+)"/g, '"version": "[version]"')
.replace(/"maxWorkers": (\d+)/g, '"maxWorkers": "[maxWorkers]"')
.replace(/"\S*show-config-test/gm, '"<<REPLACED_ROOT_DIR>>')
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/ValidConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const initialOptions: Config.InitialOptions = {
platforms: ['ios', 'android'],
throwOnModuleCollision: false,
},
id: 'string',
injectGlobals: true,
json: false,
lastCommit: false,
Expand All @@ -72,7 +73,6 @@ const initialOptions: Config.InitialOptions = {
},
modulePathIgnorePatterns: ['<rootDir>/build/'],
modulePaths: ['/shared/vendor/modules'],
name: 'string',
noStackTrace: false,
notify: false,
notifyMode: 'failure-change',
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ it('picks a name based on the rootDir', () => {
rootDir,
},
{},
).options.name,
).options.id,
).toBe(expected);
});

Expand All @@ -100,11 +100,11 @@ it('keeps custom names based on the rootDir', () => {
expect(
normalize(
{
name: 'custom-name',
id: 'custom-name',
rootDir: '/root/path/foo',
},
{},
).options.name,
).options.id,
).toBe('custom-name');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ const groupOptions = (
globalTeardown: options.globalTeardown,
globals: options.globals,
haste: options.haste,
id: options.id,
injectGlobals: options.injectGlobals,
moduleDirectories: options.moduleDirectories,
moduleFileExtensions: options.moduleFileExtensions,
moduleLoader: options.moduleLoader,
moduleNameMapper: options.moduleNameMapper,
modulePathIgnorePatterns: options.modulePathIgnorePatterns,
modulePaths: options.modulePaths,
name: options.name,
prettierPath: options.prettierPath,
resetMocks: options.resetMocks,
resetModules: options.resetModules,
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-config/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ const normalizeMissingOptions = (
configPath: Config.Path | null | undefined,
projectIndex: number,
): Config.InitialOptionsWithRootDir => {
if (!options.name) {
options.name = createHash('md5')
if (!options.id) {
options.id = createHash('md5')
.update(options.rootDir)
// In case we load config from some path that has the same root dir
.update(configPath || '')
Expand Down Expand Up @@ -891,7 +891,7 @@ export default function normalize(
case 'logHeapUsage':
case 'maxConcurrency':
case 'mapCoverage':
case 'name':
case 'id':
case 'noStackTrace':
case 'notify':
case 'notifyMode':
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-types/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export type InitialOptions = Partial<{
};
modulePathIgnorePatterns: Array<string>;
modulePaths: Array<string>;
name: string;
id: string;
noStackTrace: boolean;
notify: boolean;
notifyMode: string;
Expand Down