Skip to content

Commit

Permalink
Standardize filenames in packages/jest circus (#7301)
Browse files Browse the repository at this point in the history
* Rename event_handler -> eventHandler. Function & Mocks

* Rename error_handlers -> globalErrorHandlers. File & imports

* Rename format_node_assert_errors -> formatNodeAssertErrors

- File, Function & Imports renamed
- `export default (...` changed to
  `const formatNodeAssertErrors = (...` with
  `export default formatNodeAssertErrors` at end of file

* Rename test_utils & runTest -> testUtils

- Rename file, function, imports, mocks, & tests

* Rename after_all.test.js -> afterAll.test.js

- Rename file only

* Rename after_all.test.js.snap -> afterAll.test.js.snap

- Forgot snapshot when renaming afterAll.test.js
- Rename snapshot to match test filename

* Rename base_test.test.js -> baseTest.test.js

- Rename file & snap

* Rename circus_it_test_error.test.js -> circusItTestError.test.js

* Rename circus_todo_test_error.test.js -> CircusItTodoTestError.test.js

- Added "it" to name to match CircusItTestError.test.js
- Rename file

* Rename hooks_error.test.js -> hooksError.test.js

- Rename file

* Rename legacy_code_todo_rewrite -> legacy-code-todo-rewrite

- Directory names should use dashes

* Add CHANGELOG.md entry

* Fix broken link to legacy-code-todo-rewrite/ in jest-circus/runner.js

* Revert export in testUtils.js to runTest per @thymikee's request

* Rename files in legacy-code-todo-rewrite/

- jest_adapter.js      -> jestAdapter.js
- jest_adapter_init.js -> jestAdapterInit.js
- jest_expect.js       -> jestExpect.js
- Fixed imports within directory and in runner.js
  • Loading branch information
andrew-pyle authored and thymikee committed Oct 31, 2018
1 parent 968ddc4 commit 2f32100
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

### Chore & Maintenance

- `[jest-circus]` Standardize file naming in `jest-circus` ([#7301](https://github.com/facebook/jest/pull/7301))
- `[docs]` Add synchronous test.each setup ([#7150](https://github.com/facebook/jest/pull/7150))
- `[docs]` Add `this.extend` to the Custom Matchers API reference ([#7130](https://github.com/facebook/jest/pull/7130))
- `[docs]` Fix default value for `coverageReporters` value in configuration docs ([#7126](https://github.com/facebook/jest/pull/7126))
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
*/

// Allow people to use `jest-circus/runner` as a runner.
const runner = require('./build/legacy_code_todo_rewrite/jest_adapter');
const runner = require('./build/legacy-code-todo-rewrite/jestAdapter');
module.exports = runner;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {skipSuiteOnWindows} from '../../../../scripts/ConditionalTest';
const CIRCUS_PATH = require.resolve('../../build/index');
const CIRCUS_RUN_PATH = require.resolve('../../build/run');
const CIRCUS_STATE_PATH = require.resolve('../../build/state');
const TEST_EVENT_HANDLER_PATH = require.resolve('./test_event_handler');
const TEST_EVENT_HANDLER_PATH = require.resolve('./testEventHandler');
const BABEL_REGISTER_PATH = require.resolve('babel-register');

skipSuiteOnWindows();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {runTest} from '../__mocks__/testUtils';

test('tests are not marked done until their parent afterAll runs', () => {
const {stdout} = runTest(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {runTest} from '../__mocks__/testUtils';

test('simple test', () => {
const {stdout} = runTest(`
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-circus/src/__tests__/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import {runTest} from '../__mocks__/test_utils';
import {runTest} from '../__mocks__/testUtils';

test('beforeEach is executed before each test in current/child describe blocks', () => {
const {stdout} = runTest(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import {
import {
injectGlobalErrorHandlers,
restoreGlobalErrorHandlers,
} from './error_handlers';
} from './globalErrorHandlers';

// To pass this value from Runtime object to state we need to use global[sym]
const TEST_TIMEOUT_SYMBOL = Symbol.for('TEST_TIMEOUT_SYMBOL');

const handler: EventHandler = (event, state): void => {
const eventHandler: EventHandler = (event, state): void => {
switch (event.name) {
case 'include_test_location_in_result': {
state.includeTestLocationInResult = true;
Expand Down Expand Up @@ -183,4 +183,4 @@ const handler: EventHandler = (event, state): void => {
}
};

export default handler;
export default eventHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const humanReadableOperators = {
strictEqual: 'to strictly be equal',
};

export default (event: Event, state: State) => {
const formatNodeAssertErrors = (event: Event, state: State) => {
switch (event.name) {
case 'test_done': {
event.test.errors = event.test.errors.map(errors => {
Expand Down Expand Up @@ -167,3 +167,5 @@ function assertionErrorMessage(error: AssertionError, options: DiffOptions) {
trimmedStack
);
}

export default formatNodeAssertErrors;
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {GlobalConfig, ProjectConfig} from 'types/Config';
import type {TestResult} from 'types/TestResult';
import type Runtime from 'jest-runtime';

const FRAMEWORK_INITIALIZER = require.resolve('./jest_adapter_init');
const FRAMEWORK_INITIALIZER = require.resolve('./jestAdapterInit');
import path from 'path';

const jestAdapter = async (
Expand All @@ -28,7 +28,7 @@ const jestAdapter = async (
} = runtime.requireInternalModule(FRAMEWORK_INITIALIZER);

runtime
.requireInternalModule(path.resolve(__dirname, './jest_expect.js'))
.requireInternalModule(path.resolve(__dirname, './jestExpect.js'))
.default({
expand: globalConfig.expand,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-circus/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import type {Event, State, EventHandler} from 'types/Circus';

import {makeDescribe} from './utils';
import eventHandler from './event_handler';
import formatNodeAssertErrors from './format_node_assert_errors';
import eventHandler from './eventHandler';
import formatNodeAssertErrors from './formatNodeAssertErrors';

const eventHandlers: Array<EventHandler> = [
eventHandler,
Expand Down

0 comments on commit 2f32100

Please sign in to comment.