diff --git a/.eslintrc.js b/.eslintrc.js index 5fbced0c04f6..cce09f2050a7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,7 @@ module.exports = { extends: [ './packages/eslint-config-fb-strict/index.js', - 'plugin:import/errors', + 'plugin:import/errors' ], parser: 'babel-eslint', rules: { @@ -20,15 +20,16 @@ module.exports = { 'max-len': 0, 'no-multiple-empty-lines': 1, 'import/no-duplicates': 2, - 'import/no-unresolved': [2, { ignore: ['^types/'] }], + 'import/no-unresolved': [2, {ignore: ['^types/']}], // This has to be disabled until all type and module imports are combined // https://github.com/benmosher/eslint-plugin-import/issues/645 'import/order': 0, // These has to be disabled until the whole code base is converted to ESM 'import/default': 0, 'import/named': 0, + 'unicorn/filename-case': [2, {case: 'snakeCase'}] }, - plugins: ['markdown', 'import'], + plugins: ['markdown', 'import', 'unicorn'], overrides: [ // to make it more suitable for running on code examples in docs/ folder { @@ -43,22 +44,31 @@ module.exports = { 'no-unused-vars': 0, 'consistent-return': 0, 'import/no-unresolved': 0, - 'sort-keys': 0 - }, + 'sort-keys': 0, + 'unicorn/filename-case': 0 + } }, { files: ['examples/**/*'], rules: { 'babel/func-params-comma-dangle': 0, 'import/order': 0, - 'import/no-unresolved': [2, { 'ignore': ['^react-native$'] }] - }, + 'import/no-unresolved': [2, {ignore: ['^react-native$']}], + 'unicorn/filename-case': 0 + } }, { files: ['scripts/**/*', 'integration_tests/**/*'], rules: { 'babel/func-params-comma-dangle': 0, - }, + 'unicorn/filename-case': 0 + } }, - ], + { + files: ['**/__mocks__/**/*', 'website/**/*', '**/jest-runtime/**/*', '**/src/Console*'], + rules: { + 'unicorn/filename-case': 0 + } + } + ] }; diff --git a/examples/react-native/.flowconfig b/examples/react-native/.flowconfig index 2aa9a60e3b2a..31558d3ba74f 100644 --- a/examples/react-native/.flowconfig +++ b/examples/react-native/.flowconfig @@ -26,7 +26,7 @@ experimental.strict_type_args=true munge_underscores=true -module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' +module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'global_image_stub' module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' suppress_type=$FlowIssue diff --git a/fixtures/parserTests.js b/fixtures/parser_tests.js similarity index 100% rename from fixtures/parserTests.js rename to fixtures/parser_tests.js diff --git a/package.json b/package.json index 8355aaa24505..afe746cfd079 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "eslint-plugin-import": "^2.6.0", "eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-react": "^7.1.0", + "eslint-plugin-unicorn": "^2.1.2", "flow-bin": "^0.48.0", "glob": "^7.1.1", "graceful-fs": "^4.1.11", @@ -114,7 +115,7 @@ "transform": { "^.+\\.js$": "/packages/babel-jest" }, - "setupTestFrameworkScriptFile": "/testSetupFile.js", + "setupTestFrameworkScriptFile": "/test_setup_file.js", "snapshotSerializers": [ "/packages/pretty-format/build/plugins/convert_ansi.js" ], @@ -130,5 +131,6 @@ "testMatch": [ "**/*.test.js" ] - } + }, + "dependencies": {} } diff --git a/packages/jest-cli/src/__tests__/generate_empty_coverage.test.js b/packages/jest-cli/src/__tests__/generate_empty_coverage.test.js index c34801e7b2a9..8f2749c6c20a 100644 --- a/packages/jest-cli/src/__tests__/generate_empty_coverage.test.js +++ b/packages/jest-cli/src/__tests__/generate_empty_coverage.test.js @@ -11,7 +11,7 @@ const os = require('os'); -const generateEmptyCoverage = require('../generateEmptyCoverage'); +const generateEmptyCoverage = require('../generate_empty_coverage'); jest.mock('jest-runtime', () => { const realRuntime = require.requireActual('jest-runtime'); diff --git a/packages/jest-cli/src/__tests__/search_source.test.js b/packages/jest-cli/src/__tests__/search_source.test.js index 765c1caf1cc5..6d30fb8e233d 100644 --- a/packages/jest-cli/src/__tests__/search_source.test.js +++ b/packages/jest-cli/src/__tests__/search_source.test.js @@ -34,7 +34,7 @@ describe('SearchSource', () => { beforeEach(() => { Runtime = require('jest-runtime'); - SearchSource = require('../SearchSource'); + SearchSource = require('../search_source'); normalize = require('jest-config').normalize; }); @@ -415,7 +415,7 @@ describe('SearchSource', () => { }); it('returns empty search result if no related tests were found', () => { - const input = ['no tests.js']; + const input = ['no_tests.js']; const data = searchSource.findRelatedTestsFromPattern(input); expect(data.tests).toEqual([]); }); diff --git a/packages/jest-cli/src/__tests__/test_root/no tests.js b/packages/jest-cli/src/__tests__/test_root/no_tests.js similarity index 100% rename from packages/jest-cli/src/__tests__/test_root/no tests.js rename to packages/jest-cli/src/__tests__/test_root/no_tests.js diff --git a/packages/jest-cli/src/__tests__/test_runner.test.js b/packages/jest-cli/src/__tests__/test_runner.test.js index 1a86a2cceb33..7cba6bf20eee 100644 --- a/packages/jest-cli/src/__tests__/test_runner.test.js +++ b/packages/jest-cli/src/__tests__/test_runner.test.js @@ -10,9 +10,9 @@ 'use strict'; -const TestRunner = require('../TestRunner'); -const TestWatcher = require('../TestWatcher'); -const SummaryReporter = require('../reporters/SummaryReporter'); +const TestRunner = require('../test_runner'); +const TestWatcher = require('../test_watcher'); +const SummaryReporter = require('../reporters/summary_reporter'); let workerFarmMock; @@ -27,8 +27,8 @@ jest.mock('worker-farm', () => { return mock; }); -jest.mock('../TestWorker', () => {}); -jest.mock('../reporters/DefaultReporter'); +jest.mock('../test_worker', () => {}); +jest.mock('../reporters/default_reporter'); test('.addReporter() .removeReporter()', () => { const runner = new TestRunner({}, {}); diff --git a/packages/jest-cli/src/__tests__/test_sequencer.test.js b/packages/jest-cli/src/__tests__/test_sequencer.test.js index 45d74c2ce0e2..82982eb25d2d 100644 --- a/packages/jest-cli/src/__tests__/test_sequencer.test.js +++ b/packages/jest-cli/src/__tests__/test_sequencer.test.js @@ -12,7 +12,7 @@ jest.mock('fs'); const fs = require('fs'); const path = require('path'); -const TestSequencer = require('../TestSequencer'); +const TestSequencer = require('../test_sequencer'); const FAIL = 0; const SUCCESS = 1; diff --git a/packages/jest-cli/src/__tests__/watch.test.js b/packages/jest-cli/src/__tests__/watch.test.js index 145ffb654e3e..a544e6fb24b2 100644 --- a/packages/jest-cli/src/__tests__/watch.test.js +++ b/packages/jest-cli/src/__tests__/watch.test.js @@ -11,14 +11,14 @@ 'use strict'; const chalk = require('chalk'); -const TestWatcher = require('../TestWatcher'); +const TestWatcher = require('../test_watcher'); const {KEYS} = require('../constants'); const runJestMock = jest.fn(); jest.doMock('chalk', () => new chalk.constructor({enabled: false})); jest.doMock( - '../runJest', + '../run_jest', () => function() { const args = Array.from(arguments); diff --git a/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js b/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js index b88083bada53..acd67316c488 100644 --- a/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js +++ b/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js @@ -28,7 +28,7 @@ jest.mock('ansi-escapes', () => ({ })); jest.mock( - '../SearchSource', + '../search_source', () => class { constructor(context) { @@ -68,7 +68,7 @@ jest.doMock('chalk', () => ); jest.doMock( - '../runJest', + '../run_jest', () => function() { const args = Array.from(arguments); @@ -81,7 +81,7 @@ jest.doMock( }, ); -jest.doMock('../lib/terminalUtils', () => ({ +jest.doMock('../lib/terminal_utils', () => ({ getTerminalWidth: () => terminalWidth, })); diff --git a/packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js b/packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js index e93e28548bcc..778aff30882c 100644 --- a/packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js +++ b/packages/jest-cli/src/__tests__/watch_test_name_pattern_mode.test.js @@ -28,7 +28,7 @@ jest.mock('ansi-escapes', () => ({ })); jest.mock( - '../SearchSource', + '../search_source', () => class { findMatchingTests(pattern) { @@ -44,7 +44,7 @@ jest.doMock('chalk', () => ); jest.doMock( - '../runJest', + '../run_jest', () => function() { const args = Array.from(arguments); @@ -95,7 +95,7 @@ jest.doMock( }, ); -jest.doMock('../lib/terminalUtils', () => ({ +jest.doMock('../lib/terminal_utils', () => ({ getTerminalWidth: () => terminalWidth, })); diff --git a/packages/jest-cli/src/cli/getJest.js b/packages/jest-cli/src/cli/get_jest.js similarity index 100% rename from packages/jest-cli/src/cli/getJest.js rename to packages/jest-cli/src/cli/get_jest.js diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index 5b4a8d0a6045..71b0d6571d33 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -22,15 +22,15 @@ import {readConfig} from 'jest-config'; import {version as VERSION} from '../../package.json'; import args from './args'; import chalk from 'chalk'; -import createContext from '../lib/createContext'; -import getJest from './getJest'; -import getMaxWorkers from '../lib/getMaxWorkers'; -import handleDeprecationWarnings from '../lib/handleDeprecationWarnings'; -import logDebugMessages from '../lib/logDebugMessages'; -import preRunMessage from '../preRunMessage'; -import runJest from '../runJest'; +import createContext from '../lib/create_context'; +import getJest from './get_jest'; +import getMaxWorkers from '../lib/get_max_workers'; +import handleDeprecationWarnings from '../lib/handle_deprecation_warnings'; +import logDebugMessages from '../lib/log_debug_messages'; +import preRunMessage from '../pre_run_message'; +import runJest from '../run_jest'; import Runtime from 'jest-runtime'; -import TestWatcher from '../TestWatcher'; +import TestWatcher from '../test_watcher'; import watch from '../watch'; import yargs from 'yargs'; diff --git a/packages/jest-cli/src/generateEmptyCoverage.js b/packages/jest-cli/src/generate_empty_coverage.js similarity index 100% rename from packages/jest-cli/src/generateEmptyCoverage.js rename to packages/jest-cli/src/generate_empty_coverage.js diff --git a/packages/jest-cli/src/jest.js b/packages/jest-cli/src/jest.js index bced97273c0a..4e1e0cc46074 100644 --- a/packages/jest-cli/src/jest.js +++ b/packages/jest-cli/src/jest.js @@ -10,9 +10,9 @@ import {version as VERSION} from '../package.json'; -import SearchSource from './SearchSource'; -import TestRunner from './TestRunner'; -import TestWatcher from './TestWatcher'; +import SearchSource from './search_source'; +import TestRunner from './test_runner'; +import TestWatcher from './test_watcher'; import {run, runCLI} from './cli'; module.exports = { diff --git a/packages/jest-cli/src/lib/__tests__/format_test_name_by_pattern.test.js b/packages/jest-cli/src/lib/__tests__/format_test_name_by_pattern.test.js index f15810edbb5f..69b12e137ae6 100644 --- a/packages/jest-cli/src/lib/__tests__/format_test_name_by_pattern.test.js +++ b/packages/jest-cli/src/lib/__tests__/format_test_name_by_pattern.test.js @@ -10,7 +10,7 @@ 'use strict'; -const formatTestNameByPattern = require('../formatTestNameByPattern'); +const formatTestNameByPattern = require('../format_test_name_by_pattern'); describe('for multiline test name returns', () => { const testNames = [ diff --git a/packages/jest-cli/src/lib/__tests__/get_max_workers.test.js b/packages/jest-cli/src/lib/__tests__/get_max_workers.test.js index dc9e2eddadb1..1056566a22af 100644 --- a/packages/jest-cli/src/lib/__tests__/get_max_workers.test.js +++ b/packages/jest-cli/src/lib/__tests__/get_max_workers.test.js @@ -8,7 +8,7 @@ * @emails oncall+jsinfra */ -const getMaxWorkers = require('../getMaxWorkers'); +const getMaxWorkers = require('../get_max_workers'); jest.mock('os', () => ({ cpus: () => ({length: 4}), diff --git a/packages/jest-cli/src/lib/__tests__/is_valid_path.test.js b/packages/jest-cli/src/lib/__tests__/is_valid_path.test.js index cf1837b1aa7f..e84168d28d4c 100644 --- a/packages/jest-cli/src/lib/__tests__/is_valid_path.test.js +++ b/packages/jest-cli/src/lib/__tests__/is_valid_path.test.js @@ -9,7 +9,7 @@ */ const path = require('path'); -const isValidPath = require('../isValidPath'); +const isValidPath = require('../is_valid_path'); const rootDir = path.resolve(path.sep, 'root'); diff --git a/packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js b/packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js index e4a369302fcf..d68ccbfcc2cc 100644 --- a/packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js +++ b/packages/jest-cli/src/lib/__tests__/log_debug_messages.test.js @@ -10,7 +10,7 @@ 'use strict'; -const logDebugMessages = require('../logDebugMessages'); +const logDebugMessages = require('../log_debug_messages'); jest.mock('../../../package.json', () => ({version: 123})); diff --git a/packages/jest-cli/src/lib/__tests__/prompt.test.js b/packages/jest-cli/src/lib/__tests__/prompt.test.js index 9598621b8270..a8965aa1429b 100644 --- a/packages/jest-cli/src/lib/__tests__/prompt.test.js +++ b/packages/jest-cli/src/lib/__tests__/prompt.test.js @@ -9,7 +9,7 @@ */ 'use strict'; -const Prompt = require('../Prompt'); +const Prompt = require('../prompt'); let {KEYS} = require('../../constants'); KEYS = Object.assign({}, KEYS, { diff --git a/packages/jest-cli/src/lib/__tests__/scroll_list.test.js b/packages/jest-cli/src/lib/__tests__/scroll_list.test.js index 23e4aa0a510a..dfb723e2fb14 100644 --- a/packages/jest-cli/src/lib/__tests__/scroll_list.test.js +++ b/packages/jest-cli/src/lib/__tests__/scroll_list.test.js @@ -1,4 +1,4 @@ -const scroll = require('../scrollList'); +const scroll = require('../scroll_list'); it('When offset is -1', () => { expect(scroll(25, {max: 10, offset: -1})).toEqual({ diff --git a/packages/jest-cli/src/lib/__tests__/setState.js b/packages/jest-cli/src/lib/__tests__/set_state.js similarity index 100% rename from packages/jest-cli/src/lib/__tests__/setState.js rename to packages/jest-cli/src/lib/__tests__/set_state.js diff --git a/packages/jest-cli/src/lib/__tests__/validate_pattern.test.js b/packages/jest-cli/src/lib/__tests__/validate_pattern.test.js index 24b651eb6e70..5a6d22152c14 100644 --- a/packages/jest-cli/src/lib/__tests__/validate_pattern.test.js +++ b/packages/jest-cli/src/lib/__tests__/validate_pattern.test.js @@ -9,7 +9,7 @@ */ 'use strict'; -const validatePattern = require('../validatePattern'); +const validatePattern = require('../validate_pattern'); describe('validate pattern function', () => { it('without passed args returns true', () => { diff --git a/packages/jest-cli/src/lib/BufferedConsole.js b/packages/jest-cli/src/lib/buffered_console.js similarity index 100% rename from packages/jest-cli/src/lib/BufferedConsole.js rename to packages/jest-cli/src/lib/buffered_console.js diff --git a/packages/jest-cli/src/lib/createContext.js b/packages/jest-cli/src/lib/create_context.js similarity index 100% rename from packages/jest-cli/src/lib/createContext.js rename to packages/jest-cli/src/lib/create_context.js diff --git a/packages/jest-cli/src/lib/formatTestNameByPattern.js b/packages/jest-cli/src/lib/format_test_name_by_pattern.js similarity index 100% rename from packages/jest-cli/src/lib/formatTestNameByPattern.js rename to packages/jest-cli/src/lib/format_test_name_by_pattern.js diff --git a/packages/jest-cli/src/lib/getMaxWorkers.js b/packages/jest-cli/src/lib/get_max_workers.js similarity index 100% rename from packages/jest-cli/src/lib/getMaxWorkers.js rename to packages/jest-cli/src/lib/get_max_workers.js diff --git a/packages/jest-cli/src/lib/getTestPathPattern.js b/packages/jest-cli/src/lib/get_test_path_pattern.js similarity index 94% rename from packages/jest-cli/src/lib/getTestPathPattern.js rename to packages/jest-cli/src/lib/get_test_path_pattern.js index 1ce1a4402699..c6cf3505f960 100644 --- a/packages/jest-cli/src/lib/getTestPathPattern.js +++ b/packages/jest-cli/src/lib/get_test_path_pattern.js @@ -9,11 +9,11 @@ */ import type {Argv} from 'types/Argv'; -import type {TestSelectionConfig} from '../SearchSource'; +import type {TestSelectionConfig} from '../search_source'; import {clearLine} from 'jest-util'; import chalk from 'chalk'; -import validatePattern from './validatePattern'; +import validatePattern from './validate_pattern'; const DEFAULT_PATTERN_INFO = { input: '', diff --git a/packages/jest-cli/src/lib/handleDeprecationWarnings.js b/packages/jest-cli/src/lib/handle_deprecation_warnings.js similarity index 100% rename from packages/jest-cli/src/lib/handleDeprecationWarnings.js rename to packages/jest-cli/src/lib/handle_deprecation_warnings.js diff --git a/packages/jest-cli/src/lib/isValidPath.js b/packages/jest-cli/src/lib/is_valid_path.js similarity index 100% rename from packages/jest-cli/src/lib/isValidPath.js rename to packages/jest-cli/src/lib/is_valid_path.js diff --git a/packages/jest-cli/src/lib/logDebugMessages.js b/packages/jest-cli/src/lib/log_debug_messages.js similarity index 100% rename from packages/jest-cli/src/lib/logDebugMessages.js rename to packages/jest-cli/src/lib/log_debug_messages.js diff --git a/packages/jest-cli/src/lib/patternModeHelpers.js b/packages/jest-cli/src/lib/pattern_mode_helpers.js similarity index 98% rename from packages/jest-cli/src/lib/patternModeHelpers.js rename to packages/jest-cli/src/lib/pattern_mode_helpers.js index 82de807d6c4a..735ef326f330 100644 --- a/packages/jest-cli/src/lib/patternModeHelpers.js +++ b/packages/jest-cli/src/lib/pattern_mode_helpers.js @@ -13,7 +13,7 @@ import chalk from 'chalk'; import ansiEscapes from 'ansi-escapes'; import stringLength from 'string-length'; -import Prompt from './Prompt'; +import Prompt from './prompt'; const pluralize = (count: number, text: string) => count === 1 ? text : text + 's'; diff --git a/packages/jest-cli/src/lib/Prompt.js b/packages/jest-cli/src/lib/prompt.js similarity index 98% rename from packages/jest-cli/src/lib/Prompt.js rename to packages/jest-cli/src/lib/prompt.js index d1e48f415863..5178fd50dec2 100644 --- a/packages/jest-cli/src/lib/Prompt.js +++ b/packages/jest-cli/src/lib/prompt.js @@ -8,7 +8,7 @@ * @flow */ -import type {ScrollOptions} from './scrollList'; +import type {ScrollOptions} from './scroll_list'; import {KEYS} from '../constants'; diff --git a/packages/jest-cli/src/lib/scrollList.js b/packages/jest-cli/src/lib/scroll_list.js similarity index 100% rename from packages/jest-cli/src/lib/scrollList.js rename to packages/jest-cli/src/lib/scroll_list.js diff --git a/packages/jest-cli/src/lib/terminalUtils.js b/packages/jest-cli/src/lib/terminal_utils.js similarity index 100% rename from packages/jest-cli/src/lib/terminalUtils.js rename to packages/jest-cli/src/lib/terminal_utils.js diff --git a/packages/jest-cli/src/lib/updateArgv.js b/packages/jest-cli/src/lib/update_argv.js similarity index 95% rename from packages/jest-cli/src/lib/updateArgv.js rename to packages/jest-cli/src/lib/update_argv.js index 969887c3d89e..0a16d7f35f3d 100644 --- a/packages/jest-cli/src/lib/updateArgv.js +++ b/packages/jest-cli/src/lib/update_argv.js @@ -10,7 +10,7 @@ import type {Argv} from 'types/Argv'; -import getTestPathPattern from './getTestPathPattern'; +import getTestPathPattern from './get_test_path_pattern'; type Options = {| testNamePattern?: string, diff --git a/packages/jest-cli/src/lib/validatePattern.js b/packages/jest-cli/src/lib/validate_pattern.js similarity index 100% rename from packages/jest-cli/src/lib/validatePattern.js rename to packages/jest-cli/src/lib/validate_pattern.js diff --git a/packages/jest-cli/src/PatternPrompt.js b/packages/jest-cli/src/pattern_prompt.js similarity index 95% rename from packages/jest-cli/src/PatternPrompt.js rename to packages/jest-cli/src/pattern_prompt.js index 19a2a0ced922..3a58ffa199e2 100644 --- a/packages/jest-cli/src/PatternPrompt.js +++ b/packages/jest-cli/src/pattern_prompt.js @@ -10,11 +10,11 @@ 'use strict'; -import type {ScrollOptions} from './lib/scrollList'; +import type {ScrollOptions} from './lib/scroll_list'; import chalk from 'chalk'; import ansiEscapes from 'ansi-escapes'; -import Prompt from './lib/Prompt'; +import Prompt from './lib/prompt'; const usage = (entity: string) => `\n${chalk.bold('Pattern Mode Usage')}\n` + diff --git a/packages/jest-cli/src/preRunMessage.js b/packages/jest-cli/src/pre_run_message.js similarity index 100% rename from packages/jest-cli/src/preRunMessage.js rename to packages/jest-cli/src/pre_run_message.js diff --git a/packages/jest-cli/src/ReporterDispatcher.js b/packages/jest-cli/src/reporter_dispatcher.js similarity index 100% rename from packages/jest-cli/src/ReporterDispatcher.js rename to packages/jest-cli/src/reporter_dispatcher.js diff --git a/packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js b/packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js index 1b4ec241352d..09553bd94309 100644 --- a/packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js +++ b/packages/jest-cli/src/reporters/__tests__/coverage_reporter.test.js @@ -25,7 +25,7 @@ beforeEach(() => { write: jest.fn(), })); - CoverageReporter = require('../CoverageReporter'); + CoverageReporter = require('../coverage_reporter'); libCoverage = require('istanbul-lib-coverage'); libSourceMaps = require('istanbul-lib-source-maps'); }); diff --git a/packages/jest-cli/src/reporters/__tests__/coverage_worker.test.js b/packages/jest-cli/src/reporters/__tests__/coverage_worker.test.js index a8ddf35655c7..6bc082d4a38c 100644 --- a/packages/jest-cli/src/reporters/__tests__/coverage_worker.test.js +++ b/packages/jest-cli/src/reporters/__tests__/coverage_worker.test.js @@ -8,7 +8,7 @@ 'use strict'; -jest.mock('fs').mock('../../generateEmptyCoverage'); +jest.mock('fs').mock('../../generate_empty_coverage'); const globalConfig = {collectCoverage: true}; const config = {}; @@ -22,8 +22,8 @@ beforeEach(() => { jest.resetModules(); fs = require('fs'); - generateEmptyCoverage = require('../../generateEmptyCoverage'); - worker = require('../CoverageWorker'); + generateEmptyCoverage = require('../../generate_empty_coverage'); + worker = require('../coverage_worker'); }); test('resolves to the result of generateEmptyCoverage upon success', () => { diff --git a/packages/jest-cli/src/reporters/__tests__/verbose_reporter.test.js b/packages/jest-cli/src/reporters/__tests__/verbose_reporter.test.js index 9bd151af2169..27669b73a9f0 100644 --- a/packages/jest-cli/src/reporters/__tests__/verbose_reporter.test.js +++ b/packages/jest-cli/src/reporters/__tests__/verbose_reporter.test.js @@ -12,7 +12,7 @@ const wrap = obj => ({suites: obj, tests: [], title: ''}); let groupTestsBySuites; beforeEach(() => { - groupTestsBySuites = require('../VerboseReporter').groupTestsBySuites; + groupTestsBySuites = require('../verbose_reporter').groupTestsBySuites; }); describe('groupTestsBySuites', () => { diff --git a/packages/jest-cli/src/reporters/BaseReporter.js b/packages/jest-cli/src/reporters/base_reporter.js similarity index 96% rename from packages/jest-cli/src/reporters/BaseReporter.js rename to packages/jest-cli/src/reporters/base_reporter.js index 27c14dd8452e..9716acb3650e 100644 --- a/packages/jest-cli/src/reporters/BaseReporter.js +++ b/packages/jest-cli/src/reporters/base_reporter.js @@ -13,7 +13,7 @@ import type {Context} from 'types/Context'; import type {Test} from 'types/TestRunner'; import type {ReporterOnStartOptions} from 'types/Reporters'; -import preRunMessage from '../preRunMessage'; +import preRunMessage from '../pre_run_message'; class BaseReporter { _error: ?Error; diff --git a/packages/jest-cli/src/reporters/CoverageReporter.js b/packages/jest-cli/src/reporters/coverage_reporter.js similarity index 98% rename from packages/jest-cli/src/reporters/CoverageReporter.js rename to packages/jest-cli/src/reporters/coverage_reporter.js index b9077f0c8ca0..23b6f6dd2708 100644 --- a/packages/jest-cli/src/reporters/CoverageReporter.js +++ b/packages/jest-cli/src/reporters/coverage_reporter.js @@ -30,8 +30,8 @@ import istanbulCoverage from 'istanbul-lib-coverage'; import libSourceMaps from 'istanbul-lib-source-maps'; import pify from 'pify'; import workerFarm from 'worker-farm'; -import BaseReporter from './BaseReporter'; -import CoverageWorker from './CoverageWorker'; +import BaseReporter from './base_reporter'; +import CoverageWorker from './coverage_worker'; const FAIL_COLOR = chalk.bold.red; const RUNNING_TEST_COLOR = chalk.bold.dim; @@ -153,7 +153,7 @@ class CoverageReporter extends BaseReporter { maxConcurrentWorkers: this._maxWorkers, maxRetries: 2, }, - require.resolve('./CoverageWorker'), + require.resolve('./coverage_worker'), ); worker = pify(farm); } diff --git a/packages/jest-cli/src/reporters/CoverageWorker.js b/packages/jest-cli/src/reporters/coverage_worker.js similarity index 95% rename from packages/jest-cli/src/reporters/CoverageWorker.js rename to packages/jest-cli/src/reporters/coverage_worker.js index 75e413f9b134..25ef877458ba 100644 --- a/packages/jest-cli/src/reporters/CoverageWorker.js +++ b/packages/jest-cli/src/reporters/coverage_worker.js @@ -12,7 +12,7 @@ import type {GlobalConfig, ProjectConfig, Path} from 'types/Config'; import type {SerializableError} from 'types/TestResult'; import fs from 'fs'; -import generateEmptyCoverage from '../generateEmptyCoverage'; +import generateEmptyCoverage from '../generate_empty_coverage'; type CoverageWorkerData = {| globalConfig: GlobalConfig, diff --git a/packages/jest-cli/src/reporters/DefaultReporter.js b/packages/jest-cli/src/reporters/default_reporter.js similarity index 96% rename from packages/jest-cli/src/reporters/DefaultReporter.js rename to packages/jest-cli/src/reporters/default_reporter.js index ab112da7adb5..000a52aab914 100644 --- a/packages/jest-cli/src/reporters/DefaultReporter.js +++ b/packages/jest-cli/src/reporters/default_reporter.js @@ -18,10 +18,10 @@ import type {ReporterOnStartOptions} from 'types/Reporters'; import {clearLine} from 'jest-util'; import chalk from 'chalk'; import isCI from 'is-ci'; -import BaseReporter from './BaseReporter'; -import Status from './Status'; -import getConsoleOutput from './getConsoleOutput'; -import getResultHeader from './getResultHeader'; +import BaseReporter from './base_reporter'; +import Status from './status'; +import getConsoleOutput from './get_console_output'; +import getResultHeader from './get_result_header'; type write = (chunk: string, enc?: any, cb?: () => void) => boolean; type FlushBufferedOutput = () => void; diff --git a/packages/jest-cli/src/reporters/getConsoleOutput.js b/packages/jest-cli/src/reporters/get_console_output.js similarity index 100% rename from packages/jest-cli/src/reporters/getConsoleOutput.js rename to packages/jest-cli/src/reporters/get_console_output.js diff --git a/packages/jest-cli/src/reporters/getResultHeader.js b/packages/jest-cli/src/reporters/get_result_header.js similarity index 100% rename from packages/jest-cli/src/reporters/getResultHeader.js rename to packages/jest-cli/src/reporters/get_result_header.js diff --git a/packages/jest-cli/src/reporters/NotifyReporter.js b/packages/jest-cli/src/reporters/notify_reporter.js similarity index 98% rename from packages/jest-cli/src/reporters/NotifyReporter.js rename to packages/jest-cli/src/reporters/notify_reporter.js index 5deb6603327b..cfa8c589fcd2 100644 --- a/packages/jest-cli/src/reporters/NotifyReporter.js +++ b/packages/jest-cli/src/reporters/notify_reporter.js @@ -14,7 +14,7 @@ import type {Context} from 'types/Context'; import path from 'path'; import util from 'util'; import notifier from 'node-notifier'; -import BaseReporter from './BaseReporter'; +import BaseReporter from './base_reporter'; const isDarwin = process.platform === 'darwin'; diff --git a/packages/jest-cli/src/reporters/Status.js b/packages/jest-cli/src/reporters/status.js similarity index 100% rename from packages/jest-cli/src/reporters/Status.js rename to packages/jest-cli/src/reporters/status.js diff --git a/packages/jest-cli/src/reporters/SummaryReporter.js b/packages/jest-cli/src/reporters/summary_reporter.js similarity index 97% rename from packages/jest-cli/src/reporters/SummaryReporter.js rename to packages/jest-cli/src/reporters/summary_reporter.js index 215c11a9f6ae..2e6e0cad8fb4 100644 --- a/packages/jest-cli/src/reporters/SummaryReporter.js +++ b/packages/jest-cli/src/reporters/summary_reporter.js @@ -12,13 +12,13 @@ import type {AggregatedResult, SnapshotSummary} from 'types/TestResult'; import type {GlobalConfig} from 'types/Config'; import type {Context} from 'types/Context'; import type {ReporterOnStartOptions} from 'types/Reporters'; -import type {TestRunnerOptions} from '../TestRunner'; -import type {TestSelectionConfig} from '../SearchSource'; +import type {TestRunnerOptions} from '../test_runner'; +import type {TestSelectionConfig} from '../search_source'; import chalk from 'chalk'; -import BaseReporter from './BaseReporter'; +import BaseReporter from './base_reporter'; import {getSummary, pluralize} from './utils'; -import getResultHeader from './getResultHeader'; +import getResultHeader from './get_result_header'; const ARROW = ' \u203A '; const FAIL_COLOR = chalk.bold.red; diff --git a/packages/jest-cli/src/reporters/VerboseReporter.js b/packages/jest-cli/src/reporters/verbose_reporter.js similarity index 98% rename from packages/jest-cli/src/reporters/VerboseReporter.js rename to packages/jest-cli/src/reporters/verbose_reporter.js index 0b27d48c8454..9d0012a1908c 100644 --- a/packages/jest-cli/src/reporters/VerboseReporter.js +++ b/packages/jest-cli/src/reporters/verbose_reporter.js @@ -19,7 +19,7 @@ import type {Test} from 'types/TestRunner'; import chalk from 'chalk'; import {ICONS} from '../constants'; -import DefaultReporter from './DefaultReporter'; +import DefaultReporter from './default_reporter'; class VerboseReporter extends DefaultReporter { _globalConfig: GlobalConfig; diff --git a/packages/jest-cli/src/runJest.js b/packages/jest-cli/src/run_jest.js similarity index 94% rename from packages/jest-cli/src/runJest.js rename to packages/jest-cli/src/run_jest.js index 8f3f11e6c0b3..66b4266d5227 100644 --- a/packages/jest-cli/src/runJest.js +++ b/packages/jest-cli/src/run_jest.js @@ -11,21 +11,21 @@ import type {Argv} from 'types/Argv'; import type {Context} from 'types/Context'; import type {GlobalConfig} from 'types/Config'; -import type {TestSelectionConfig} from './SearchSource'; +import type {TestSelectionConfig} from './search_source'; import type {AggregatedResult} from 'types/TestResult'; -import type TestWatcher from './TestWatcher'; +import type TestWatcher from './test_watcher'; import path from 'path'; import {Console, formatTestResults} from 'jest-util'; import chalk from 'chalk'; import fs from 'graceful-fs'; -import getMaxWorkers from './lib/getMaxWorkers'; -import getTestPathPattern from './lib/getTestPathPattern'; -import SearchSource from './SearchSource'; -import updateArgv from './lib/updateArgv'; -import TestRunner from './TestRunner'; -import TestSequencer from './TestSequencer'; -import {makeEmptyAggregatedTestResult} from './testResultHelpers'; +import getMaxWorkers from './lib/get_max_workers'; +import getTestPathPattern from './lib/get_test_path_pattern'; +import SearchSource from './search_source'; +import updateArgv from './lib/update_argv'; +import TestRunner from './test_runner'; +import TestSequencer from './test_sequencer'; +import {makeEmptyAggregatedTestResult} from './test_result_helpers'; const setConfig = (contexts, newConfig) => contexts.forEach( diff --git a/packages/jest-cli/src/runTest.js b/packages/jest-cli/src/run_test.js similarity index 97% rename from packages/jest-cli/src/runTest.js rename to packages/jest-cli/src/run_test.js index a7f47d1a8af4..fd90b5f2611b 100644 --- a/packages/jest-cli/src/runTest.js +++ b/packages/jest-cli/src/run_test.js @@ -19,8 +19,8 @@ import fs from 'fs'; import {Console, NullConsole, setGlobal} from 'jest-util'; import {getTestEnvironment} from 'jest-config'; import docblock from 'jest-docblock'; -import BufferedConsole from './lib/BufferedConsole'; -import getConsoleOutput from './reporters/getConsoleOutput'; +import BufferedConsole from './lib/buffered_console'; +import getConsoleOutput from './reporters/get_console_output'; function runTest( path: Path, diff --git a/packages/jest-cli/src/SearchSource.js b/packages/jest-cli/src/search_source.js similarity index 100% rename from packages/jest-cli/src/SearchSource.js rename to packages/jest-cli/src/search_source.js diff --git a/packages/jest-cli/src/TestNamePatternPrompt.js b/packages/jest-cli/src/test_name_pattern_prompt.js similarity index 88% rename from packages/jest-cli/src/TestNamePatternPrompt.js rename to packages/jest-cli/src/test_name_pattern_prompt.js index 4a9c7b01fd98..e614e1725e00 100644 --- a/packages/jest-cli/src/TestNamePatternPrompt.js +++ b/packages/jest-cli/src/test_name_pattern_prompt.js @@ -10,12 +10,12 @@ import type {TestResult} from 'types/TestResult'; import chalk from 'chalk'; -import type {ScrollOptions} from './lib/scrollList'; +import type {ScrollOptions} from './lib/scroll_list'; -import scroll from './lib/scrollList'; -import {getTerminalWidth} from './lib/terminalUtils'; -import Prompt from './lib/Prompt'; -import formatTestNameByPattern from './lib/formatTestNameByPattern'; +import scroll from './lib/scroll_list'; +import {getTerminalWidth} from './lib/terminal_utils'; +import Prompt from './lib/prompt'; +import formatTestNameByPattern from './lib/format_test_name_by_pattern'; import { formatTypeaheadSelection, printMore, @@ -24,8 +24,8 @@ import { printRestoredPatternCaret, printStartTyping, printTypeaheadItem, -} from './lib/patternModeHelpers'; -import PatternPrompt from './PatternPrompt'; +} from './lib/pattern_mode_helpers'; +import PatternPrompt from './pattern_prompt'; module.exports = class TestNamePatternPrompt extends PatternPrompt { _cachedTestResults: Array; diff --git a/packages/jest-cli/src/TestPathPatternPrompt.js b/packages/jest-cli/src/test_path_pattern_prompt.js similarity index 90% rename from packages/jest-cli/src/TestPathPatternPrompt.js rename to packages/jest-cli/src/test_path_pattern_prompt.js index 65137eaa6f71..9934bc95cd07 100644 --- a/packages/jest-cli/src/TestPathPatternPrompt.js +++ b/packages/jest-cli/src/test_path_pattern_prompt.js @@ -10,17 +10,17 @@ import type {Context} from 'types/Context'; import type {Test} from 'types/TestRunner'; -import type {ScrollOptions} from './lib/scrollList'; +import type {ScrollOptions} from './lib/scroll_list'; // eslint-disable-next-line import/default -import type SearchSource from './SearchSource'; +import type SearchSource from './search_source'; import chalk from 'chalk'; import stringLength from 'string-length'; -import scroll from './lib/scrollList'; -import {getTerminalWidth} from './lib/terminalUtils'; +import scroll from './lib/scroll_list'; +import {getTerminalWidth} from './lib/terminal_utils'; import highlight from './lib/highlight'; import {trimAndFormatPath} from './reporters/utils'; -import Prompt from './lib/Prompt'; +import Prompt from './lib/prompt'; import { formatTypeaheadSelection, printMore, @@ -29,8 +29,8 @@ import { printRestoredPatternCaret, printStartTyping, printTypeaheadItem, -} from './lib/patternModeHelpers'; -import PatternPrompt from './PatternPrompt'; +} from './lib/pattern_mode_helpers'; +import PatternPrompt from './pattern_prompt'; type SearchSources = Array<{| context: Context, diff --git a/packages/jest-cli/src/testResultHelpers.js b/packages/jest-cli/src/test_result_helpers.js similarity index 100% rename from packages/jest-cli/src/testResultHelpers.js rename to packages/jest-cli/src/test_result_helpers.js diff --git a/packages/jest-cli/src/TestRunner.js b/packages/jest-cli/src/test_runner.js similarity index 95% rename from packages/jest-cli/src/TestRunner.js rename to packages/jest-cli/src/test_runner.js index 3fa0665bd0d3..d4ded03b63c8 100644 --- a/packages/jest-cli/src/TestRunner.js +++ b/packages/jest-cli/src/test_runner.js @@ -16,26 +16,26 @@ import type { import type {GlobalConfig, ReporterConfig} from 'types/Config'; import type {Context} from 'types/Context'; import type {Reporter, Test} from 'types/TestRunner'; -import type {TestSelectionConfig} from './SearchSource'; +import type {TestSelectionConfig} from './search_source'; import {formatExecError} from 'jest-message-util'; import { addResult, buildFailureTestResult, makeEmptyAggregatedTestResult, -} from './testResultHelpers'; +} from './test_result_helpers'; import snapshot from 'jest-snapshot'; import pify from 'pify'; import throat from 'throat'; import workerFarm from 'worker-farm'; -import DefaultReporter from './reporters/DefaultReporter'; -import NotifyReporter from './reporters/NotifyReporter'; -import SummaryReporter from './reporters/SummaryReporter'; -import VerboseReporter from './reporters/VerboseReporter'; -import runTest from './runTest'; -import TestWatcher from './TestWatcher'; -import CoverageReporter from './reporters/CoverageReporter'; -import ReporterDispatcher from './ReporterDispatcher'; +import DefaultReporter from './reporters/default_reporter'; +import NotifyReporter from './reporters/notify_reporter'; +import SummaryReporter from './reporters/summary_reporter'; +import VerboseReporter from './reporters/verbose_reporter'; +import runTest from './run_test'; +import TestWatcher from './test_watcher'; +import CoverageReporter from './reporters/coverage_reporter'; +import ReporterDispatcher from './reporter_dispatcher'; const SLOW_TEST_TIME = 3000; @@ -57,7 +57,7 @@ export type TestRunnerOptions = {| type OnTestFailure = (test: Test, err: TestError) => void; type OnTestSuccess = (test: Test, result: TestResult) => Promise<*>; -const TEST_WORKER_PATH = require.resolve('./TestWorker'); +const TEST_WORKER_PATH = require.resolve('./test_worker'); class TestRunner { _globalConfig: GlobalConfig; diff --git a/packages/jest-cli/src/TestSequencer.js b/packages/jest-cli/src/test_sequencer.js similarity index 100% rename from packages/jest-cli/src/TestSequencer.js rename to packages/jest-cli/src/test_sequencer.js diff --git a/packages/jest-cli/src/TestWatcher.js b/packages/jest-cli/src/test_watcher.js similarity index 100% rename from packages/jest-cli/src/TestWatcher.js rename to packages/jest-cli/src/test_watcher.js diff --git a/packages/jest-cli/src/TestWorker.js b/packages/jest-cli/src/test_worker.js similarity index 98% rename from packages/jest-cli/src/TestWorker.js rename to packages/jest-cli/src/test_worker.js index ff89dd1575f3..0a03be90baab 100644 --- a/packages/jest-cli/src/TestWorker.js +++ b/packages/jest-cli/src/test_worker.js @@ -22,7 +22,7 @@ process.on('uncaughtException', err => { import {ModuleMap} from 'jest-haste-map'; import {separateMessageFromStack} from 'jest-message-util'; import Runtime from 'jest-runtime'; -import runTest from './runTest'; +import runTest from './run_test'; type WorkerData = {| config: ProjectConfig, diff --git a/packages/jest-cli/src/watch.js b/packages/jest-cli/src/watch.js index 26a9156e78b6..b98c94f151c7 100644 --- a/packages/jest-cli/src/watch.js +++ b/packages/jest-cli/src/watch.js @@ -17,16 +17,16 @@ import chalk from 'chalk'; import {replacePathSepForRegex} from 'jest-regex-util'; import HasteMap from 'jest-haste-map'; import isCI from 'is-ci'; -import isValidPath from './lib/isValidPath'; -import preRunMessage from './preRunMessage'; -import createContext from './lib/createContext'; -import runJest from './runJest'; -import updateArgv from './lib/updateArgv'; -import SearchSource from './SearchSource'; -import TestWatcher from './TestWatcher'; -import Prompt from './lib/Prompt'; -import TestPathPatternPrompt from './TestPathPatternPrompt'; -import TestNamePatternPrompt from './TestNamePatternPrompt'; +import isValidPath from './lib/is_valid_path'; +import preRunMessage from './pre_run_message'; +import createContext from './lib/create_context'; +import runJest from './run_jest'; +import updateArgv from './lib/update_argv'; +import SearchSource from './search_source'; +import TestWatcher from './test_watcher'; +import Prompt from './lib/prompt'; +import TestPathPatternPrompt from './test_path_pattern_prompt'; +import TestNamePatternPrompt from './test_name_pattern_prompt'; import {KEYS, CLEAR} from './constants'; const isInteractive = process.stdout.isTTY && !isCI; diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index 6e61a522e859..c26c291df90e 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -272,7 +272,7 @@ describe('haste', () => { const {options} = normalize( { haste: { - hasteImplModulePath: '/hasteImpl.js', + hasteImplModulePath: '/haste_impl.js', }, rootDir: '/root/', }, @@ -280,7 +280,7 @@ describe('haste', () => { ); expect(options.haste).toEqual({ - hasteImplModulePath: '/root/hasteImpl.js', + hasteImplModulePath: '/root/haste_impl.js', }); }); }); diff --git a/packages/jest-config/src/valid_config.js b/packages/jest-config/src/valid_config.js index 3feb3fa07a71..a8c6c0eeea60 100644 --- a/packages/jest-config/src/valid_config.js +++ b/packages/jest-config/src/valid_config.js @@ -67,7 +67,7 @@ module.exports = ({ rootDir: '/', roots: [''], setupFiles: ['/setup.js'], - setupTestFrameworkScriptFile: '/testSetupFile.js', + setupTestFrameworkScriptFile: '/test_setup_file.js', silent: true, snapshotSerializers: ['my-serializer-module'], testEnvironment: 'jest-environment-jsdom', diff --git a/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js b/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js index 73d6c7b325e0..63940a4220e2 100644 --- a/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js +++ b/packages/jest-editor-support/src/__tests__/parsers/babylon_parser.test.js @@ -9,6 +9,6 @@ 'use strict'; const {parse} = require('../../parsers/babylon_parser'); -const {parserTests} = require('../../../../../fixtures/parserTests'); +const {parserTests} = require('../../../../../fixtures/parser_tests'); parserTests(parse); diff --git a/packages/jest-haste-map/src/__tests__/hasteImpl.js b/packages/jest-haste-map/src/__tests__/haste_impl.js similarity index 100% rename from packages/jest-haste-map/src/__tests__/hasteImpl.js rename to packages/jest-haste-map/src/__tests__/haste_impl.js diff --git a/packages/jest-haste-map/src/__tests__/worker.test.js b/packages/jest-haste-map/src/__tests__/worker.test.js index 7287ef656638..867c14578610 100644 --- a/packages/jest-haste-map/src/__tests__/worker.test.js +++ b/packages/jest-haste-map/src/__tests__/worker.test.js @@ -104,7 +104,7 @@ describe('worker', () => { worker( { filePath: '/fruits/strawberry.js', - hasteImplModulePath: path.resolve(__dirname, 'hasteImpl.js'), + hasteImplModulePath: path.resolve(__dirname, 'haste_impl.js'), }, callback, ); diff --git a/packages/jest-haste-map/src/index.js b/packages/jest-haste-map/src/index.js index 571285386e68..d313c1ff0e4c 100644 --- a/packages/jest-haste-map/src/index.js +++ b/packages/jest-haste-map/src/index.js @@ -156,7 +156,7 @@ const getWhiteList = (list: ?Array): ?RegExp => { * }; * * // Modules can be targeted to a specific platform based on the file name. - * // Example: Platform.ios.js and Platform.android.js will both map to the same + * // Example: platform.ios.js and Platform.android.js will both map to the same * // `Platform` module. The platform should be specified during resolution. * type ModuleMapItem = {[platform: string]: ModuleMetaData}; * diff --git a/packages/jest-jasmine2/src/__tests__/integration/lifecycle-hooks-test.js b/packages/jest-jasmine2/src/__tests__/integration/lifecycle_hooks_test.js similarity index 100% rename from packages/jest-jasmine2/src/__tests__/integration/lifecycle-hooks-test.js rename to packages/jest-jasmine2/src/__tests__/integration/lifecycle_hooks_test.js diff --git a/packages/jest-runtime/src/__mocks__/createRuntime.js b/packages/jest-runtime/src/__mocks__/createRuntime.js index bd544fe94a1b..8f3fe23f3a02 100644 --- a/packages/jest-runtime/src/__mocks__/createRuntime.js +++ b/packages/jest-runtime/src/__mocks__/createRuntime.js @@ -41,7 +41,7 @@ module.exports = function createRuntime(filename, config) { config.rootDir, 'subdir2', 'module_dir', - 'moduleDirModule.js', + 'module_dir_module.js', ); return runtime; }); diff --git a/packages/jest-runtime/src/__tests__/NODE_PATH_dir/RegularModuleInNodePath.js b/packages/jest-runtime/src/__tests__/NODE_PATH_dir/regular_module_in_node_path.js similarity index 100% rename from packages/jest-runtime/src/__tests__/NODE_PATH_dir/RegularModuleInNodePath.js rename to packages/jest-runtime/src/__tests__/NODE_PATH_dir/regular_module_in_node_path.js diff --git a/packages/jest-runtime/src/__tests__/__snapshots__/script_transformer.test.js.snap b/packages/jest-runtime/src/__tests__/__snapshots__/script_transformer.test.js.snap index f4311abae9c2..d2deb8aab43b 100644 --- a/packages/jest-runtime/src/__tests__/__snapshots__/script_transformer.test.js.snap +++ b/packages/jest-runtime/src/__tests__/__snapshots__/script_transformer.test.js.snap @@ -15,7 +15,7 @@ exports[`ScriptTransformer uses multiple preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = \\"banana\\";', - config: '{\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"name\\":\\"test\\",\\"rootDir\\":\\"/\\",\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"transform\\":[[\\"^.+\\\\\\\\.js$\\",\\"test-preprocessor\\"],[\\"^.+\\\\\\\\.css$\\",\\"css-preprocessor\\"]]}', + config: '{\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"name\\":\\"test\\",\\"rootDir\\":\\"/\\",\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"transform\\":[[\\"^.+\\\\\\\\.js$\\",\\"test_preprocessor\\"],[\\"^.+\\\\\\\\.css$\\",\\"css-preprocessor\\"]]}', }; }});" @@ -41,7 +41,7 @@ exports[`ScriptTransformer uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = \\"banana\\";', - config: '{\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"name\\":\\"test\\",\\"rootDir\\":\\"/\\",\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"transform\\":[[\\"^.+\\\\\\\\.js$\\",\\"test-preprocessor\\"]]}', + config: '{\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"name\\":\\"test\\",\\"rootDir\\":\\"/\\",\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"transform\\":[[\\"^.+\\\\\\\\.js$\\",\\"test_preprocessor\\"]]}', }; }});" diff --git a/packages/jest-runtime/src/__tests__/instrumentation.test.js b/packages/jest-runtime/src/__tests__/instrumentation.test.js index f779a69b948e..6ec258a70362 100644 --- a/packages/jest-runtime/src/__tests__/instrumentation.test.js +++ b/packages/jest-runtime/src/__tests__/instrumentation.test.js @@ -16,7 +16,7 @@ const os = require('os'); const FILE_PATH_TO_INSTRUMENT = path.resolve( __dirname, - './module_dir/to-be-instrumented.js', + './module_dir/to_be_instrumented.js', ); it('instruments files', () => { diff --git a/packages/jest-runtime/src/__tests__/module_dir/moduleDirectoryFile.js b/packages/jest-runtime/src/__tests__/module_dir/module_directory_file.js similarity index 100% rename from packages/jest-runtime/src/__tests__/module_dir/moduleDirectoryFile.js rename to packages/jest-runtime/src/__tests__/module_dir/module_directory_file.js diff --git a/packages/jest-runtime/src/__tests__/module_dir/to-be-instrumented.js b/packages/jest-runtime/src/__tests__/module_dir/to_be_instrumented.js similarity index 100% rename from packages/jest-runtime/src/__tests__/module_dir/to-be-instrumented.js rename to packages/jest-runtime/src/__tests__/module_dir/to_be_instrumented.js diff --git a/packages/jest-runtime/src/__tests__/runtime_environment.test.js b/packages/jest-runtime/src/__tests__/runtime_environment.test.js index 0be8b2c7f0ad..96d1261165ee 100644 --- a/packages/jest-runtime/src/__tests__/runtime_environment.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_environment.test.js @@ -34,7 +34,7 @@ describe('Runtime', () => { let hasThrown = false; const sum = runtime.requireModule( runtime.__mockRootPath, - './throwing-fn.js', + './throwing_fn.js', ); try { @@ -43,11 +43,11 @@ describe('Runtime', () => { hasThrown = true; if (process.platform === 'win32') { expect(err.stack).toMatch( - /^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\throwing-fn.js:12:9/, + /^Error: throwing fn\s+at sum.+\\__tests__\\test_root\\throwing_fn.js:12:9/, ); } else { expect(err.stack).toMatch( - /^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/throwing-fn.js:12:9/, + /^Error: throwing fn\s+at sum.+\/__tests__\/test_root\/throwing_fn.js:12:9/, ); } } diff --git a/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js b/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js index 044ed4ed5411..ad2ef46bfc1c 100644 --- a/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_internal_module.test.js @@ -23,7 +23,7 @@ describe('Runtime', () => { describe('internalModule', () => { it('loads modules and applies transforms', () => createRuntime(__filename, { - transform: {'^.+\\.js$': './test-preprocessor'}, + transform: {'^.+\\.js$': './test_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), @@ -36,7 +36,7 @@ describe('Runtime', () => { it('loads internal modules without applying transforms', () => createRuntime(__filename, { - transform: {'^.+\\.js$': './test-preprocessor'}, + transform: {'^.+\\.js$': './test_preprocessor'}, }).then(runtime => { const modulePath = path.resolve( path.dirname(runtime.__mockRootPath), diff --git a/packages/jest-runtime/src/__tests__/Runtime-jest-fn.js b/packages/jest-runtime/src/__tests__/runtime_jest_fn.js similarity index 100% rename from packages/jest-runtime/src/__tests__/Runtime-jest-fn.js rename to packages/jest-runtime/src/__tests__/runtime_jest_fn.js diff --git a/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js b/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js index 830edf9601ae..6d049e3743b4 100644 --- a/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js @@ -28,7 +28,7 @@ describe('Runtime', () => { }).then(runtime => { const exports = runtime.requireModule( runtime.__mockRootPath, - 'moduleDirModule', + 'module_dir_module', ); expect(exports).toBeDefined(); })); @@ -47,11 +47,11 @@ describe('Runtime', () => { it('finds closest module from moduleDirectories', () => createRuntime(__filename, {moduleDirectories}).then(runtime => { const exports = runtime.requireModule( - path.join(rootDir, 'subdir2', 'MyModule.js'), - 'moduleDirModule', + path.join(rootDir, 'subdir2', 'my_module.js'), + 'module_dir_module', ); expect(exports.modulePath).toEqual( - 'subdir2/module_dir/moduleDirModule.js', + 'subdir2/module_dir/module_dir_module.js', ); })); diff --git a/packages/jest-runtime/src/__tests__/runtime_node_path.test.js b/packages/jest-runtime/src/__tests__/runtime_node_path.test.js index e167d9b0b9fa..0ec0069890e4 100644 --- a/packages/jest-runtime/src/__tests__/runtime_node_path.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_node_path.test.js @@ -31,7 +31,7 @@ describe('Runtime', () => { return createLocalRuntime(nodePath).then(runtime => { const exports = runtime.requireModuleOrMock( runtime.__mockRootPath, - 'RegularModuleInNodePath', + 'regular_module_in_node_path', ); expect(exports).toBeDefined(); }); @@ -42,7 +42,7 @@ describe('Runtime', () => { return createLocalRuntime(null, {modulePaths: [nodePath]}).then(runtime => { const exports = runtime.requireModuleOrMock( runtime.__mockRootPath, - 'RegularModuleInNodePath', + 'regular_module_in_node_path', ); expect(exports).toBeDefined(); }); @@ -54,7 +54,7 @@ describe('Runtime', () => { return createLocalRuntime(nodePath).then(runtime => { const exports = runtime.requireModuleOrMock( runtime.__mockRootPath, - 'RegularModuleInNodePath', + 'regular_module_in_node_path', ); expect(exports).toBeDefined(); }); @@ -67,11 +67,11 @@ describe('Runtime', () => { expect(() => { runtime.requireModuleOrMock( runtime.__mockRootPath, - 'RegularModuleInNodePath', + 'regular_module_in_node_path', ); }).toThrow( new Error( - `Cannot find module 'RegularModuleInNodePath' from 'root.js'`, + `Cannot find module 'regular_module_in_node_path' from 'root.js'`, ), ); }); diff --git a/packages/jest-runtime/src/__tests__/runtime_require_mock.test.js b/packages/jest-runtime/src/__tests__/runtime_require_mock.test.js index fcc3dfc29716..508ab70936f5 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_mock.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_mock.test.js @@ -149,15 +149,15 @@ describe('Runtime', () => { expect(console.warn).toBeCalled(); const exports1 = runtime.requireMock( runtime.__mockRootPath, - './subdir1/MyModule', + './subdir1/my_module', ); - expect(exports1.modulePath).toEqual('subdir1/__mocks__/MyModule.js'); + expect(exports1.modulePath).toEqual('subdir1/__mocks__/my_module.js'); const exports2 = runtime.requireMock( runtime.__mockRootPath, - './subdir2/MyModule', + './subdir2/my_module', ); - expect(exports2.modulePath).toEqual('subdir2/__mocks__/MyModule.js'); + expect(exports2.modulePath).toEqual('subdir2/__mocks__/my_module.js'); }); }); }); diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 062680d4929f..382ad3432d29 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -258,7 +258,7 @@ describe('Runtime requireModule', () => { createRuntime(__filename).then(runtime => { const exports = runtime.requireModule( runtime.__mockRootPath, - './UTF8WithBOM.js', + './utf8_with_bom.js', ); expect(exports).toBe('isModuleEncodedInUTF8WithBOM'); })); @@ -267,7 +267,7 @@ describe('Runtime requireModule', () => { createRuntime(__filename).then(runtime => { const exports = runtime.requireModule( runtime.__mockRootPath, - './UTF8WithBOM.json', + './utf8_with_bom.json', ); expect(exports.isJSONModuleEncodedInUTF8WithBOM).toBe(true); })); diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js index 4f9a2748c1d9..0191df7edba9 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js @@ -12,10 +12,10 @@ const moduleNameMapper = { '\\.css$': '/__mocks__/ManuallyMocked', '^[./a-zA-Z0-9$_-]+\.png$': 'RelativeImageStub', - '^image![a-zA-Z0-9$_-]+$': 'GlobalImageStub', + '^image![a-zA-Z0-9$_-]+$': 'global_image_stub', mappedToDirectory: '/MyDirectoryModule', mappedToModule: '/TestModuleNameMapperResolution', - mappedToPath: '/GlobalImageStub.js', + mappedToPath: '/global_image_stub.js', 'module/name/(.*)': '/mapped_module_$1.js', }; @@ -106,7 +106,7 @@ it('resolves mapped module names and unmocks them by default', () => }).then(runtime => { let exports = runtime.requireModuleOrMock( runtime.__mockRootPath, - 'image!not-really-a-module', + 'image!not_really_a_module', ); expect(exports.isGlobalImageStub).toBe(true); diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js index ffab717d7eb7..a1e12cdf7ffc 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js @@ -13,10 +13,10 @@ let createRuntime; const moduleNameMapper = { '^[./a-zA-Z0-9$_-]+\.png$': 'RelativeImageStub', - '^image![a-zA-Z0-9$_-]+$': 'GlobalImageStub', + '^image![a-zA-Z0-9$_-]+$': 'global_image_stub', '^testMapped/(.*)': '/mapped_dir/$1', mappedToDirectory: '/MyDirectoryModule', - mappedToPath: '/GlobalImageStub.js', + mappedToPath: '/global_image_stub.js', 'module/name/(.*)': '/mapped_module_$1.js', }; @@ -47,7 +47,7 @@ describe('transitive dependencies', () => { const parentDep = runtime.requireModule( runtime.__mockRootPath, - './depOnMappedModule.js', + './dep_on_mapped_module.js', ); expect(parentDep).toEqual({result: 'mocked_in_mapped'}); })); diff --git a/packages/jest-runtime/src/__tests__/script_transformer.test.js b/packages/jest-runtime/src/__tests__/script_transformer.test.js index cc1971409f0e..c1c1b5d56a20 100644 --- a/packages/jest-runtime/src/__tests__/script_transformer.test.js +++ b/packages/jest-runtime/src/__tests__/script_transformer.test.js @@ -24,7 +24,7 @@ jest .mock('vm'); jest.mock( - 'test-preprocessor', + 'test_preprocessor', () => { const escapeStrings = str => { return str.replace(/'/, `'`); @@ -233,12 +233,12 @@ describe('ScriptTransformer', () => { it('uses the supplied preprocessor', () => { config = Object.assign(config, { - transform: [['^.+\\.js$', 'test-preprocessor']], + transform: [['^.+\\.js$', 'test_preprocessor']], }); const scriptTransformer = new ScriptTransformer(config); scriptTransformer.transform('/fruits/banana.js', {}); - expect(require('test-preprocessor').getCacheKey).toBeCalled(); + expect(require('test_preprocessor').getCacheKey).toBeCalled(); expect(vm.Script.mock.calls[0][0]).toMatchSnapshot(); @@ -250,7 +250,7 @@ describe('ScriptTransformer', () => { it('uses multiple preprocessors', () => { config = Object.assign(config, { transform: [ - ['^.+\\.js$', 'test-preprocessor'], + ['^.+\\.js$', 'test_preprocessor'], ['^.+\\.css$', 'css-preprocessor'], ], }); @@ -259,7 +259,7 @@ describe('ScriptTransformer', () => { scriptTransformer.transform('/fruits/banana.js', {}); scriptTransformer.transform('/styles/App.css', {}); - expect(require('test-preprocessor').getCacheKey).toBeCalled(); + expect(require('test_preprocessor').getCacheKey).toBeCalled(); expect(require('css-preprocessor').getCacheKey).toBeCalled(); expect(vm.Script.mock.calls[0][0]).toMatchSnapshot(); expect(vm.Script.mock.calls[1][0]).toMatchSnapshot(); @@ -353,7 +353,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache', () => { const transformConfig = Object.assign(config, { - transform: [['^.+\\.js$', 'test-preprocessor']], + transform: [['^.+\\.js$', 'test_preprocessor']], }); let scriptTransformer = new ScriptTransformer(transformConfig); scriptTransformer.transform('/fruits/banana.js', {}); diff --git a/packages/jest-runtime/src/__tests__/test_root/depOnMappedModule.js b/packages/jest-runtime/src/__tests__/test_root/dep_on_mapped_module.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/depOnMappedModule.js rename to packages/jest-runtime/src/__tests__/test_root/dep_on_mapped_module.js diff --git a/packages/jest-runtime/src/__tests__/test_root/GlobalImageStub.js b/packages/jest-runtime/src/__tests__/test_root/global_image_stub.js similarity index 90% rename from packages/jest-runtime/src/__tests__/test_root/GlobalImageStub.js rename to packages/jest-runtime/src/__tests__/test_root/global_image_stub.js index 0fd8277e653e..a07525a17a18 100644 --- a/packages/jest-runtime/src/__tests__/test_root/GlobalImageStub.js +++ b/packages/jest-runtime/src/__tests__/test_root/global_image_stub.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule GlobalImageStub + * @providesModule global_image_stub */ 'use strict'; diff --git a/packages/jest-runtime/src/__tests__/test_root/module_dir/module_dir_module.js b/packages/jest-runtime/src/__tests__/test_root/module_dir/module_dir_module.js new file mode 100644 index 000000000000..09bf7b994d9e --- /dev/null +++ b/packages/jest-runtime/src/__tests__/test_root/module_dir/module_dir_module.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +exports.modulePath = 'module_dir/module_dir_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root/platform/Platform.android.js b/packages/jest-runtime/src/__tests__/test_root/platform/platform.android.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/platform/Platform.android.js rename to packages/jest-runtime/src/__tests__/test_root/platform/platform.android.js diff --git a/packages/jest-runtime/src/__tests__/test_root/platform/Platform.ios.js b/packages/jest-runtime/src/__tests__/test_root/platform/platform.ios.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/platform/Platform.ios.js rename to packages/jest-runtime/src/__tests__/test_root/platform/platform.ios.js diff --git a/packages/jest-runtime/src/__tests__/test_root/platform/Platform.js b/packages/jest-runtime/src/__tests__/test_root/platform/platform.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/platform/Platform.js rename to packages/jest-runtime/src/__tests__/test_root/platform/platform.js diff --git a/packages/jest-runtime/src/__tests__/test_root/platform/Platform.native.js b/packages/jest-runtime/src/__tests__/test_root/platform/platform.native.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/platform/Platform.native.js rename to packages/jest-runtime/src/__tests__/test_root/platform/platform.native.js diff --git a/packages/jest-runtime/src/__tests__/test_root/root.js b/packages/jest-runtime/src/__tests__/test_root/root.js index 4ec2d1328278..d05cb3713838 100644 --- a/packages/jest-runtime/src/__tests__/test_root/root.js +++ b/packages/jest-runtime/src/__tests__/test_root/root.js @@ -17,7 +17,7 @@ require('RegularModule'); // We only care about the static analysis, not about the runtime. const lazyRequire = () => { - require('image!not-really-a-module'); + require('image!not_really_a_module'); require('cat.png'); require('dog.png'); }; diff --git a/packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/moduleDirModule.js b/packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/module_dir_module.js similarity index 83% rename from packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/moduleDirModule.js rename to packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/module_dir_module.js index b9f4e0a28d11..145796b83885 100644 --- a/packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/moduleDirModule.js +++ b/packages/jest-runtime/src/__tests__/test_root/subdir2/module_dir/module_dir_module.js @@ -8,4 +8,4 @@ 'use strict'; -exports.modulePath = 'subdir2/module_dir/moduleDirModule.js'; +exports.modulePath = 'subdir2/module_dir/module_dir_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root/test-preprocessor.js b/packages/jest-runtime/src/__tests__/test_root/test_preprocessor.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/test-preprocessor.js rename to packages/jest-runtime/src/__tests__/test_root/test_preprocessor.js diff --git a/packages/jest-runtime/src/__tests__/test_root/throwing-fn.js b/packages/jest-runtime/src/__tests__/test_root/throwing_fn.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/throwing-fn.js rename to packages/jest-runtime/src/__tests__/test_root/throwing_fn.js diff --git a/packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.js b/packages/jest-runtime/src/__tests__/test_root/utf8_with_bom.js similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.js rename to packages/jest-runtime/src/__tests__/test_root/utf8_with_bom.js diff --git a/packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.json b/packages/jest-runtime/src/__tests__/test_root/utf8_with_bom.json similarity index 100% rename from packages/jest-runtime/src/__tests__/test_root/UTF8WithBOM.json rename to packages/jest-runtime/src/__tests__/test_root/utf8_with_bom.json diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/MyModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/my_module.js similarity index 85% rename from packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/MyModule.js rename to packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/my_module.js index c238d4b6775c..dece48e6245a 100644 --- a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/MyModule.js +++ b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/__mocks__/my_module.js @@ -8,4 +8,4 @@ 'use strict'; -exports.modulePath = 'subdir1/__mocks__/MyModule.js'; +exports.modulePath = 'subdir1/__mocks__/my_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/MyModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/my_module.js similarity index 87% rename from packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/MyModule.js rename to packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/my_module.js index ebffbf30be76..8a91474b48db 100644 --- a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/MyModule.js +++ b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/my_module.js @@ -8,4 +8,4 @@ 'use strict'; -exports.modulePath = 'subdir2/MyModule.js'; +exports.modulePath = 'subdir1/my_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/MyModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/MyModule.js deleted file mode 100644 index b0b7a50d4a9e..000000000000 --- a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/MyModule.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -exports.modulePath = 'subdir2/__mocks__/MyModule.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root/module_dir/moduleDirModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/my_module.js similarity index 85% rename from packages/jest-runtime/src/__tests__/test_root/module_dir/moduleDirModule.js rename to packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/my_module.js index c40f376bed09..1a644ae5fa04 100644 --- a/packages/jest-runtime/src/__tests__/test_root/module_dir/moduleDirModule.js +++ b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/__mocks__/my_module.js @@ -8,4 +8,4 @@ 'use strict'; -exports.modulePath = 'module_dir/moduleDirModule.js'; +exports.modulePath = 'subdir2/__mocks__/my_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/moduleDirModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/moduleDirModule.js deleted file mode 100644 index b9f4e0a28d11..000000000000 --- a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/moduleDirModule.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -exports.modulePath = 'subdir2/module_dir/moduleDirModule.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/module_dir_module.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/module_dir_module.js new file mode 100644 index 000000000000..145796b83885 --- /dev/null +++ b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/module_dir/module_dir_module.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +exports.modulePath = 'subdir2/module_dir/module_dir_module.js'; diff --git a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/MyModule.js b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/my_module.js similarity index 87% rename from packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/MyModule.js rename to packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/my_module.js index a39d2eea1e9b..748327ed4b51 100644 --- a/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir1/MyModule.js +++ b/packages/jest-runtime/src/__tests__/test_root_with_dup_mocks/subdir2/my_module.js @@ -8,4 +8,4 @@ 'use strict'; -exports.modulePath = 'subdir1/MyModule.js'; +exports.modulePath = 'subdir2/my_module.js'; diff --git a/packages/jest-runtime/src/index.js b/packages/jest-runtime/src/index.js index 99c04ceb5eeb..f27a4bf2a459 100644 --- a/packages/jest-runtime/src/index.js +++ b/packages/jest-runtime/src/index.js @@ -362,14 +362,14 @@ class Runtime { // If the actual module file has a __mocks__ dir sitting immediately next // to it, look to see if there is a manual mock for this file. // - // subDir1/MyModule.js - // subDir1/__mocks__/MyModule.js - // subDir2/MyModule.js - // subDir2/__mocks__/MyModule.js + // subDir1/my_module.js + // subDir1/__mocks__/my_module.js + // subDir2/my_module.js + // subDir2/__mocks__/my_module.js // // Where some other module does a relative require into each of the // respective subDir{1,2} directories and expects a manual mock - // corresponding to that particular MyModule.js file. + // corresponding to that particular my_module.js file. const moduleDir = path.dirname(modulePath); const moduleFileName = path.basename(modulePath); const potentialManualMock = path.join( diff --git a/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js b/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js index 1cfef59ce3fd..7999cd43e22b 100644 --- a/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js +++ b/packages/jest-test-typescript-parser/src/__tests__/type_script_parser.test.js @@ -9,6 +9,6 @@ 'use strict'; const {parse} = require('../type_script_parser'); -const {parserTests} = require('../../../../fixtures/parserTests'); +const {parserTests} = require('../../../../fixtures/parser_tests'); parserTests(parse); diff --git a/packages/jest-validate/src/__tests__/fixtures/jest_config.js b/packages/jest-validate/src/__tests__/fixtures/jest_config.js index 3c39fac6bf6c..96182af17529 100644 --- a/packages/jest-validate/src/__tests__/fixtures/jest_config.js +++ b/packages/jest-validate/src/__tests__/fixtures/jest_config.js @@ -101,7 +101,7 @@ const validConfig = { rootDir: '/', roots: [''], setupFiles: ['/setup.js'], - setupTestFrameworkScriptFile: '/testSetupFile.js', + setupTestFrameworkScriptFile: '/test_setup_file.js', silent: true, snapshotSerializers: ['my-serializer-module'], testEnvironment: 'jest-environment-jsdom', diff --git a/packages/pretty-format/src/__tests__/expect-util.js b/packages/pretty-format/src/__tests__/expect_util.js similarity index 100% rename from packages/pretty-format/src/__tests__/expect-util.js rename to packages/pretty-format/src/__tests__/expect_util.js diff --git a/packages/pretty-format/src/__tests__/html_element.test.js b/packages/pretty-format/src/__tests__/html_element.test.js index 4cfabc627e2f..ba91c0ed66c8 100644 --- a/packages/pretty-format/src/__tests__/html_element.test.js +++ b/packages/pretty-format/src/__tests__/html_element.test.js @@ -12,7 +12,7 @@ 'use strict'; const HTMLElementPlugin = require('../plugins/html_element'); -const toPrettyPrintTo = require('./expect-util').getPrettyPrint([ +const toPrettyPrintTo = require('./expect_util').getPrettyPrint([ HTMLElementPlugin, ]); diff --git a/packages/pretty-format/src/__tests__/immutable.test.js b/packages/pretty-format/src/__tests__/immutable.test.js index 64b540627982..ffa432af477a 100644 --- a/packages/pretty-format/src/__tests__/immutable.test.js +++ b/packages/pretty-format/src/__tests__/immutable.test.js @@ -13,7 +13,7 @@ const Immutable = require('immutable'); const ReactElementPlugin = require('../plugins/react_element'); const ReactTestComponentPlugin = require('../plugins/react_test_component'); const ImmutablePlugins = require('../plugins/immutable_plugins'); -const toPrettyPrintTo = require('./expect-util').getPrettyPrint( +const toPrettyPrintTo = require('./expect_util').getPrettyPrint( [ReactElementPlugin, ReactTestComponentPlugin].concat(ImmutablePlugins), ); diff --git a/testSetupFile.js b/test_setup_file.js similarity index 100% rename from testSetupFile.js rename to test_setup_file.js diff --git a/yarn.lock b/yarn.lock index c49f1f470ee6..a900c0e19e26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2195,6 +2195,16 @@ eslint-plugin-react@^7.1.0: has "^1.0.1" jsx-ast-utils "^1.4.1" +eslint-plugin-unicorn@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-2.1.2.tgz#99dffe9f4773b04bc39356a7febd64dd700274bc" + dependencies: + import-modules "^1.1.0" + lodash.camelcase "^4.1.1" + lodash.kebabcase "^4.0.1" + lodash.snakecase "^4.0.1" + lodash.upperfirst "^4.2.0" + eslint-scope@^3.7.1: version "3.7.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" @@ -2670,7 +2680,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@7.1.1, glob@^7.1.1: +glob@7.1.1, glob@^7.1.0, glob@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -2681,7 +2691,7 @@ glob@7.1.1, glob@^7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.0, glob@^7.1.2: +glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -2889,11 +2899,11 @@ https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" -iconv-lite@0.4.13, iconv-lite@~0.4.13: +iconv-lite@0.4.13: version "0.4.13" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2" -iconv-lite@0.4.15: +iconv-lite@0.4.15, iconv-lite@~0.4.13: version "0.4.15" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" @@ -2913,6 +2923,10 @@ immutable@^4.0.0-rc.1: version "4.0.0-rc.2" resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0-rc.2.tgz#fdd0948aae728fda2306a02f72bb73e1773432d1" +import-modules@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/import-modules/-/import-modules-1.1.0.tgz#748db79c5cc42bb9701efab424f894e72600e9dc" + imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -3716,6 +3730,10 @@ lodash.bind@^4.1.4: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" +lodash.camelcase@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + lodash.cond@^4.3.0: version "4.5.2" resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" @@ -3752,6 +3770,10 @@ lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" +lodash.kebabcase@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36" + lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -3784,6 +3806,10 @@ lodash.reject@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" +lodash.snakecase@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d" + lodash.some@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" @@ -3801,6 +3827,10 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" +lodash.upperfirst@^4.2.0: + version "4.3.1" + resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce" + lodash@^3.10.1, lodash@^3.8.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" @@ -5342,7 +5372,7 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" -supports-color@3.1.2: +supports-color@3.1.2, supports-color@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" dependencies: @@ -5352,12 +5382,6 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -supports-color@^3.1.2: - version "3.2.3" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" - dependencies: - has-flag "^1.0.0" - symbol-tree@^3.2.1: version "3.2.2" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"