From 4585f6445bab6431d5a26b7311373cdc48460bfa Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 25 Oct 2020 12:26:38 +0530 Subject: [PATCH 1/2] chore(jest-cli): standardize files and folder names --- ...ts.snap => modifyPackageJson.test.ts.snap} | 0 .../jest.config.cjs | 0 .../package.json | 0 .../jest.config.js | 0 .../package.json | 0 .../jest.config.json | 0 .../package.json | 0 .../jest.config.mjs | 0 .../package.json | 0 .../jest.config.ts | 0 .../package.json | 0 .../package.json | 0 .../index.js | 0 .../package.json | 0 .../package.json | 0 .../package.json | 0 .../{type_module => type-module}/package.json | 0 .../package.json | 0 .../package.json | 0 .../jest-cli/src/init/__tests__/init.test.js | 32 +++++++++---------- ...json.test.ts => modifyPackageJson.test.ts} | 2 +- ...e_config_file.ts => generateConfigFile.ts} | 0 packages/jest-cli/src/init/index.ts | 4 +-- ...y_package_json.ts => modifyPackageJson.ts} | 0 24 files changed, 19 insertions(+), 19 deletions(-) rename packages/jest-cli/src/init/__tests__/__snapshots__/{modify_package_json.test.ts.snap => modifyPackageJson.test.ts.snap} (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_cjs => has-jest-config-file-cjs}/jest.config.cjs (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_cjs => has-jest-config-file-cjs}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_js => has-jest-config-file-js}/jest.config.js (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_js => has-jest-config-file-js}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_json => has-jest-config-file-json}/jest.config.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_json => has-jest-config-file-json}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_mjs => has-jest-config-file-mjs}/jest.config.mjs (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_mjs => has-jest-config-file-mjs}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_ts => has-jest-config-file-ts}/jest.config.ts (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_file_ts => has-jest-config-file-ts}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{has_jest_config_in_package_json => has-jest-config-in-package-json}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{no_package_json => no-package-json}/index.js (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{only_package_json => only-package-json}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{test_generated_jest_config_ts => test-generated-jest-config-ts}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{test_script_configured => test-script-configured}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{type_module => type-module}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{typescript_in_dependencies => typescript-in-dependencies}/package.json (100%) rename packages/jest-cli/src/init/__tests__/fixtures/{typescript_in_dev_dependencies => typescript-in-dev-dependencies}/package.json (100%) rename packages/jest-cli/src/init/__tests__/{modify_package_json.test.ts => modifyPackageJson.test.ts} (95%) rename packages/jest-cli/src/init/{generate_config_file.ts => generateConfigFile.ts} (100%) rename packages/jest-cli/src/init/{modify_package_json.ts => modifyPackageJson.ts} (100%) diff --git a/packages/jest-cli/src/init/__tests__/__snapshots__/modify_package_json.test.ts.snap b/packages/jest-cli/src/init/__tests__/__snapshots__/modifyPackageJson.test.ts.snap similarity index 100% rename from packages/jest-cli/src/init/__tests__/__snapshots__/modify_package_json.test.ts.snap rename to packages/jest-cli/src/init/__tests__/__snapshots__/modifyPackageJson.test.ts.snap diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_cjs/jest.config.cjs b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-cjs/jest.config.cjs similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_cjs/jest.config.cjs rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-cjs/jest.config.cjs diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_cjs/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-cjs/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_cjs/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-cjs/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_js/jest.config.js b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-js/jest.config.js similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_js/jest.config.js rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-js/jest.config.js diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_js/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-js/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_js/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-js/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_json/jest.config.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-json/jest.config.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_json/jest.config.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-json/jest.config.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_json/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-json/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_json/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-json/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_mjs/jest.config.mjs b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-mjs/jest.config.mjs similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_mjs/jest.config.mjs rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-mjs/jest.config.mjs diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_mjs/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-mjs/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_mjs/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-mjs/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/jest.config.ts b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-ts/jest.config.ts similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/jest.config.ts rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-ts/jest.config.ts diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-ts/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_file_ts/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-file-ts/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_in_package_json/package.json b/packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-in-package-json/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/has_jest_config_in_package_json/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/has-jest-config-in-package-json/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/no_package_json/index.js b/packages/jest-cli/src/init/__tests__/fixtures/no-package-json/index.js similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/no_package_json/index.js rename to packages/jest-cli/src/init/__tests__/fixtures/no-package-json/index.js diff --git a/packages/jest-cli/src/init/__tests__/fixtures/only_package_json/package.json b/packages/jest-cli/src/init/__tests__/fixtures/only-package-json/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/only_package_json/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/only-package-json/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/test_generated_jest_config_ts/package.json b/packages/jest-cli/src/init/__tests__/fixtures/test-generated-jest-config-ts/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/test_generated_jest_config_ts/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/test-generated-jest-config-ts/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/test_script_configured/package.json b/packages/jest-cli/src/init/__tests__/fixtures/test-script-configured/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/test_script_configured/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/test-script-configured/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/type_module/package.json b/packages/jest-cli/src/init/__tests__/fixtures/type-module/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/type_module/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/type-module/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/typescript_in_dependencies/package.json b/packages/jest-cli/src/init/__tests__/fixtures/typescript-in-dependencies/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/typescript_in_dependencies/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/typescript-in-dependencies/package.json diff --git a/packages/jest-cli/src/init/__tests__/fixtures/typescript_in_dev_dependencies/package.json b/packages/jest-cli/src/init/__tests__/fixtures/typescript-in-dev-dependencies/package.json similarity index 100% rename from packages/jest-cli/src/init/__tests__/fixtures/typescript_in_dev_dependencies/package.json rename to packages/jest-cli/src/init/__tests__/fixtures/typescript-in-dev-dependencies/package.json diff --git a/packages/jest-cli/src/init/__tests__/init.test.js b/packages/jest-cli/src/init/__tests__/init.test.js index d8d820393c51..81d0ca0bbd5f 100644 --- a/packages/jest-cli/src/init/__tests__/init.test.js +++ b/packages/jest-cli/src/init/__tests__/init.test.js @@ -44,7 +44,7 @@ describe('init', () => { it('should return the default configuration (an empty config)', async () => { prompts.mockReturnValueOnce({}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; @@ -58,7 +58,7 @@ describe('init', () => { it('should generate empty config with mjs extension', async () => { prompts.mockReturnValueOnce({}); - await init(resolveFromFixture('type_module')); + await init(resolveFromFixture('type-module')); const writtenJestConfigFilename = fs.writeFileSync.mock.calls[0][0]; const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; @@ -74,7 +74,7 @@ describe('init', () => { it('should create configuration for {clearMocks: true}', async () => { prompts.mockReturnValueOnce({clearMocks: true}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -85,7 +85,7 @@ describe('init', () => { it('should create configuration for {coverage: true}', async () => { prompts.mockReturnValueOnce({coverage: true}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -96,7 +96,7 @@ describe('init', () => { it('should create configuration for {coverageProvider: "babel"}', async () => { prompts.mockReturnValueOnce({coverageProvider: 'babel'}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -107,7 +107,7 @@ describe('init', () => { it('should create configuration for {coverageProvider: "v8"}', async () => { prompts.mockReturnValueOnce({coverageProvider: 'v8'}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -118,7 +118,7 @@ describe('init', () => { it('should create configuration for {environment: "jsdom"}', async () => { prompts.mockReturnValueOnce({environment: 'jsdom'}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -129,7 +129,7 @@ describe('init', () => { it('should create configuration for {environment: "node"}', async () => { prompts.mockReturnValueOnce({environment: 'node'}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenJestConfig = fs.writeFileSync.mock.calls[0][1]; const evaluatedConfig = eval(writtenJestConfig); @@ -140,7 +140,7 @@ describe('init', () => { it('should create package.json with configured test command when {scripts: true}', async () => { prompts.mockReturnValueOnce({scripts: true}); - await init(resolveFromFixture('only_package_json')); + await init(resolveFromFixture('only-package-json')); const writtenPackageJson = fs.writeFileSync.mock.calls[0][1]; @@ -155,7 +155,7 @@ describe('init', () => { expect.assertions(1); try { - await init(resolveFromFixture('no_package_json')); + await init(resolveFromFixture('no-package-json')); } catch (error) { expect(error.message).toMatch( 'Could not find a "package.json" file in', @@ -171,7 +171,7 @@ describe('init', () => { it('user answered with "Yes"', async () => { prompts.mockReturnValueOnce({continue: true}).mockReturnValueOnce({}); - await init(resolveFromFixture(`has_jest_config_file_${extension}`)); + await init(resolveFromFixture(`has-jest-config-file-${extension}`)); expect(prompts.mock.calls[0][0]).toMatchSnapshot(); @@ -185,7 +185,7 @@ describe('init', () => { it('user answered with "No"', async () => { prompts.mockReturnValueOnce({continue: false}); - await init(resolveFromFixture(`has_jest_config_file_${extension}`)); + await init(resolveFromFixture(`has-jest-config-file-${extension}`)); // return after first prompt expect(prompts).toHaveBeenCalledTimes(1); }); @@ -198,7 +198,7 @@ describe('init', () => { it('user answered with "Yes"', async () => { prompts.mockReturnValueOnce({useTypescript: true}); - await init(resolveFromFixture('test_generated_jest_config_ts')); + await init(resolveFromFixture('test-generated-jest-config-ts')); expect(prompts.mock.calls[0][0]).toMatchSnapshot(); @@ -212,7 +212,7 @@ describe('init', () => { it('user answered with "No"', async () => { prompts.mockReturnValueOnce({useTypescript: false}); - await init(resolveFromFixture('test_generated_jest_config_ts')); + await init(resolveFromFixture('test-generated-jest-config-ts')); const jestConfigFileName = fs.writeFileSync.mock.calls[0][0]; @@ -225,7 +225,7 @@ describe('init', () => { it('should ask the user whether to override config or not', async () => { prompts.mockReturnValueOnce({continue: true}).mockReturnValueOnce({}); - await init(resolveFromFixture('has_jest_config_in_package_json')); + await init(resolveFromFixture('has-jest-config-in-package-json')); expect(prompts.mock.calls[0][0]).toMatchSnapshot(); @@ -239,7 +239,7 @@ describe('init', () => { it('should not ask "test script question"', async () => { prompts.mockReturnValueOnce({}); - await init(resolveFromFixture('test_script_configured')); + await init(resolveFromFixture('test-script-configured')); const questionsNames = prompts.mock.calls[0][0].map( question => question.name, diff --git a/packages/jest-cli/src/init/__tests__/modify_package_json.test.ts b/packages/jest-cli/src/init/__tests__/modifyPackageJson.test.ts similarity index 95% rename from packages/jest-cli/src/init/__tests__/modify_package_json.test.ts rename to packages/jest-cli/src/init/__tests__/modifyPackageJson.test.ts index 8c7dad5a0bef..b52b1cf070c9 100644 --- a/packages/jest-cli/src/init/__tests__/modify_package_json.test.ts +++ b/packages/jest-cli/src/init/__tests__/modifyPackageJson.test.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import modifyPackageJson from '../modify_package_json'; +import modifyPackageJson from '../modifyPackageJson'; test('should remove jest config if exists', () => { expect( diff --git a/packages/jest-cli/src/init/generate_config_file.ts b/packages/jest-cli/src/init/generateConfigFile.ts similarity index 100% rename from packages/jest-cli/src/init/generate_config_file.ts rename to packages/jest-cli/src/init/generateConfigFile.ts diff --git a/packages/jest-cli/src/init/index.ts b/packages/jest-cli/src/init/index.ts index cdc5a5298ade..67eef8cdd02b 100644 --- a/packages/jest-cli/src/init/index.ts +++ b/packages/jest-cli/src/init/index.ts @@ -13,8 +13,8 @@ import {constants} from 'jest-config'; import {tryRealpath} from 'jest-util'; import defaultQuestions, {testScriptQuestion} from './questions'; import {MalformedPackageJsonError, NotFoundPackageJsonError} from './errors'; -import generateConfigFile from './generate_config_file'; -import modifyPackageJson from './modify_package_json'; +import generateConfigFile from './generateConfigFile'; +import modifyPackageJson from './modifyPackageJson'; import type {ProjectPackageJson} from './types'; const { diff --git a/packages/jest-cli/src/init/modify_package_json.ts b/packages/jest-cli/src/init/modifyPackageJson.ts similarity index 100% rename from packages/jest-cli/src/init/modify_package_json.ts rename to packages/jest-cli/src/init/modifyPackageJson.ts From 7134a10eec6f2ca2a1d80875cb860197d8f5a77e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 25 Oct 2020 12:58:05 +0530 Subject: [PATCH 2/2] add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fdc55f111b..fa8314e1b95e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Chore & Maintenance +- `[jest-cli]` chore: standardize files and folder names ([#10698](https://github.com/facebook/jest/pull/1098)) + ### Performance ## 26.6.1