diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b67389a430c..42f65a4894b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/packages/jest-circus/runner.js b/packages/jest-circus/runner.js index 214956a9f42a..8ed8163ee414 100644 --- a/packages/jest-circus/runner.js +++ b/packages/jest-circus/runner.js @@ -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; diff --git a/packages/jest-circus/src/__mocks__/test_event_handler.js b/packages/jest-circus/src/__mocks__/testEventHandler.js similarity index 100% rename from packages/jest-circus/src/__mocks__/test_event_handler.js rename to packages/jest-circus/src/__mocks__/testEventHandler.js diff --git a/packages/jest-circus/src/__mocks__/test_utils.js b/packages/jest-circus/src/__mocks__/testUtils.js similarity index 97% rename from packages/jest-circus/src/__mocks__/test_utils.js rename to packages/jest-circus/src/__mocks__/testUtils.js index 39594b009a2b..4e3ca543dccb 100644 --- a/packages/jest-circus/src/__mocks__/test_utils.js +++ b/packages/jest-circus/src/__mocks__/testUtils.js @@ -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(); diff --git a/packages/jest-circus/src/__tests__/__snapshots__/after_all.test.js.snap b/packages/jest-circus/src/__tests__/__snapshots__/afterAll.test.js.snap similarity index 100% rename from packages/jest-circus/src/__tests__/__snapshots__/after_all.test.js.snap rename to packages/jest-circus/src/__tests__/__snapshots__/afterAll.test.js.snap diff --git a/packages/jest-circus/src/__tests__/__snapshots__/base_test.test.js.snap b/packages/jest-circus/src/__tests__/__snapshots__/baseTest.test.js.snap similarity index 100% rename from packages/jest-circus/src/__tests__/__snapshots__/base_test.test.js.snap rename to packages/jest-circus/src/__tests__/__snapshots__/baseTest.test.js.snap diff --git a/packages/jest-circus/src/__tests__/after_all.test.js b/packages/jest-circus/src/__tests__/afterAll.test.js similarity index 97% rename from packages/jest-circus/src/__tests__/after_all.test.js rename to packages/jest-circus/src/__tests__/afterAll.test.js index 22e424d96f20..7cccc1f66d49 100644 --- a/packages/jest-circus/src/__tests__/after_all.test.js +++ b/packages/jest-circus/src/__tests__/afterAll.test.js @@ -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(` diff --git a/packages/jest-circus/src/__tests__/base_test.test.js b/packages/jest-circus/src/__tests__/baseTest.test.js similarity index 94% rename from packages/jest-circus/src/__tests__/base_test.test.js rename to packages/jest-circus/src/__tests__/baseTest.test.js index ec83663ba8db..1cc1c2abab94 100644 --- a/packages/jest-circus/src/__tests__/base_test.test.js +++ b/packages/jest-circus/src/__tests__/baseTest.test.js @@ -10,7 +10,7 @@ 'use strict'; -import {runTest} from '../__mocks__/test_utils'; +import {runTest} from '../__mocks__/testUtils'; test('simple test', () => { const {stdout} = runTest(` diff --git a/packages/jest-circus/src/__tests__/circus_it_test_error.test.js b/packages/jest-circus/src/__tests__/circusItTestError.test.js similarity index 100% rename from packages/jest-circus/src/__tests__/circus_it_test_error.test.js rename to packages/jest-circus/src/__tests__/circusItTestError.test.js diff --git a/packages/jest-circus/src/__tests__/circus_todo_test_error.test.js b/packages/jest-circus/src/__tests__/circusItTodoTestError.test.js similarity index 100% rename from packages/jest-circus/src/__tests__/circus_todo_test_error.test.js rename to packages/jest-circus/src/__tests__/circusItTodoTestError.test.js diff --git a/packages/jest-circus/src/__tests__/hooks.test.js b/packages/jest-circus/src/__tests__/hooks.test.js index 2486cc3d6e62..6d9b58bce341 100644 --- a/packages/jest-circus/src/__tests__/hooks.test.js +++ b/packages/jest-circus/src/__tests__/hooks.test.js @@ -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(` diff --git a/packages/jest-circus/src/__tests__/hooks_error.test.js b/packages/jest-circus/src/__tests__/hooksError.test.js similarity index 100% rename from packages/jest-circus/src/__tests__/hooks_error.test.js rename to packages/jest-circus/src/__tests__/hooksError.test.js diff --git a/packages/jest-circus/src/event_handler.js b/packages/jest-circus/src/eventHandler.js similarity index 97% rename from packages/jest-circus/src/event_handler.js rename to packages/jest-circus/src/eventHandler.js index fb5af141b802..893e61f61410 100644 --- a/packages/jest-circus/src/event_handler.js +++ b/packages/jest-circus/src/eventHandler.js @@ -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; @@ -183,4 +183,4 @@ const handler: EventHandler = (event, state): void => { } }; -export default handler; +export default eventHandler; diff --git a/packages/jest-circus/src/format_node_assert_errors.js b/packages/jest-circus/src/formatNodeAssertErrors.js similarity index 97% rename from packages/jest-circus/src/format_node_assert_errors.js rename to packages/jest-circus/src/formatNodeAssertErrors.js index 9151fa9fe3fa..d6080ce0b168 100644 --- a/packages/jest-circus/src/format_node_assert_errors.js +++ b/packages/jest-circus/src/formatNodeAssertErrors.js @@ -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 => { @@ -167,3 +167,5 @@ function assertionErrorMessage(error: AssertionError, options: DiffOptions) { trimmedStack ); } + +export default formatNodeAssertErrors; diff --git a/packages/jest-circus/src/error_handlers.js b/packages/jest-circus/src/globalErrorHandlers.js similarity index 100% rename from packages/jest-circus/src/error_handlers.js rename to packages/jest-circus/src/globalErrorHandlers.js diff --git a/packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter.js b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.js similarity index 95% rename from packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter.js rename to packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.js index bf2d87b9f4bd..af85e4d095b4 100644 --- a/packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter.js +++ b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapter.js @@ -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 ( @@ -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, }); diff --git a/packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter_init.js b/packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.js similarity index 100% rename from packages/jest-circus/src/legacy_code_todo_rewrite/jest_adapter_init.js rename to packages/jest-circus/src/legacy-code-todo-rewrite/jestAdapterInit.js diff --git a/packages/jest-circus/src/legacy_code_todo_rewrite/jest_expect.js b/packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.js similarity index 100% rename from packages/jest-circus/src/legacy_code_todo_rewrite/jest_expect.js rename to packages/jest-circus/src/legacy-code-todo-rewrite/jestExpect.js diff --git a/packages/jest-circus/src/state.js b/packages/jest-circus/src/state.js index 3187775bcc2f..36d4fa69cf04 100644 --- a/packages/jest-circus/src/state.js +++ b/packages/jest-circus/src/state.js @@ -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,