Skip to content

Commit

Permalink
fix:rename projectConfig.name to projectConfig.id
Browse files Browse the repository at this point in the history
  • Loading branch information
Udit Takkar committed Oct 19, 2021
1 parent e7edb75 commit 7805e40
Show file tree
Hide file tree
Showing 23 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
],
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"name": "[md5 hash]",
"id": "[md5 hash]",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
Expand Down
28 changes: 14 additions & 14 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,13 +513,13 @@ describe("doesn't bleed module file extensions resolution with multiple workers"

expect(configs).toHaveLength(2);

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

expect(name1).toEqual(expect.any(String));
expect(name2).toEqual(expect.any(String));
expect(name1).toHaveLength(32);
expect(name2).toHaveLength(32);
expect(name1).not.toEqual(name2);
expect(id1).toEqual(expect.any(String));
expect(id2).toEqual(expect.any(String));
expect(id1).toHaveLength(32);
expect(id2).toHaveLength(32);
expect(id1).not.toEqual(id2);

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

expect(configs).toHaveLength(2);

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

expect(name1).toEqual(expect.any(String));
expect(name2).toEqual(expect.any(String));
expect(name1).toHaveLength(32);
expect(name2).toHaveLength(32);
expect(name1).not.toEqual(name2);
expect(id1).toEqual(expect.any(String));
expect(id2).toEqual(expect.any(String));
expect(id1).toHaveLength(32);
expect(id2).toHaveLength(32);
expect(id1).not.toEqual(id2);

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

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 @@ -66,6 +66,7 @@ const initialOptions: Config.InitialOptions = {
platforms: ['ios', 'android'],
throwOnModuleCollision: false,
},
id: 'string',
injectGlobals: true,
json: false,
lastCommit: false,
Expand All @@ -81,7 +82,6 @@ const initialOptions: Config.InitialOptions = {
},
modulePathIgnorePatterns: ['<rootDir>/build/'],
modulePaths: ['/shared/vendor/modules'],
name: 'string',
noStackTrace: false,
notify: false,
notifyMode: 'failure-change',
Expand Down
18 changes: 9 additions & 9 deletions packages/jest-config/src/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ afterEach(() => {
(console.warn as unknown as jest.SpyInstance).mockRestore();
});

it('picks a name based on the rootDir', async () => {
it('picks an id based on the rootDir', async () => {
const rootDir = '/root/path/foo';
const expected = createHash('md5')
.update('/root/path/foo')
Expand All @@ -80,32 +80,32 @@ it('picks a name based on the rootDir', async () => {
},
{} as Config.Argv,
);
expect(options.name).toBe(expected);
expect(options.id).toBe(expected);
});

it('keeps custom project name based on the projects rootDir', async () => {
const name = 'test';
it('keeps custom project id based on the projects rootDir', async () => {
const id = 'test';
const {options} = await normalize(
{
projects: [{name, rootDir: '/path/to/foo'}],
projects: [{id, rootDir: '/path/to/foo'}],
rootDir: '/root/path/baz',
},
{} as Config.Argv,
);

expect(options.projects[0].name).toBe(name);
expect(options.projects[0].id).toBe(id);
});

it('keeps custom names based on the rootDir', async () => {
it('keeps custom ids based on the rootDir', async () => {
const {options} = await normalize(
{
name: 'custom-name',
id: 'custom-id',
rootDir: '/root/path/foo',
},
{} as Config.Argv,
);

expect(options.name).toBe('custom-name');
expect(options.id).toBe('custom-id');
});

it('minimal config is stable across runs', async () => {
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 @@ -193,14 +193,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 @@ -369,8 +369,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 @@ -978,7 +978,7 @@ export default async function normalize(
case 'listTests':
case 'logHeapUsage':
case 'maxConcurrency':
case 'name':
case 'id':
case 'noStackTrace':
case 'notify':
case 'notifyMode':
Expand Down
42 changes: 21 additions & 21 deletions packages/jest-core/src/__tests__/SearchSource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const toPaths = (tests: Array<Test>) => tests.map(({path}) => path);
let findMatchingTests: (config: Config.ProjectConfig) => Promise<SearchResult>;

describe('SearchSource', () => {
const name = 'SearchSource';
const id = 'SearchSource';
let searchSource: SearchSource;

describe('isTestFilePath', () => {
Expand All @@ -50,7 +50,7 @@ describe('SearchSource', () => {
config = (
await normalize(
{
name,
id,
rootDir: '.',
roots: [],
},
Expand All @@ -71,7 +71,7 @@ describe('SearchSource', () => {
config = (
await normalize(
{
name,
id,
rootDir: '.',
roots: [],
testMatch: undefined,
Expand Down Expand Up @@ -121,8 +121,8 @@ describe('SearchSource', () => {
it('finds tests matching a pattern via testRegex', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'txt'],
name,
rootDir,
testMatch: undefined,
testRegex: 'not-really-a-test',
Expand All @@ -145,8 +145,8 @@ describe('SearchSource', () => {
it('finds tests matching a pattern via testMatch', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'txt'],
name,
rootDir,
testMatch: ['**/not-really-a-test.txt', '!**/do-not-match-me.txt'],
testRegex: '',
Expand All @@ -169,8 +169,8 @@ describe('SearchSource', () => {
it('finds tests matching a JS regex pattern', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch: undefined,
testRegex: 'test.jsx?',
Expand All @@ -191,8 +191,8 @@ describe('SearchSource', () => {
it('finds tests matching a JS glob pattern', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch: ['**/test.js?(x)'],
testRegex: '',
Expand All @@ -213,8 +213,8 @@ describe('SearchSource', () => {
it('finds tests matching a JS with overriding glob patterns', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch: [
'**/*.js?(x)',
Expand All @@ -241,7 +241,7 @@ describe('SearchSource', () => {
it('finds tests with default file extensions using testRegex', async () => {
const {options: config} = await normalize(
{
name,
id,
rootDir,
testMatch: undefined,
testRegex,
Expand All @@ -262,7 +262,7 @@ describe('SearchSource', () => {
it('finds tests with default file extensions using testMatch', async () => {
const {options: config} = await normalize(
{
name,
id,
rootDir,
testMatch,
testRegex: '',
Expand All @@ -283,7 +283,7 @@ describe('SearchSource', () => {
it('finds tests with parentheses in their rootDir when using testMatch', async () => {
const {options: config} = await normalize(
{
name,
id,
rootDir: path.resolve(__dirname, 'test_root_with_(parentheses)'),
testMatch: ['<rootDir>**/__testtests__/**/*'],
testRegex: undefined,
Expand All @@ -303,8 +303,8 @@ describe('SearchSource', () => {
it('finds tests with similar but custom file extensions', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch,
},
Expand All @@ -324,8 +324,8 @@ describe('SearchSource', () => {
it('finds tests with totally custom foobar file extensions', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'foobar'],
name,
rootDir,
testMatch,
},
Expand All @@ -345,8 +345,8 @@ describe('SearchSource', () => {
it('finds tests with many kinds of file extensions', async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch,
},
Expand All @@ -366,7 +366,7 @@ describe('SearchSource', () => {
it('finds tests using a regex only', async () => {
const {options: config} = await normalize(
{
name,
id,
rootDir,
testMatch: undefined,
testRegex,
Expand All @@ -387,7 +387,7 @@ describe('SearchSource', () => {
it('finds tests using a glob only', async () => {
const {options: config} = await normalize(
{
name,
id,
rootDir,
testMatch,
testRegex: '',
Expand All @@ -411,7 +411,7 @@ describe('SearchSource', () => {
const config = (
await normalize(
{
name,
id,
rootDir: '.',
roots: [],
},
Expand Down Expand Up @@ -509,7 +509,7 @@ describe('SearchSource', () => {
'haste_impl.js',
),
},
name: 'SearchSource-findRelatedTests-tests',
id: 'SearchSource-findRelatedTests-tests',
rootDir,
},
{} as Config.Argv,
Expand Down Expand Up @@ -564,8 +564,8 @@ describe('SearchSource', () => {
beforeEach(async () => {
const {options: config} = await normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'foobar'],
name,
rootDir,
testMatch,
},
Expand Down Expand Up @@ -623,7 +623,7 @@ describe('SearchSource', () => {
const config = (
await normalize(
{
name,
id,
rootDir: '.',
roots: ['/foo/bar/prefix'],
},
Expand Down Expand Up @@ -657,7 +657,7 @@ describe('SearchSource', () => {
'../../../jest-haste-map/src/__tests__/haste_impl.js',
),
},
name: 'SearchSource-findRelatedSourcesFromTestsInChangedFiles-tests',
id: 'SearchSource-findRelatedSourcesFromTestsInChangedFiles-tests',
rootDir,
},
{} as Config.Argv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`prints the config object 1`] = `
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"modulePaths": [],
"name": "test_name",
"id": "test_name",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ describe('HasteMap', () => {
defaultConfig = {
extensions: ['js', 'json'],
hasteImplModulePath: require.resolve('./haste_impl.js'),
id: 'haste-map-test',
maxWorkers: 1,
name: 'haste-map-test',
platforms: ['ios', 'android'],
resetCache: false,
rootDir: path.join('/', 'project'),
Expand Down
Loading

0 comments on commit 7805e40

Please sign in to comment.