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

Rename ProjectConfig.name to ProjectConfig.id #10051

Closed
wants to merge 3 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
1 change: 0 additions & 1 deletion e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ exports[`--showConfig outputs config info and exits 1`] = `
],
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"name": "[md5 hash]",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should id exist here now that I have renamed name to id?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
Expand Down
16 changes: 0 additions & 16 deletions e2e/__tests__/multiProjectRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,6 @@ describe("doesn't bleed module file extensions resolution with multiple workers"

expect(configs).toHaveLength(2);

const [{name: name1}, {name: name2}] = configs;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep these, but just call them id instead of name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially did this, however id doesn't exist. I'm confused and need some help understanding why id is not present


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);

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

expect(configs).toHaveLength(2);

const [{name: name1}, {name: name2}] = 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);

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

expect(stderr).toMatch('Ran all test suites in 2 projects.');
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',
json: false,
lastCommit: false,
logHeapUsage: true,
Expand All @@ -71,7 +72,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
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 @@ -885,12 +885,12 @@ export default function normalize(
case 'findRelatedTests':
case 'forceCoverageMatch':
case 'forceExit':
case 'id':
case 'lastCommit':
case 'listTests':
case 'logHeapUsage':
case 'maxConcurrency':
case 'mapCoverage':
case 'name':
case 'noStackTrace':
case 'notify':
case 'notifyMode':
Expand Down
38 changes: 19 additions & 19 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 @@ -49,7 +49,7 @@ describe('SearchSource', () => {
beforeEach(() => {
config = normalize(
{
name,
id,
rootDir: '.',
roots: [],
},
Expand All @@ -68,7 +68,7 @@ describe('SearchSource', () => {
if (process.platform !== 'win32') {
config = normalize(
{
name,
id,
rootDir: '.',
roots: [],
testMatch: undefined,
Expand Down Expand Up @@ -117,8 +117,8 @@ describe('SearchSource', () => {
it('finds tests matching a pattern via testRegex', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'txt'],
name,
rootDir,
testMatch: undefined,
testRegex: 'not-really-a-test',
Expand All @@ -141,8 +141,8 @@ describe('SearchSource', () => {
it('finds tests matching a pattern via testMatch', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'txt'],
name,
rootDir,
testMatch: ['**/not-really-a-test.txt', '!**/do-not-match-me.txt'],
testRegex: '',
Expand All @@ -165,8 +165,8 @@ describe('SearchSource', () => {
it('finds tests matching a JS regex pattern', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch: undefined,
testRegex: 'test.jsx?',
Expand All @@ -187,8 +187,8 @@ describe('SearchSource', () => {
it('finds tests matching a JS glob pattern', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch: ['**/test.js?(x)'],
testRegex: '',
Expand All @@ -209,7 +209,7 @@ describe('SearchSource', () => {
it('finds tests with default file extensions using testRegex', () => {
const {options: config} = normalize(
{
name,
id,
rootDir,
testMatch: undefined,
testRegex,
Expand All @@ -230,7 +230,7 @@ describe('SearchSource', () => {
it('finds tests with default file extensions using testMatch', () => {
const {options: config} = normalize(
{
name,
id,
rootDir,
testMatch,
testRegex: '',
Expand All @@ -251,7 +251,7 @@ describe('SearchSource', () => {
it('finds tests with parentheses in their rootDir when using testMatch', () => {
const {options: config} = normalize(
{
name,
id,
rootDir: path.resolve(__dirname, 'test_root_with_(parentheses)'),
testMatch: ['<rootDir>**/__testtests__/**/*'],
testRegex: undefined,
Expand All @@ -271,8 +271,8 @@ describe('SearchSource', () => {
it('finds tests with similar but custom file extensions', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch,
},
Expand All @@ -292,8 +292,8 @@ describe('SearchSource', () => {
it('finds tests with totally custom foobar file extensions', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'foobar'],
name,
rootDir,
testMatch,
},
Expand All @@ -313,8 +313,8 @@ describe('SearchSource', () => {
it('finds tests with many kinds of file extensions', () => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testMatch,
},
Expand All @@ -334,7 +334,7 @@ describe('SearchSource', () => {
it('finds tests using a regex only', () => {
const {options: config} = normalize(
{
name,
id,
rootDir,
testMatch: undefined,
testRegex,
Expand All @@ -355,7 +355,7 @@ describe('SearchSource', () => {
it('finds tests using a glob only', () => {
const {options: config} = normalize(
{
name,
id,
rootDir,
testMatch,
testRegex: '',
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('SearchSource', () => {
'haste_impl.js',
),
},
name: 'SearchSource-findRelatedTests-tests',
id: 'SearchSource-findRelatedTests-tests',
rootDir,
},
{} as Config.Argv,
Expand Down Expand Up @@ -454,8 +454,8 @@ describe('SearchSource', () => {
beforeEach(done => {
const {options: config} = normalize(
{
id,
moduleFileExtensions: ['js', 'jsx', 'foobar'],
name,
rootDir,
testMatch,
},
Expand Down Expand Up @@ -513,7 +513,7 @@ describe('SearchSource', () => {
if (process.platform !== 'win32') {
const config = normalize(
{
name,
id,
rootDir: '.',
roots: ['/foo/bar/prefix'],
},
Expand Down Expand Up @@ -546,7 +546,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
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/__mocks__/createRuntime.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = async function createRuntime(filename, config) {
'haste_impl.js',
),
},
name: 'Runtime-' + filename.replace(/\W/, '-') + '.tests',
id: 'Runtime-' + filename.replace(/\W/, '-') + '.tests',
rootDir: path.resolve(path.dirname(filename), 'test_root'),
...config,
},
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 @@ -146,7 +146,7 @@ export type InitialOptions = Partial<{
};
modulePathIgnorePatterns: Array<string>;
modulePaths: Array<string>;
name: string;
id: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort it alphabetically

noStackTrace: boolean;
notify: boolean;
notifyMode: string;
Expand Down