Skip to content

Commit cc3c296

Browse files
author
Udit Takkar
committed
fix:rename projectConfig.name to projectConfig.id
1 parent 3f54dd0 commit cc3c296

File tree

23 files changed

+77
-77
lines changed

23 files changed

+77
-77
lines changed

e2e/__tests__/__snapshots__/showConfig.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
3939
],
4040
"moduleNameMapper": [],
4141
"modulePathIgnorePatterns": [],
42-
"name": "[md5 hash]",
42+
"id": "[md5 hash]",
4343
"prettierPath": "prettier",
4444
"resetMocks": false,
4545
"resetModules": false,

e2e/__tests__/multiProjectRunner.test.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ test('resolves projects and their <rootDir> properly', () => {
347347
},
348348
}),
349349
'project1.conf.json': JSON.stringify({
350-
name: 'project1',
350+
id: 'project1',
351351
rootDir: './project1',
352352
// root dir should be this project's directory
353353
setupFiles: ['<rootDir>/project1_setup.js'],
@@ -357,7 +357,7 @@ test('resolves projects and their <rootDir> properly', () => {
357357
'project1/project1_setup.js': 'global.project1 = true;',
358358
'project2/__tests__/test.test.js': `test('project2', () => expect(global.project2).toBe(true))`,
359359
'project2/project2.conf.json': JSON.stringify({
360-
name: 'project2',
360+
id: 'project2',
361361
rootDir: '../', // root dir is set to the top level
362362
setupFiles: ['<rootDir>/project2/project2_setup.js'], // rootDir shold be of the
363363
testEnvironment: 'node',
@@ -513,13 +513,13 @@ describe("doesn't bleed module file extensions resolution with multiple workers"
513513

514514
expect(configs).toHaveLength(2);
515515

516-
const [{name: name1}, {name: name2}] = configs;
516+
const [{id: id1}, {id: id2}] = configs;
517517

518-
expect(name1).toEqual(expect.any(String));
519-
expect(name2).toEqual(expect.any(String));
520-
expect(name1).toHaveLength(32);
521-
expect(name2).toHaveLength(32);
522-
expect(name1).not.toEqual(name2);
518+
expect(id1).toEqual(expect.any(String));
519+
expect(id2).toEqual(expect.any(String));
520+
expect(id1).toHaveLength(32);
521+
expect(id2).toHaveLength(32);
522+
expect(id1).not.toEqual(id2);
523523

524524
const {stderr} = runJest(DIR, [
525525
'--no-watchman',
@@ -556,13 +556,13 @@ describe("doesn't bleed module file extensions resolution with multiple workers"
556556

557557
expect(configs).toHaveLength(2);
558558

559-
const [{name: name1}, {name: name2}] = configs;
559+
const [{id: id1}, {id: id2}] = configs;
560560

561-
expect(name1).toEqual(expect.any(String));
562-
expect(name2).toEqual(expect.any(String));
563-
expect(name1).toHaveLength(32);
564-
expect(name2).toHaveLength(32);
565-
expect(name1).not.toEqual(name2);
561+
expect(id1).toEqual(expect.any(String));
562+
expect(id2).toEqual(expect.any(String));
563+
expect(id1).toHaveLength(32);
564+
expect(id2).toHaveLength(32);
565+
expect(id1).not.toEqual(id2);
566566

567567
const {stderr} = runJest(DIR, ['--no-watchman', '-w=2']);
568568

e2e/__tests__/showConfig.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test('--showConfig outputs config info and exits', () => {
3434
.replace(/\\\\\.pnp\\\\\.\[\^[/\\]+\]\+\$/g, '<<REPLACED_PNP_PATH>>')
3535
.replace(/\\\\(?:([^.]+?)|$)/g, '/$1')
3636
.replace(/"cacheDirectory": "(.+)"/g, '"cacheDirectory": "/tmp/jest"')
37-
.replace(/"name": "(.+)"/g, '"name": "[md5 hash]"')
37+
.replace(/"id": "(.+)"/g, '"id": "[md5 hash]"')
3838
.replace(/"version": "(.+)"/g, '"version": "[version]"')
3939
.replace(/"maxWorkers": (\d+)/g, '"maxWorkers": "[maxWorkers]"')
4040
.replace(/"\S*show-config-test/gm, '"<<REPLACED_ROOT_DIR>>')

packages/jest-config/src/ValidConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const initialOptions: Config.InitialOptions = {
6666
platforms: ['ios', 'android'],
6767
throwOnModuleCollision: false,
6868
},
69+
id: 'string',
6970
injectGlobals: true,
7071
json: false,
7172
lastCommit: false,
@@ -81,7 +82,6 @@ const initialOptions: Config.InitialOptions = {
8182
},
8283
modulePathIgnorePatterns: ['<rootDir>/build/'],
8384
modulePaths: ['/shared/vendor/modules'],
84-
name: 'string',
8585
noStackTrace: false,
8686
notify: false,
8787
notifyMode: 'failure-change',

packages/jest-config/src/__tests__/normalize.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ afterEach(() => {
6868
(console.warn as unknown as jest.SpyInstance).mockRestore();
6969
});
7070

71-
it('picks a name based on the rootDir', async () => {
71+
it('picks an id based on the rootDir', async () => {
7272
const rootDir = '/root/path/foo';
7373
const expected = createHash('md5')
7474
.update('/root/path/foo')
@@ -80,32 +80,32 @@ it('picks a name based on the rootDir', async () => {
8080
},
8181
{} as Config.Argv,
8282
);
83-
expect(options.name).toBe(expected);
83+
expect(options.id).toBe(expected);
8484
});
8585

86-
it('keeps custom project name based on the projects rootDir', async () => {
87-
const name = 'test';
86+
it('keeps custom project id based on the projects rootDir', async () => {
87+
const id = 'test';
8888
const {options} = await normalize(
8989
{
90-
projects: [{name, rootDir: '/path/to/foo'}],
90+
projects: [{id, rootDir: '/path/to/foo'}],
9191
rootDir: '/root/path/baz',
9292
},
9393
{} as Config.Argv,
9494
);
9595

96-
expect(options.projects[0].name).toBe(name);
96+
expect(options.projects[0].id).toBe(id);
9797
});
9898

99-
it('keeps custom names based on the rootDir', async () => {
99+
it('keeps custom ids based on the rootDir', async () => {
100100
const {options} = await normalize(
101101
{
102-
name: 'custom-name',
102+
id: 'custom-id',
103103
rootDir: '/root/path/foo',
104104
},
105105
{} as Config.Argv,
106106
);
107107

108-
expect(options.name).toBe('custom-name');
108+
expect(options.id).toBe('custom-id');
109109
});
110110

111111
it('minimal config is stable across runs', async () => {

packages/jest-config/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ const groupOptions = (
193193
globalTeardown: options.globalTeardown,
194194
globals: options.globals,
195195
haste: options.haste,
196+
id: options.id,
196197
injectGlobals: options.injectGlobals,
197198
moduleDirectories: options.moduleDirectories,
198199
moduleFileExtensions: options.moduleFileExtensions,
199200
moduleLoader: options.moduleLoader,
200201
moduleNameMapper: options.moduleNameMapper,
201202
modulePathIgnorePatterns: options.modulePathIgnorePatterns,
202203
modulePaths: options.modulePaths,
203-
name: options.name,
204204
prettierPath: options.prettierPath,
205205
resetMocks: options.resetMocks,
206206
resetModules: options.resetModules,

packages/jest-config/src/normalize.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ const normalizeMissingOptions = (
369369
configPath: Config.Path | null | undefined,
370370
projectIndex: number,
371371
): Config.InitialOptionsWithRootDir => {
372-
if (!options.name) {
373-
options.name = createHash('md5')
372+
if (!options.id) {
373+
options.id = createHash('md5')
374374
.update(options.rootDir)
375375
// In case we load config from some path that has the same root dir
376376
.update(configPath || '')
@@ -978,7 +978,7 @@ export default async function normalize(
978978
case 'listTests':
979979
case 'logHeapUsage':
980980
case 'maxConcurrency':
981-
case 'name':
981+
case 'id':
982982
case 'noStackTrace':
983983
case 'notify':
984984
case 'notifyMode':

packages/jest-core/src/__tests__/SearchSource.test.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const toPaths = (tests: Array<Test>) => tests.map(({path}) => path);
4040
let findMatchingTests: (config: Config.ProjectConfig) => Promise<SearchResult>;
4141

4242
describe('SearchSource', () => {
43-
const name = 'SearchSource';
43+
const id = 'SearchSource';
4444
let searchSource: SearchSource;
4545

4646
describe('isTestFilePath', () => {
@@ -50,7 +50,7 @@ describe('SearchSource', () => {
5050
config = (
5151
await normalize(
5252
{
53-
name,
53+
id,
5454
rootDir: '.',
5555
roots: [],
5656
},
@@ -71,7 +71,7 @@ describe('SearchSource', () => {
7171
config = (
7272
await normalize(
7373
{
74-
name,
74+
id,
7575
rootDir: '.',
7676
roots: [],
7777
testMatch: undefined,
@@ -121,8 +121,8 @@ describe('SearchSource', () => {
121121
it('finds tests matching a pattern via testRegex', async () => {
122122
const {options: config} = await normalize(
123123
{
124+
id,
124125
moduleFileExtensions: ['js', 'jsx', 'txt'],
125-
name,
126126
rootDir,
127127
testMatch: undefined,
128128
testRegex: 'not-really-a-test',
@@ -145,8 +145,8 @@ describe('SearchSource', () => {
145145
it('finds tests matching a pattern via testMatch', async () => {
146146
const {options: config} = await normalize(
147147
{
148+
id,
148149
moduleFileExtensions: ['js', 'jsx', 'txt'],
149-
name,
150150
rootDir,
151151
testMatch: ['**/not-really-a-test.txt', '!**/do-not-match-me.txt'],
152152
testRegex: '',
@@ -169,8 +169,8 @@ describe('SearchSource', () => {
169169
it('finds tests matching a JS regex pattern', async () => {
170170
const {options: config} = await normalize(
171171
{
172+
id,
172173
moduleFileExtensions: ['js', 'jsx'],
173-
name,
174174
rootDir,
175175
testMatch: undefined,
176176
testRegex: 'test.jsx?',
@@ -191,8 +191,8 @@ describe('SearchSource', () => {
191191
it('finds tests matching a JS glob pattern', async () => {
192192
const {options: config} = await normalize(
193193
{
194+
id,
194195
moduleFileExtensions: ['js', 'jsx'],
195-
name,
196196
rootDir,
197197
testMatch: ['**/test.js?(x)'],
198198
testRegex: '',
@@ -213,8 +213,8 @@ describe('SearchSource', () => {
213213
it('finds tests matching a JS with overriding glob patterns', async () => {
214214
const {options: config} = await normalize(
215215
{
216+
id,
216217
moduleFileExtensions: ['js', 'jsx'],
217-
name,
218218
rootDir,
219219
testMatch: [
220220
'**/*.js?(x)',
@@ -241,7 +241,7 @@ describe('SearchSource', () => {
241241
it('finds tests with default file extensions using testRegex', async () => {
242242
const {options: config} = await normalize(
243243
{
244-
name,
244+
id,
245245
rootDir,
246246
testMatch: undefined,
247247
testRegex,
@@ -262,7 +262,7 @@ describe('SearchSource', () => {
262262
it('finds tests with default file extensions using testMatch', async () => {
263263
const {options: config} = await normalize(
264264
{
265-
name,
265+
id,
266266
rootDir,
267267
testMatch,
268268
testRegex: '',
@@ -283,7 +283,7 @@ describe('SearchSource', () => {
283283
it('finds tests with parentheses in their rootDir when using testMatch', async () => {
284284
const {options: config} = await normalize(
285285
{
286-
name,
286+
id,
287287
rootDir: path.resolve(__dirname, 'test_root_with_(parentheses)'),
288288
testMatch: ['<rootDir>**/__testtests__/**/*'],
289289
testRegex: undefined,
@@ -303,8 +303,8 @@ describe('SearchSource', () => {
303303
it('finds tests with similar but custom file extensions', async () => {
304304
const {options: config} = await normalize(
305305
{
306+
id,
306307
moduleFileExtensions: ['js', 'jsx'],
307-
name,
308308
rootDir,
309309
testMatch,
310310
},
@@ -324,8 +324,8 @@ describe('SearchSource', () => {
324324
it('finds tests with totally custom foobar file extensions', async () => {
325325
const {options: config} = await normalize(
326326
{
327+
id,
327328
moduleFileExtensions: ['js', 'foobar'],
328-
name,
329329
rootDir,
330330
testMatch,
331331
},
@@ -345,8 +345,8 @@ describe('SearchSource', () => {
345345
it('finds tests with many kinds of file extensions', async () => {
346346
const {options: config} = await normalize(
347347
{
348+
id,
348349
moduleFileExtensions: ['js', 'jsx'],
349-
name,
350350
rootDir,
351351
testMatch,
352352
},
@@ -366,7 +366,7 @@ describe('SearchSource', () => {
366366
it('finds tests using a regex only', async () => {
367367
const {options: config} = await normalize(
368368
{
369-
name,
369+
id,
370370
rootDir,
371371
testMatch: undefined,
372372
testRegex,
@@ -387,7 +387,7 @@ describe('SearchSource', () => {
387387
it('finds tests using a glob only', async () => {
388388
const {options: config} = await normalize(
389389
{
390-
name,
390+
id,
391391
rootDir,
392392
testMatch,
393393
testRegex: '',
@@ -411,7 +411,7 @@ describe('SearchSource', () => {
411411
const config = (
412412
await normalize(
413413
{
414-
name,
414+
id,
415415
rootDir: '.',
416416
roots: [],
417417
},
@@ -509,7 +509,7 @@ describe('SearchSource', () => {
509509
'haste_impl.js',
510510
),
511511
},
512-
name: 'SearchSource-findRelatedTests-tests',
512+
id: 'SearchSource-findRelatedTests-tests',
513513
rootDir,
514514
},
515515
{} as Config.Argv,
@@ -564,8 +564,8 @@ describe('SearchSource', () => {
564564
beforeEach(async () => {
565565
const {options: config} = await normalize(
566566
{
567+
id,
567568
moduleFileExtensions: ['js', 'jsx', 'foobar'],
568-
name,
569569
rootDir,
570570
testMatch,
571571
},
@@ -623,7 +623,7 @@ describe('SearchSource', () => {
623623
const config = (
624624
await normalize(
625625
{
626-
name,
626+
id,
627627
rootDir: '.',
628628
roots: ['/foo/bar/prefix'],
629629
},
@@ -657,7 +657,7 @@ describe('SearchSource', () => {
657657
'../../../jest-haste-map/src/__tests__/haste_impl.js',
658658
),
659659
},
660-
name: 'SearchSource-findRelatedSourcesFromTestsInChangedFiles-tests',
660+
id: 'SearchSource-findRelatedSourcesFromTestsInChangedFiles-tests',
661661
rootDir,
662662
},
663663
{} as Config.Argv,

packages/jest-core/src/lib/__tests__/__snapshots__/logDebugMessages.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exports[`prints the config object 1`] = `
2626
"moduleNameMapper": [],
2727
"modulePathIgnorePatterns": [],
2828
"modulePaths": [],
29-
"name": "test_name",
29+
"id": "test_name",
3030
"prettierPath": "prettier",
3131
"resetMocks": false,
3232
"resetModules": false,

packages/jest-haste-map/src/__tests__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ describe('HasteMap', () => {
207207
defaultConfig = {
208208
extensions: ['js', 'json'],
209209
hasteImplModulePath: require.resolve('./haste_impl.js'),
210+
id: 'haste-map-test',
210211
maxWorkers: 1,
211-
name: 'haste-map-test',
212212
platforms: ['ios', 'android'],
213213
resetCache: false,
214214
rootDir: path.join('/', 'project'),

0 commit comments

Comments
 (0)