Skip to content

Commit

Permalink
chore(jest-cli): standardize files and folder names (#10698)
Browse files Browse the repository at this point in the history
* chore(jest-cli): standardize files and folder names

* add changelog entry
  • Loading branch information
snitin315 committed Oct 25, 2020
1 parent 706d636 commit 246b5d3
Show file tree
Hide file tree
Showing 25 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
32 changes: 16 additions & 16 deletions packages/jest-cli/src/init/__tests__/init.test.js
Expand Up @@ -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];

Expand All @@ -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];
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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];

Expand All @@ -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',
Expand All @@ -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();

Expand All @@ -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);
});
Expand All @@ -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();

Expand All @@ -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];

Expand All @@ -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();

Expand All @@ -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,
Expand Down
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/init/index.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit 246b5d3

Please sign in to comment.