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

Standardize file names in packages/jest-worker and packages/pretty-format #7316

Merged
merged 12 commits into from
Nov 14, 2018
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
- `[docs]` Add correct default value for `testUrl` config option ([#7277](https://github.com/facebook/jest/pull/7277))
- `[jest-util]` [**BREAKING**] Remove long-deprecated globals for fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[docs]` Remove duplicate code in `MockFunctions` ([#7297](https://github.com/facebook/jest/pull/7297))
- `[jest-haste-map]` Standardize filenames ([#7316](https://github.com/facebook/jest/pull/7316))
Copy link
Collaborator

Choose a reason for hiding this comment

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

jest-haste-map -> jest-worker

- `[pretty-format]` Standardize filenames ([#7316](https://github.com/facebook/jest/pull/7316))

### Performance

Expand Down
6 changes: 3 additions & 3 deletions packages/jest-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This example covers the minimal usage:
import Worker from 'jest-worker';

async function main() {
const worker = new Worker(require.resolve('./worker'));
const worker = new Worker(require.resolve('./Worker'));
const result = await worker.hello('Alice'); // "Hello, Alice"
}

Expand Down Expand Up @@ -114,7 +114,7 @@ This example covers the standard usage:
import Worker from 'jest-worker';

async function main() {
const myWorker = new Worker(require.resolve('./worker'), {
const myWorker = new Worker(require.resolve('./Worker'), {
exposedMethods: ['foo', 'bar', 'getWorkerId'],
numWorkers: 4,
});
Expand Down Expand Up @@ -155,7 +155,7 @@ This example covers the usage with a `computeWorkerKey` method:
import Worker from 'jest-worker';

async function main() {
const myWorker = new Worker(require.resolve('./worker'), {
const myWorker = new Worker(require.resolve('./Worker'), {
computeWorkerKey: (method, filename) => filename,
});

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/jest-worker/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ beforeEach(() => {
// The worker mock returns a worker with custom methods, plus it stores them
// in a global list, so that they can be accessed later. This list is reset in
// every test.
jest.mock('../worker', () => {
jest.mock('../Worker', () => {
const fakeClass = jest.fn(() => {
const fakeWorker = {
getStderr: () => ({once() {}, pipe() {}}),
Expand Down Expand Up @@ -63,7 +63,7 @@ beforeEach(() => {
virtual: true,
});

Worker = require('../worker').default;
Worker = require('../Worker').default;
Farm = require('../index').default;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/__tests__/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ beforeEach(() => {
return forkInterface;
});

Worker = require('../worker').default;
SimenB marked this conversation as resolved.
Show resolved Hide resolved
Worker = require('../Worker').default;
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {FarmOptions} from './types';
import type {Readable} from 'stream';

import {CHILD_MESSAGE_CALL, CHILD_MESSAGE_END} from './types';
import Worker from './worker';
import Worker from './Worker';

/* istanbul ignore next */
const emptyMethod = () => {};
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type PARENT_MESSAGE_ERROR =

// Option objects.

import type Worker from './worker';
import type Worker from './Worker';

export type ForkOptions = {
cwd?: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/src/plugins/lib/markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import type {Config, Printer, Refs} from 'types/PrettyFormat';

import escapeHTML from './escape_html';
import escapeHTML from './escapeHTML';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you rename the rest of the files in pretty-format? There's quite a bunch of left

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, I might have missed some, could you point out what files are left? I thought that the ones in /src/ have multiple exports per file, hence I left files with snake_case

Copy link
Collaborator

Choose a reason for hiding this comment

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

We want to rename every file that doesn't stick to the convention.
E.g.

packages/pretty-format/src/__tests__/asymmetric_matcher.test.js
packages/pretty-format/src/plugins/asymmetric_matcher.js

to have names as variables:

import AsymmetricMatcher from './plugins/asymmetric_matcher';
import ConvertAnsi from './plugins/convert_ansi';
import DOMCollection from './plugins/dom_collection';
import DOMElement from './plugins/dom_element';
import Immutable from './plugins/immutable';
import ReactElement from './plugins/react_element';
import ReactTestComponent from './plugins/react_test_component';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the './plugins/asymmetric_matcher' has 3 exports, so according to those:

All folders -> kabab-case
All files that export a single Class -> CapitalizeCase
All files that export a single function -> camelCase
All other files -> underscore_case

its falling into the underscore_case?

Copy link
Collaborator

@thymikee thymikee Nov 8, 2018

Choose a reason for hiding this comment

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

This is a mistake in interface, they shouldn't expose serialize and test directly, as they do it in a default export – and we only use it that way. You can remove those named exports. cc @pedrottimark

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thymikee Great, I will redo the exports and fix those files, thanks 👍


// Return empty string if keys is empty.
export const printProps = (
Expand Down