diff options
author | Joel Kronqvist <work.joelkronqvist@pm.me> | 2022-03-11 20:46:06 +0200 |
---|---|---|
committer | Joel Kronqvist <work.joelkronqvist@pm.me> | 2022-03-11 20:46:06 +0200 |
commit | 080c5819d87b933816d724a83f3bf4f1686770a7 (patch) | |
tree | 4a2ccc68b27edf7d4cbc586c932cc7542b655e19 /node_modules/jest-cli | |
parent | 5ac7049a9d30733165cc212dee308163c2a14644 (diff) | |
parent | d003b82235a9329f912522a2f70aa950dfce4998 (diff) | |
download | LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.tar.gz LYLLRuoka-080c5819d87b933816d724a83f3bf4f1686770a7.zip |
Merge branch 'master' of https://github.com/JoelHMikael/FoodJS
Updating remote changes
Diffstat (limited to 'node_modules/jest-cli')
22 files changed, 2141 insertions, 0 deletions
diff --git a/node_modules/jest-cli/LICENSE b/node_modules/jest-cli/LICENSE new file mode 100644 index 0000000..b96dcb0 --- /dev/null +++ b/node_modules/jest-cli/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Facebook, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/jest-cli/README.md b/node_modules/jest-cli/README.md new file mode 100644 index 0000000..9c3d31e --- /dev/null +++ b/node_modules/jest-cli/README.md @@ -0,0 +1,11 @@ +# Jest + +🃏 Delightful JavaScript Testing + +- **👩🏻💻 Developer Ready**: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project. + +- **🏃🏽 Instant Feedback**: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files. + +- **📸 Snapshot Testing**: Jest can [capture snapshots](https://jestjs.io/docs/snapshot-testing) of React trees or other serializable values to simplify UI testing. + +Read More: https://jestjs.io/ diff --git a/node_modules/jest-cli/bin/jest.js b/node_modules/jest-cli/bin/jest.js new file mode 100755 index 0000000..146fb2c --- /dev/null +++ b/node_modules/jest-cli/bin/jest.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const importLocal = require('import-local'); + +if (!importLocal(__filename)) { + if (process.env.NODE_ENV == null) { + process.env.NODE_ENV = 'test'; + } + + require('..').run(); +} diff --git a/node_modules/jest-cli/build/cli/args.d.ts b/node_modules/jest-cli/build/cli/args.d.ts new file mode 100644 index 0000000..28d4fee --- /dev/null +++ b/node_modules/jest-cli/build/cli/args.d.ts @@ -0,0 +1,448 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import type { Config } from '@jest/types'; +export declare function check(argv: Config.Argv): true; +export declare const usage = "Usage: $0 [--config=<pathToConfigFile>] [TestPathPattern]"; +export declare const docs = "Documentation: https://jestjs.io/"; +export declare const options: { + readonly all: { + readonly description: string; + readonly type: "boolean"; + }; + readonly automock: { + readonly description: "Automock all files by default."; + readonly type: "boolean"; + }; + readonly bail: { + readonly alias: "b"; + readonly description: "Exit the test suite immediately after `n` number of failing tests."; + readonly type: "boolean"; + }; + readonly cache: { + readonly description: string; + readonly type: "boolean"; + }; + readonly cacheDirectory: { + readonly description: string; + readonly type: "string"; + }; + readonly changedFilesWithAncestor: { + readonly description: string; + readonly type: "boolean"; + }; + readonly changedSince: { + readonly description: string; + readonly nargs: 1; + readonly type: "string"; + }; + readonly ci: { + readonly description: string; + readonly type: "boolean"; + }; + readonly clearCache: { + readonly description: string; + readonly type: "boolean"; + }; + readonly clearMocks: { + readonly description: string; + readonly type: "boolean"; + }; + readonly collectCoverage: { + readonly description: "Alias for --coverage."; + readonly type: "boolean"; + }; + readonly collectCoverageFrom: { + readonly description: string; + readonly type: "string"; + }; + readonly collectCoverageOnlyFrom: { + readonly description: "Explicit list of paths coverage will be restricted to."; + readonly string: true; + readonly type: "array"; + }; + readonly color: { + readonly description: string; + readonly type: "boolean"; + }; + readonly colors: { + readonly description: "Alias for `--color`."; + readonly type: "boolean"; + }; + readonly config: { + readonly alias: "c"; + readonly description: string; + readonly type: "string"; + }; + readonly coverage: { + readonly description: string; + readonly type: "boolean"; + }; + readonly coverageDirectory: { + readonly description: "The directory where Jest should output its coverage files."; + readonly type: "string"; + }; + readonly coveragePathIgnorePatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly coverageProvider: { + readonly choices: readonly ["babel", "v8"]; + readonly description: "Select between Babel and V8 to collect coverage"; + }; + readonly coverageReporters: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly coverageThreshold: { + readonly description: string; + readonly type: "string"; + }; + readonly debug: { + readonly description: "Print debugging info about your jest config."; + readonly type: "boolean"; + }; + readonly detectLeaks: { + readonly description: string; + readonly type: "boolean"; + }; + readonly detectOpenHandles: { + readonly description: string; + readonly type: "boolean"; + }; + readonly env: { + readonly description: string; + readonly type: "string"; + }; + readonly errorOnDeprecated: { + readonly description: "Make calling deprecated APIs throw helpful error messages."; + readonly type: "boolean"; + }; + readonly expand: { + readonly alias: "e"; + readonly description: "Use this flag to show full diffs instead of a patch."; + readonly type: "boolean"; + }; + readonly filter: { + readonly description: string; + readonly type: "string"; + }; + readonly findRelatedTests: { + readonly description: string; + readonly type: "boolean"; + }; + readonly forceExit: { + readonly description: string; + readonly type: "boolean"; + }; + readonly globalSetup: { + readonly description: "The path to a module that runs before All Tests."; + readonly type: "string"; + }; + readonly globalTeardown: { + readonly description: "The path to a module that runs after All Tests."; + readonly type: "string"; + }; + readonly globals: { + readonly description: string; + readonly type: "string"; + }; + readonly haste: { + readonly description: "A JSON string with map of variables for the haste module system"; + readonly type: "string"; + }; + readonly init: { + readonly description: "Generate a basic configuration file"; + readonly type: "boolean"; + }; + readonly injectGlobals: { + readonly description: "Should Jest inject global variables or not"; + readonly type: "boolean"; + }; + readonly json: { + readonly description: string; + readonly type: "boolean"; + }; + readonly lastCommit: { + readonly description: string; + readonly type: "boolean"; + }; + readonly listTests: { + readonly description: string; + readonly type: "boolean"; + }; + readonly logHeapUsage: { + readonly description: string; + readonly type: "boolean"; + }; + readonly maxConcurrency: { + readonly description: string; + readonly type: "number"; + }; + readonly maxWorkers: { + readonly alias: "w"; + readonly description: string; + readonly type: "string"; + }; + readonly moduleDirectories: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly moduleFileExtensions: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly moduleNameMapper: { + readonly description: string; + readonly type: "string"; + }; + readonly modulePathIgnorePatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly modulePaths: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly noStackTrace: { + readonly description: "Disables stack trace in test results output"; + readonly type: "boolean"; + }; + readonly notify: { + readonly description: "Activates notifications for test results."; + readonly type: "boolean"; + }; + readonly notifyMode: { + readonly description: "Specifies when notifications will appear for test results."; + readonly type: "string"; + }; + readonly onlyChanged: { + readonly alias: "o"; + readonly description: string; + readonly type: "boolean"; + }; + readonly onlyFailures: { + readonly alias: "f"; + readonly description: "Run tests that failed in the previous execution."; + readonly type: "boolean"; + }; + readonly outputFile: { + readonly description: string; + readonly type: "string"; + }; + readonly passWithNoTests: { + readonly description: "Will not fail if no tests are found (for example while using `--testPathPattern`.)"; + readonly type: "boolean"; + }; + readonly preset: { + readonly description: "A preset that is used as a base for Jest's configuration."; + readonly type: "string"; + }; + readonly prettierPath: { + readonly description: "The path to the \"prettier\" module used for inline snapshots."; + readonly type: "string"; + }; + readonly projects: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly reporters: { + readonly description: "A list of custom reporters for the test suite."; + readonly string: true; + readonly type: "array"; + }; + readonly resetMocks: { + readonly description: string; + readonly type: "boolean"; + }; + readonly resetModules: { + readonly description: string; + readonly type: "boolean"; + }; + readonly resolver: { + readonly description: "A JSON string which allows the use of a custom resolver."; + readonly type: "string"; + }; + readonly restoreMocks: { + readonly description: string; + readonly type: "boolean"; + }; + readonly rootDir: { + readonly description: string; + readonly type: "string"; + }; + readonly roots: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly runInBand: { + readonly alias: "i"; + readonly description: string; + readonly type: "boolean"; + }; + readonly runTestsByPath: { + readonly description: string; + readonly type: "boolean"; + }; + readonly runner: { + readonly description: "Allows to use a custom runner instead of Jest's default test runner."; + readonly type: "string"; + }; + readonly selectProjects: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly setupFiles: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly setupFilesAfterEnv: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly showConfig: { + readonly description: "Print your jest config and then exits."; + readonly type: "boolean"; + }; + readonly silent: { + readonly description: "Prevent tests from printing messages through the console."; + readonly type: "boolean"; + }; + readonly skipFilter: { + readonly description: string; + readonly type: "boolean"; + }; + readonly snapshotSerializers: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly testEnvironment: { + readonly description: "Alias for --env"; + readonly type: "string"; + }; + readonly testEnvironmentOptions: { + readonly description: string; + readonly type: "string"; + }; + readonly testFailureExitCode: { + readonly description: "Exit code of `jest` command if the test run failed"; + readonly type: "string"; + }; + readonly testLocationInResults: { + readonly description: "Add `location` information to the test results"; + readonly type: "boolean"; + }; + readonly testMatch: { + readonly description: "The glob patterns Jest uses to detect test files."; + readonly string: true; + readonly type: "array"; + }; + readonly testNamePattern: { + readonly alias: "t"; + readonly description: "Run only tests with a name that matches the regex pattern."; + readonly type: "string"; + }; + readonly testPathIgnorePatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly testPathPattern: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly testRegex: { + readonly description: "A string or array of string regexp patterns that Jest uses to detect test files."; + readonly string: true; + readonly type: "array"; + }; + readonly testResultsProcessor: { + readonly description: string; + readonly type: "string"; + }; + readonly testRunner: { + readonly description: string; + readonly type: "string"; + }; + readonly testSequencer: { + readonly description: string; + readonly type: "string"; + }; + readonly testTimeout: { + readonly description: "This option sets the default timeouts of test cases."; + readonly type: "number"; + }; + readonly testURL: { + readonly description: "This option sets the URL for the jsdom environment."; + readonly type: "string"; + }; + readonly timers: { + readonly description: string; + readonly type: "string"; + }; + readonly transform: { + readonly description: string; + readonly type: "string"; + }; + readonly transformIgnorePatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly unmockedModulePathPatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly updateSnapshot: { + readonly alias: "u"; + readonly description: string; + readonly type: "boolean"; + }; + readonly useStderr: { + readonly description: "Divert all output to stderr."; + readonly type: "boolean"; + }; + readonly verbose: { + readonly description: "Display individual test results with the test suite hierarchy."; + readonly type: "boolean"; + }; + readonly version: { + readonly alias: "v"; + readonly description: "Print the version and exit"; + readonly type: "boolean"; + }; + readonly watch: { + readonly description: string; + readonly type: "boolean"; + }; + readonly watchAll: { + readonly description: string; + readonly type: "boolean"; + }; + readonly watchPathIgnorePatterns: { + readonly description: string; + readonly string: true; + readonly type: "array"; + }; + readonly watchman: { + readonly description: string; + readonly type: "boolean"; + }; +}; diff --git a/node_modules/jest-cli/build/cli/args.js b/node_modules/jest-cli/build/cli/args.js new file mode 100644 index 0000000..fac8d87 --- /dev/null +++ b/node_modules/jest-cli/build/cli/args.js @@ -0,0 +1,710 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.check = check; +exports.usage = exports.options = exports.docs = void 0; + +function _jestConfig() { + const data = require('jest-config'); + + _jestConfig = function () { + return data; + }; + + return data; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +function check(argv) { + if (argv.runInBand && argv.hasOwnProperty('maxWorkers')) { + throw new Error( + 'Both --runInBand and --maxWorkers were specified, but these two ' + + 'options do not make sense together. Which is it?' + ); + } + + for (const key of [ + 'onlyChanged', + 'lastCommit', + 'changedFilesWithAncestor', + 'changedSince' + ]) { + if (argv[key] && argv.watchAll) { + throw new Error( + `Both --${key} and --watchAll were specified, but these two ` + + 'options do not make sense together. Try the --watch option which ' + + 'reruns only tests related to changed files.' + ); + } + } + + if (argv.onlyFailures && argv.watchAll) { + throw new Error( + 'Both --onlyFailures and --watchAll were specified, but these two ' + + 'options do not make sense together.' + ); + } + + if (argv.findRelatedTests && argv._.length === 0) { + throw new Error( + 'The --findRelatedTests option requires file paths to be specified.\n' + + 'Example usage: jest --findRelatedTests ./src/source.js ' + + './src/index.js.' + ); + } + + if (argv.hasOwnProperty('maxWorkers') && argv.maxWorkers === undefined) { + throw new Error( + 'The --maxWorkers (-w) option requires a number or string to be specified.\n' + + 'Example usage: jest --maxWorkers 2\n' + + 'Example usage: jest --maxWorkers 50%\n' + + 'Or did you mean --watch?' + ); + } + + if (argv.selectProjects && argv.selectProjects.length === 0) { + throw new Error( + 'The --selectProjects option requires the name of at least one project to be specified.\n' + + 'Example usage: jest --selectProjects my-first-project my-second-project' + ); + } + + if ( + argv.config && + !(0, _jestConfig().isJSONString)(argv.config) && + !argv.config.match( + new RegExp( + `\\.(${_jestConfig() + .constants.JEST_CONFIG_EXT_ORDER.map(e => e.substring(1)) + .join('|')})$`, + 'i' + ) + ) + ) { + throw new Error( + `The --config option requires a JSON string literal, or a file path with one of these extensions: ${_jestConfig().constants.JEST_CONFIG_EXT_ORDER.join( + ', ' + )}.\nExample usage: jest --config ./jest.config.js` + ); + } + + return true; +} + +const usage = 'Usage: $0 [--config=<pathToConfigFile>] [TestPathPattern]'; +exports.usage = usage; +const docs = 'Documentation: https://jestjs.io/'; // The default values are all set in jest-config + +exports.docs = docs; +const options = { + all: { + description: + 'The opposite of `onlyChanged`. If `onlyChanged` is set by ' + + 'default, running jest with `--all` will force Jest to run all tests ' + + 'instead of running only tests related to changed files.', + type: 'boolean' + }, + automock: { + description: 'Automock all files by default.', + type: 'boolean' + }, + bail: { + alias: 'b', + description: + 'Exit the test suite immediately after `n` number of failing tests.', + type: 'boolean' + }, + cache: { + description: + 'Whether to use the transform cache. Disable the cache ' + + 'using --no-cache.', + type: 'boolean' + }, + cacheDirectory: { + description: + 'The directory where Jest should store its cached ' + + ' dependency information.', + type: 'string' + }, + changedFilesWithAncestor: { + description: + 'Runs tests related to the current changes and the changes made in the ' + + 'last commit. Behaves similarly to `--onlyChanged`.', + type: 'boolean' + }, + changedSince: { + description: + 'Runs tests related to the changes since the provided branch. If the ' + + 'current branch has diverged from the given branch, then only changes ' + + 'made locally will be tested. Behaves similarly to `--onlyChanged`.', + nargs: 1, + type: 'string' + }, + ci: { + description: + 'Whether to run Jest in continuous integration (CI) mode. ' + + 'This option is on by default in most popular CI environments. It will ' + + 'prevent snapshots from being written unless explicitly requested.', + type: 'boolean' + }, + clearCache: { + description: + 'Clears the configured Jest cache directory and then exits. ' + + 'Default directory can be found by calling jest --showConfig', + type: 'boolean' + }, + clearMocks: { + description: + 'Automatically clear mock calls, instances and results before every test. ' + + 'Equivalent to calling jest.clearAllMocks() before each test.', + type: 'boolean' + }, + collectCoverage: { + description: 'Alias for --coverage.', + type: 'boolean' + }, + collectCoverageFrom: { + description: + 'A glob pattern relative to <rootDir> matching the files that coverage ' + + 'info needs to be collected from.', + type: 'string' + }, + collectCoverageOnlyFrom: { + description: 'Explicit list of paths coverage will be restricted to.', + string: true, + type: 'array' + }, + color: { + description: + 'Forces test results output color highlighting (even if ' + + 'stdout is not a TTY). Set to false if you would like to have no colors.', + type: 'boolean' + }, + colors: { + description: 'Alias for `--color`.', + type: 'boolean' + }, + config: { + alias: 'c', + description: + 'The path to a jest config file specifying how to find ' + + 'and execute tests. If no rootDir is set in the config, the directory ' + + 'containing the config file is assumed to be the rootDir for the project.' + + 'This can also be a JSON encoded value which Jest will use as configuration.', + type: 'string' + }, + coverage: { + description: + 'Indicates that test coverage information should be ' + + 'collected and reported in the output.', + type: 'boolean' + }, + coverageDirectory: { + description: 'The directory where Jest should output its coverage files.', + type: 'string' + }, + coveragePathIgnorePatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all file paths before executing the test. If the file path' + + 'matches any of the patterns, coverage information will be skipped.', + string: true, + type: 'array' + }, + coverageProvider: { + choices: ['babel', 'v8'], + description: 'Select between Babel and V8 to collect coverage' + }, + coverageReporters: { + description: + 'A list of reporter names that Jest uses when writing ' + + 'coverage reports. Any istanbul reporter can be used.', + string: true, + type: 'array' + }, + coverageThreshold: { + description: + 'A JSON string with which will be used to configure ' + + 'minimum threshold enforcement for coverage results', + type: 'string' + }, + debug: { + description: 'Print debugging info about your jest config.', + type: 'boolean' + }, + detectLeaks: { + description: + '**EXPERIMENTAL**: Detect memory leaks in tests. After executing a ' + + 'test, it will try to garbage collect the global object used, and fail ' + + 'if it was leaked', + type: 'boolean' + }, + detectOpenHandles: { + description: + 'Print out remaining open handles preventing Jest from exiting at the ' + + 'end of a test run. Implies `runInBand`.', + type: 'boolean' + }, + env: { + description: + 'The test environment used for all tests. This can point to ' + + 'any file or node module. Examples: `jsdom`, `node` or ' + + '`path/to/my-environment.js`', + type: 'string' + }, + errorOnDeprecated: { + description: 'Make calling deprecated APIs throw helpful error messages.', + type: 'boolean' + }, + expand: { + alias: 'e', + description: 'Use this flag to show full diffs instead of a patch.', + type: 'boolean' + }, + filter: { + description: + 'Path to a module exporting a filtering function. This method receives ' + + 'a list of tests which can be manipulated to exclude tests from ' + + 'running. Especially useful when used in conjunction with a testing ' + + 'infrastructure to filter known broken tests.', + type: 'string' + }, + findRelatedTests: { + description: + 'Find related tests for a list of source files that were ' + + 'passed in as arguments. Useful for pre-commit hook integration to run ' + + 'the minimal amount of tests necessary.', + type: 'boolean' + }, + forceExit: { + description: + 'Force Jest to exit after all tests have completed running. ' + + 'This is useful when resources set up by test code cannot be ' + + 'adequately cleaned up.', + type: 'boolean' + }, + globalSetup: { + description: 'The path to a module that runs before All Tests.', + type: 'string' + }, + globalTeardown: { + description: 'The path to a module that runs after All Tests.', + type: 'string' + }, + globals: { + description: + 'A JSON string with map of global variables that need ' + + 'to be available in all test environments.', + type: 'string' + }, + haste: { + description: + 'A JSON string with map of variables for the haste module system', + type: 'string' + }, + init: { + description: 'Generate a basic configuration file', + type: 'boolean' + }, + injectGlobals: { + description: 'Should Jest inject global variables or not', + type: 'boolean' + }, + json: { + description: + 'Prints the test results in JSON. This mode will send all ' + + 'other test output and user messages to stderr.', + type: 'boolean' + }, + lastCommit: { + description: + 'Run all tests affected by file changes in the last commit made. ' + + 'Behaves similarly to `--onlyChanged`.', + type: 'boolean' + }, + listTests: { + description: + 'Lists all tests Jest will run given the arguments and ' + + 'exits. Most useful in a CI system together with `--findRelatedTests` ' + + 'to determine the tests Jest will run based on specific files', + type: 'boolean' + }, + logHeapUsage: { + description: + 'Logs the heap usage after every test. Useful to debug ' + + 'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' + + 'node.', + type: 'boolean' + }, + maxConcurrency: { + description: + 'Specifies the maximum number of tests that are allowed to run' + + 'concurrently. This only affects tests using `test.concurrent`.', + type: 'number' + }, + maxWorkers: { + alias: 'w', + description: + 'Specifies the maximum number of workers the worker-pool ' + + 'will spawn for running tests. This defaults to the number of the ' + + 'cores available on your machine. (its usually best not to override ' + + 'this default)', + type: 'string' + }, + moduleDirectories: { + description: + 'An array of directory names to be searched recursively ' + + "up from the requiring module's location.", + string: true, + type: 'array' + }, + moduleFileExtensions: { + description: + 'An array of file extensions your modules use. If you ' + + 'require modules without specifying a file extension, these are the ' + + 'extensions Jest will look for. ', + string: true, + type: 'array' + }, + moduleNameMapper: { + description: + 'A JSON string with a map from regular expressions to ' + + 'module names or to arrays of module names that allow to stub ' + + 'out resources, like images or styles with a single module', + type: 'string' + }, + modulePathIgnorePatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all module paths before those paths are to be considered ' + + '"visible" to the module loader.', + string: true, + type: 'array' + }, + modulePaths: { + description: + 'An alternative API to setting the NODE_PATH env variable, ' + + 'modulePaths is an array of absolute paths to additional locations to ' + + 'search when resolving modules.', + string: true, + type: 'array' + }, + noStackTrace: { + description: 'Disables stack trace in test results output', + type: 'boolean' + }, + notify: { + description: 'Activates notifications for test results.', + type: 'boolean' + }, + notifyMode: { + description: 'Specifies when notifications will appear for test results.', + type: 'string' + }, + onlyChanged: { + alias: 'o', + description: + 'Attempts to identify which tests to run based on which ' + + "files have changed in the current repository. Only works if you're " + + 'running tests in a git or hg repository at the moment.', + type: 'boolean' + }, + onlyFailures: { + alias: 'f', + description: 'Run tests that failed in the previous execution.', + type: 'boolean' + }, + outputFile: { + description: + 'Write test results to a file when the --json option is ' + + 'also specified.', + type: 'string' + }, + passWithNoTests: { + description: + 'Will not fail if no tests are found (for example while using `--testPathPattern`.)', + type: 'boolean' + }, + preset: { + description: "A preset that is used as a base for Jest's configuration.", + type: 'string' + }, + prettierPath: { + description: 'The path to the "prettier" module used for inline snapshots.', + type: 'string' + }, + projects: { + description: + 'A list of projects that use Jest to run all tests of all ' + + 'projects in a single instance of Jest.', + string: true, + type: 'array' + }, + reporters: { + description: 'A list of custom reporters for the test suite.', + string: true, + type: 'array' + }, + resetMocks: { + description: + 'Automatically reset mock state before every test. ' + + 'Equivalent to calling jest.resetAllMocks() before each test.', + type: 'boolean' + }, + resetModules: { + description: + 'If enabled, the module registry for every test file will ' + + 'be reset before running each individual test.', + type: 'boolean' + }, + resolver: { + description: 'A JSON string which allows the use of a custom resolver.', + type: 'string' + }, + restoreMocks: { + description: + 'Automatically restore mock state and implementation before every test. ' + + 'Equivalent to calling jest.restoreAllMocks() before each test.', + type: 'boolean' + }, + rootDir: { + description: + 'The root directory that Jest should scan for tests and ' + + 'modules within.', + type: 'string' + }, + roots: { + description: + 'A list of paths to directories that Jest should use to ' + + 'search for files in.', + string: true, + type: 'array' + }, + runInBand: { + alias: 'i', + description: + 'Run all tests serially in the current process (rather than ' + + 'creating a worker pool of child processes that run tests). This ' + + 'is sometimes useful for debugging, but such use cases are pretty ' + + 'rare.', + type: 'boolean' + }, + runTestsByPath: { + description: + 'Used when provided patterns are exact file paths. This avoids ' + + 'converting them into a regular expression and matching it against ' + + 'every single file.', + type: 'boolean' + }, + runner: { + description: + "Allows to use a custom runner instead of Jest's default test runner.", + type: 'string' + }, + selectProjects: { + description: + 'Run only the tests of the specified projects.' + + 'Jest uses the attribute `displayName` in the configuration to identify each project.', + string: true, + type: 'array' + }, + setupFiles: { + description: + 'A list of paths to modules that run some code to configure or ' + + 'set up the testing environment before each test. ', + string: true, + type: 'array' + }, + setupFilesAfterEnv: { + description: + 'A list of paths to modules that run some code to configure or ' + + 'set up the testing framework before each test ', + string: true, + type: 'array' + }, + showConfig: { + description: 'Print your jest config and then exits.', + type: 'boolean' + }, + silent: { + description: 'Prevent tests from printing messages through the console.', + type: 'boolean' + }, + skipFilter: { + description: + 'Disables the filter provided by --filter. Useful for CI jobs, or ' + + 'local enforcement when fixing tests.', + type: 'boolean' + }, + snapshotSerializers: { + description: + 'A list of paths to snapshot serializer modules Jest should ' + + 'use for snapshot testing.', + string: true, + type: 'array' + }, + testEnvironment: { + description: 'Alias for --env', + type: 'string' + }, + testEnvironmentOptions: { + description: + 'A JSON string with options that will be passed to the `testEnvironment`. ' + + 'The relevant options depend on the environment.', + type: 'string' + }, + testFailureExitCode: { + description: 'Exit code of `jest` command if the test run failed', + type: 'string' // number + }, + testLocationInResults: { + description: 'Add `location` information to the test results', + type: 'boolean' + }, + testMatch: { + description: 'The glob patterns Jest uses to detect test files.', + string: true, + type: 'array' + }, + testNamePattern: { + alias: 't', + description: 'Run only tests with a name that matches the regex pattern.', + type: 'string' + }, + testPathIgnorePatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all test paths before executing the test. If the test path ' + + 'matches any of the patterns, it will be skipped.', + string: true, + type: 'array' + }, + testPathPattern: { + description: + 'A regexp pattern string that is matched against all tests ' + + 'paths before executing the test.', + string: true, + type: 'array' + }, + testRegex: { + description: + 'A string or array of string regexp patterns that Jest uses to detect test files.', + string: true, + type: 'array' + }, + testResultsProcessor: { + description: + 'Allows the use of a custom results processor. ' + + 'This processor must be a node module that exports ' + + 'a function expecting as the first argument the result object.', + type: 'string' + }, + testRunner: { + description: + 'Allows to specify a custom test runner. The default is' + + ' `jest-circus/runner`. A path to a custom test runner can be provided:' + + ' `<rootDir>/path/to/testRunner.js`.', + type: 'string' + }, + testSequencer: { + description: + 'Allows to specify a custom test sequencer. The default is ' + + '`@jest/test-sequencer`. A path to a custom test sequencer can be ' + + 'provided: `<rootDir>/path/to/testSequencer.js`', + type: 'string' + }, + testTimeout: { + description: 'This option sets the default timeouts of test cases.', + type: 'number' + }, + testURL: { + description: 'This option sets the URL for the jsdom environment.', + type: 'string' + }, + timers: { + description: + 'Setting this value to fake allows the use of fake timers ' + + 'for functions such as setTimeout.', + type: 'string' + }, + transform: { + description: + 'A JSON string which maps from regular expressions to paths ' + + 'to transformers.', + type: 'string' + }, + transformIgnorePatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all source file paths before transformation.', + string: true, + type: 'array' + }, + unmockedModulePathPatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all modules before the module loader will automatically ' + + 'return a mock for them.', + string: true, + type: 'array' + }, + updateSnapshot: { + alias: 'u', + description: + 'Use this flag to re-record snapshots. ' + + 'Can be used together with a test suite pattern or with ' + + '`--testNamePattern` to re-record snapshot for test matching ' + + 'the pattern', + type: 'boolean' + }, + useStderr: { + description: 'Divert all output to stderr.', + type: 'boolean' + }, + verbose: { + description: + 'Display individual test results with the test suite hierarchy.', + type: 'boolean' + }, + version: { + alias: 'v', + description: 'Print the version and exit', + type: 'boolean' + }, + watch: { + description: + 'Watch files for changes and rerun tests related to ' + + 'changed files. If you want to re-run all tests when a file has ' + + 'changed, use the `--watchAll` option.', + type: 'boolean' + }, + watchAll: { + description: + 'Watch files for changes and rerun all tests. If you want ' + + 'to re-run only the tests related to the changed files, use the ' + + '`--watch` option.', + type: 'boolean' + }, + watchPathIgnorePatterns: { + description: + 'An array of regexp pattern strings that are matched ' + + 'against all paths before trigger test re-run in watch mode. ' + + 'If the test path matches any of the patterns, it will be skipped.', + string: true, + type: 'array' + }, + watchman: { + description: + 'Whether to use watchman for file crawling. Disable using ' + + '--no-watchman.', + type: 'boolean' + } +}; +exports.options = options; diff --git a/node_modules/jest-cli/build/cli/index.d.ts b/node_modules/jest-cli/build/cli/index.d.ts new file mode 100644 index 0000000..f93e0bf --- /dev/null +++ b/node_modules/jest-cli/build/cli/index.d.ts @@ -0,0 +1,9 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import type { Config } from '@jest/types'; +export declare function run(maybeArgv?: Array<string>, project?: Config.Path): Promise<void>; +export declare const buildArgv: (maybeArgv?: string[] | undefined) => Config.Argv; diff --git a/node_modules/jest-cli/build/cli/index.js b/node_modules/jest-cli/build/cli/index.js new file mode 100644 index 0000000..fed680b --- /dev/null +++ b/node_modules/jest-cli/build/cli/index.js @@ -0,0 +1,265 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.buildArgv = void 0; +exports.run = run; + +function path() { + const data = _interopRequireWildcard(require('path')); + + path = function () { + return data; + }; + + return data; +} + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function _exit() { + const data = _interopRequireDefault(require('exit')); + + _exit = function () { + return data; + }; + + return data; +} + +function _yargs() { + const data = _interopRequireDefault(require('yargs')); + + _yargs = function () { + return data; + }; + + return data; +} + +function _core() { + const data = require('@jest/core'); + + _core = function () { + return data; + }; + + return data; +} + +function _jestConfig() { + const data = require('jest-config'); + + _jestConfig = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +function _jestValidate() { + const data = require('jest-validate'); + + _jestValidate = function () { + return data; + }; + + return data; +} + +var _init = _interopRequireDefault(require('../init')); + +var args = _interopRequireWildcard(require('./args')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null; + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + newObj.default = obj; + if (cache) { + cache.set(obj, newObj); + } + return newObj; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +async function run(maybeArgv, project) { + try { + const argv = buildArgv(maybeArgv); + + if (argv.init) { + await (0, _init.default)(); + return; + } + + const projects = getProjectListFromCLIArgs(argv, project); + const {results, globalConfig} = await (0, _core().runCLI)(argv, projects); + readResultsAndExit(results, globalConfig); + } catch (error) { + (0, _jestUtil().clearLine)(process.stderr); + (0, _jestUtil().clearLine)(process.stdout); + + if (error !== null && error !== void 0 && error.stack) { + console.error(_chalk().default.red(error.stack)); + } else { + console.error(_chalk().default.red(error)); + } + + (0, _exit().default)(1); + throw error; + } +} + +const buildArgv = maybeArgv => { + const version = + (0, _core().getVersion)() + + (__dirname.includes(`packages${path().sep}jest-cli`) ? '-dev' : ''); + const rawArgv = maybeArgv || process.argv.slice(2); + const argv = (0, _yargs().default)(rawArgv) + .usage(args.usage) + .version(version) + .alias('help', 'h') + .options(args.options) + .epilogue(args.docs) + .check(args.check).argv; + (0, _jestValidate().validateCLIOptions)( + argv, + {...args.options, deprecationEntries: _jestConfig().deprecationEntries}, // strip leading dashes + Array.isArray(rawArgv) + ? rawArgv.map(rawArgv => rawArgv.replace(/^--?/, '')) + : Object.keys(rawArgv) + ); // strip dashed args + + return Object.keys(argv).reduce( + (result, key) => { + if (!key.includes('-')) { + result[key] = argv[key]; + } + + return result; + }, + { + $0: argv.$0, + _: argv._ + } + ); +}; + +exports.buildArgv = buildArgv; + +const getProjectListFromCLIArgs = (argv, project) => { + const projects = argv.projects ? argv.projects : []; + + if (project) { + projects.push(project); + } + + if (!projects.length && process.platform === 'win32') { + try { + projects.push((0, _jestUtil().tryRealpath)(process.cwd())); + } catch { + // do nothing, just catch error + // process.binding('fs').realpath can throw, e.g. on mapped drives + } + } + + if (!projects.length) { + projects.push(process.cwd()); + } + + return projects; +}; + +const readResultsAndExit = (result, globalConfig) => { + const code = !result || result.success ? 0 : globalConfig.testFailureExitCode; // Only exit if needed + + process.on('exit', () => { + if (typeof code === 'number' && code !== 0) { + process.exitCode = code; + } + }); + + if (globalConfig.forceExit) { + if (!globalConfig.detectOpenHandles) { + console.warn( + _chalk().default.bold('Force exiting Jest: ') + + 'Have you considered using `--detectOpenHandles` to detect ' + + 'async operations that kept running after all tests finished?' + ); + } + + (0, _exit().default)(code); + } else if (!globalConfig.detectOpenHandles) { + setTimeout(() => { + console.warn( + _chalk().default.yellow.bold( + 'Jest did not exit one second after the test run has completed.\n\n' + ) + + _chalk().default.yellow( + 'This usually means that there are asynchronous operations that ' + + "weren't stopped in your tests. Consider running Jest with " + + '`--detectOpenHandles` to troubleshoot this issue.' + ) + ); + }, 1000).unref(); + } +}; diff --git a/node_modules/jest-cli/build/index.d.ts b/node_modules/jest-cli/build/index.d.ts new file mode 100644 index 0000000..00cb5fe --- /dev/null +++ b/node_modules/jest-cli/build/index.d.ts @@ -0,0 +1,7 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +export { run } from './cli'; diff --git a/node_modules/jest-cli/build/index.js b/node_modules/jest-cli/build/index.js new file mode 100644 index 0000000..fdfb92e --- /dev/null +++ b/node_modules/jest-cli/build/index.js @@ -0,0 +1,13 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +Object.defineProperty(exports, 'run', { + enumerable: true, + get: function () { + return _cli.run; + } +}); + +var _cli = require('./cli'); diff --git a/node_modules/jest-cli/build/init/errors.d.ts b/node_modules/jest-cli/build/init/errors.d.ts new file mode 100644 index 0000000..426fdc0 --- /dev/null +++ b/node_modules/jest-cli/build/init/errors.d.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +export declare class NotFoundPackageJsonError extends Error { + constructor(rootDir: string); +} +export declare class MalformedPackageJsonError extends Error { + constructor(packageJsonPath: string); +} diff --git a/node_modules/jest-cli/build/init/errors.js b/node_modules/jest-cli/build/init/errors.js new file mode 100644 index 0000000..5059519 --- /dev/null +++ b/node_modules/jest-cli/build/init/errors.js @@ -0,0 +1,35 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.NotFoundPackageJsonError = exports.MalformedPackageJsonError = void 0; + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +class NotFoundPackageJsonError extends Error { + constructor(rootDir) { + super(`Could not find a "package.json" file in ${rootDir}`); + this.name = ''; + Error.captureStackTrace(this, () => {}); + } +} + +exports.NotFoundPackageJsonError = NotFoundPackageJsonError; + +class MalformedPackageJsonError extends Error { + constructor(packageJsonPath) { + super( + `There is malformed json in ${packageJsonPath}\n` + + 'Fix it, and then run "jest --init"' + ); + this.name = ''; + Error.captureStackTrace(this, () => {}); + } +} + +exports.MalformedPackageJsonError = MalformedPackageJsonError; diff --git a/node_modules/jest-cli/build/init/generateConfigFile.d.ts b/node_modules/jest-cli/build/init/generateConfigFile.d.ts new file mode 100644 index 0000000..c5afd8d --- /dev/null +++ b/node_modules/jest-cli/build/init/generateConfigFile.d.ts @@ -0,0 +1,8 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +declare const generateConfigFile: (results: Record<string, unknown>, generateEsm?: boolean) => string; +export default generateConfigFile; diff --git a/node_modules/jest-cli/build/init/generateConfigFile.js b/node_modules/jest-cli/build/init/generateConfigFile.js new file mode 100644 index 0000000..773e692 --- /dev/null +++ b/node_modules/jest-cli/build/init/generateConfigFile.js @@ -0,0 +1,104 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +function _jestConfig() { + const data = require('jest-config'); + + _jestConfig = function () { + return data; + }; + + return data; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const stringifyOption = (option, map, linePrefix = '') => { + const optionDescription = ` // ${_jestConfig().descriptions[option]}`; + const stringifiedObject = `${option}: ${JSON.stringify( + map[option], + null, + 2 + )}`; + return ( + optionDescription + + '\n' + + stringifiedObject + .split('\n') + .map(line => ' ' + linePrefix + line) + .join('\n') + + ',\n' + ); +}; + +const generateConfigFile = (results, generateEsm = false) => { + const {useTypescript, coverage, coverageProvider, clearMocks, environment} = + results; + const overrides = {}; + + if (coverage) { + Object.assign(overrides, { + collectCoverage: true, + coverageDirectory: 'coverage' + }); + } + + if (coverageProvider === 'v8') { + Object.assign(overrides, { + coverageProvider: 'v8' + }); + } + + if (environment === 'jsdom') { + Object.assign(overrides, { + testEnvironment: 'jsdom' + }); + } + + if (clearMocks) { + Object.assign(overrides, { + clearMocks: true + }); + } + + const overrideKeys = Object.keys(overrides); + const properties = []; + + for (const option in _jestConfig().descriptions) { + const opt = option; + + if (overrideKeys.includes(opt)) { + properties.push(stringifyOption(opt, overrides)); + } else { + properties.push(stringifyOption(opt, _jestConfig().defaults, '// ')); + } + } + + const configHeaderMessage = `/* + * For a detailed explanation regarding each configuration property${ + useTypescript ? ' and type check' : '' + }, visit: + * https://jestjs.io/docs/configuration + */ + +`; + return ( + configHeaderMessage + + (useTypescript || generateEsm + ? 'export default {\n' + : 'module.exports = {\n') + + properties.join('\n') + + '};\n' + ); +}; + +var _default = generateConfigFile; +exports.default = _default; diff --git a/node_modules/jest-cli/build/init/index.d.ts b/node_modules/jest-cli/build/init/index.d.ts new file mode 100644 index 0000000..a412b5a --- /dev/null +++ b/node_modules/jest-cli/build/init/index.d.ts @@ -0,0 +1,7 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +export default function init(rootDir?: string): Promise<void>; diff --git a/node_modules/jest-cli/build/init/index.js b/node_modules/jest-cli/build/init/index.js new file mode 100644 index 0000000..839c659 --- /dev/null +++ b/node_modules/jest-cli/build/init/index.js @@ -0,0 +1,246 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = init; + +function path() { + const data = _interopRequireWildcard(require('path')); + + path = function () { + return data; + }; + + return data; +} + +function _chalk() { + const data = _interopRequireDefault(require('chalk')); + + _chalk = function () { + return data; + }; + + return data; +} + +function fs() { + const data = _interopRequireWildcard(require('graceful-fs')); + + fs = function () { + return data; + }; + + return data; +} + +function _prompts() { + const data = _interopRequireDefault(require('prompts')); + + _prompts = function () { + return data; + }; + + return data; +} + +function _jestConfig() { + const data = require('jest-config'); + + _jestConfig = function () { + return data; + }; + + return data; +} + +function _jestUtil() { + const data = require('jest-util'); + + _jestUtil = function () { + return data; + }; + + return data; +} + +var _errors = require('./errors'); + +var _generateConfigFile = _interopRequireDefault( + require('./generateConfigFile') +); + +var _modifyPackageJson = _interopRequireDefault(require('./modifyPackageJson')); + +var _questions = _interopRequireWildcard(require('./questions')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : {default: obj}; +} + +function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== 'function') return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function (nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +} + +function _interopRequireWildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) { + return obj; + } + if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { + return {default: obj}; + } + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) { + return cache.get(obj); + } + var newObj = {}; + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor; + for (var key in obj) { + if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null; + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + newObj.default = obj; + if (cache) { + cache.set(obj, newObj); + } + return newObj; +} + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const { + JEST_CONFIG_BASE_NAME, + JEST_CONFIG_EXT_MJS, + JEST_CONFIG_EXT_JS, + JEST_CONFIG_EXT_TS, + JEST_CONFIG_EXT_ORDER, + PACKAGE_JSON +} = _jestConfig().constants; + +const getConfigFilename = ext => JEST_CONFIG_BASE_NAME + ext; + +async function init(rootDir = (0, _jestUtil().tryRealpath)(process.cwd())) { + // prerequisite checks + const projectPackageJsonPath = path().join(rootDir, PACKAGE_JSON); + + if (!fs().existsSync(projectPackageJsonPath)) { + throw new _errors.NotFoundPackageJsonError(rootDir); + } + + const questions = _questions.default.slice(0); + + let hasJestProperty = false; + let projectPackageJson; + + try { + projectPackageJson = JSON.parse( + fs().readFileSync(projectPackageJsonPath, 'utf-8') + ); + } catch { + throw new _errors.MalformedPackageJsonError(projectPackageJsonPath); + } + + if (projectPackageJson.jest) { + hasJestProperty = true; + } + + const existingJestConfigExt = JEST_CONFIG_EXT_ORDER.find(ext => + fs().existsSync(path().join(rootDir, getConfigFilename(ext))) + ); + + if (hasJestProperty || existingJestConfigExt) { + const result = await (0, _prompts().default)({ + initial: true, + message: + 'It seems that you already have a jest configuration, do you want to override it?', + name: 'continue', + type: 'confirm' + }); + + if (!result.continue) { + console.log(); + console.log('Aborting...'); + return; + } + } // Add test script installation only if needed + + if ( + !projectPackageJson.scripts || + projectPackageJson.scripts.test !== 'jest' + ) { + questions.unshift(_questions.testScriptQuestion); + } // Start the init process + + console.log(); + console.log( + _chalk().default.underline( + 'The following questions will help Jest to create a suitable configuration for your project\n' + ) + ); + let promptAborted = false; // @ts-expect-error: Return type cannot be object - faulty typings + + const results = await (0, _prompts().default)(questions, { + onCancel: () => { + promptAborted = true; + } + }); + + if (promptAborted) { + console.log(); + console.log('Aborting...'); + return; + } // Determine if Jest should use JS or TS for the config file + + const jestConfigFileExt = results.useTypescript + ? JEST_CONFIG_EXT_TS + : projectPackageJson.type === 'module' + ? JEST_CONFIG_EXT_MJS + : JEST_CONFIG_EXT_JS; // Determine Jest config path + + const jestConfigPath = existingJestConfigExt + ? getConfigFilename(existingJestConfigExt) + : path().join(rootDir, getConfigFilename(jestConfigFileExt)); + const shouldModifyScripts = results.scripts; + + if (shouldModifyScripts || hasJestProperty) { + const modifiedPackageJson = (0, _modifyPackageJson.default)({ + projectPackageJson, + shouldModifyScripts + }); + fs().writeFileSync(projectPackageJsonPath, modifiedPackageJson); + console.log(''); + console.log( + `✏️ Modified ${_chalk().default.cyan(projectPackageJsonPath)}` + ); + } + + const generatedConfig = (0, _generateConfigFile.default)( + results, + projectPackageJson.type === 'module' || + jestConfigPath.endsWith(JEST_CONFIG_EXT_MJS) + ); + fs().writeFileSync(jestConfigPath, generatedConfig); + console.log(''); + console.log( + `📝 Configuration file created at ${_chalk().default.cyan(jestConfigPath)}` + ); +} diff --git a/node_modules/jest-cli/build/init/modifyPackageJson.d.ts b/node_modules/jest-cli/build/init/modifyPackageJson.d.ts new file mode 100644 index 0000000..30e92fe --- /dev/null +++ b/node_modules/jest-cli/build/init/modifyPackageJson.d.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import type { ProjectPackageJson } from './types'; +declare const modifyPackageJson: ({ projectPackageJson, shouldModifyScripts, }: { + projectPackageJson: ProjectPackageJson; + shouldModifyScripts: boolean; +}) => string; +export default modifyPackageJson; diff --git a/node_modules/jest-cli/build/init/modifyPackageJson.js b/node_modules/jest-cli/build/init/modifyPackageJson.js new file mode 100644 index 0000000..526b485 --- /dev/null +++ b/node_modules/jest-cli/build/init/modifyPackageJson.js @@ -0,0 +1,28 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.default = void 0; + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const modifyPackageJson = ({projectPackageJson, shouldModifyScripts}) => { + if (shouldModifyScripts) { + projectPackageJson.scripts + ? (projectPackageJson.scripts.test = 'jest') + : (projectPackageJson.scripts = { + test: 'jest' + }); + } + + delete projectPackageJson.jest; + return JSON.stringify(projectPackageJson, null, 2) + '\n'; +}; + +var _default = modifyPackageJson; +exports.default = _default; diff --git a/node_modules/jest-cli/build/init/questions.d.ts b/node_modules/jest-cli/build/init/questions.d.ts new file mode 100644 index 0000000..4d261ad --- /dev/null +++ b/node_modules/jest-cli/build/init/questions.d.ts @@ -0,0 +1,10 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import type { PromptObject } from 'prompts'; +declare const defaultQuestions: Array<PromptObject>; +export default defaultQuestions; +export declare const testScriptQuestion: PromptObject; diff --git a/node_modules/jest-cli/build/init/questions.js b/node_modules/jest-cli/build/init/questions.js new file mode 100644 index 0000000..42fc582 --- /dev/null +++ b/node_modules/jest-cli/build/init/questions.js @@ -0,0 +1,76 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); +exports.testScriptQuestion = exports.default = void 0; + +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +const defaultQuestions = [ + { + initial: false, + message: 'Would you like to use Typescript for the configuration file?', + name: 'useTypescript', + type: 'confirm' + }, + { + choices: [ + { + title: 'node', + value: 'node' + }, + { + title: 'jsdom (browser-like)', + value: 'jsdom' + } + ], + initial: 0, + message: 'Choose the test environment that will be used for testing', + name: 'environment', + type: 'select' + }, + { + initial: false, + message: 'Do you want Jest to add coverage reports?', + name: 'coverage', + type: 'confirm' + }, + { + choices: [ + { + title: 'v8', + value: 'v8' + }, + { + title: 'babel', + value: 'babel' + } + ], + initial: 0, + message: 'Which provider should be used to instrument code for coverage?', + name: 'coverageProvider', + type: 'select' + }, + { + initial: false, + message: + 'Automatically clear mock calls, instances and results before every test?', + name: 'clearMocks', + type: 'confirm' + } +]; +var _default = defaultQuestions; +exports.default = _default; +const testScriptQuestion = { + initial: true, + message: + 'Would you like to use Jest when running "test" script in "package.json"?', + name: 'scripts', + type: 'confirm' +}; +exports.testScriptQuestion = testScriptQuestion; diff --git a/node_modules/jest-cli/build/init/types.d.ts b/node_modules/jest-cli/build/init/types.d.ts new file mode 100644 index 0000000..5b5a340 --- /dev/null +++ b/node_modules/jest-cli/build/init/types.d.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import type { Config } from '@jest/types'; +export declare type ProjectPackageJson = { + jest?: Partial<Config.InitialOptions>; + scripts?: Record<string, string>; + type?: 'commonjs' | 'module'; +}; diff --git a/node_modules/jest-cli/build/init/types.js b/node_modules/jest-cli/build/init/types.js new file mode 100644 index 0000000..ad9a93a --- /dev/null +++ b/node_modules/jest-cli/build/init/types.js @@ -0,0 +1 @@ +'use strict'; diff --git a/node_modules/jest-cli/package.json b/node_modules/jest-cli/package.json new file mode 100644 index 0000000..519ac1f --- /dev/null +++ b/node_modules/jest-cli/package.json @@ -0,0 +1,89 @@ +{ + "name": "jest-cli", + "description": "Delightful JavaScript Testing.", + "version": "27.5.1", + "main": "./build/index.js", + "types": "./build/index.d.ts", + "exports": { + ".": { + "types": "./build/index.d.ts", + "default": "./build/index.js" + }, + "./package.json": "./package.json", + "./bin/jest": "./bin/jest.js" + }, + "dependencies": { + "@jest/core": "^27.5.1", + "@jest/test-result": "^27.5.1", + "@jest/types": "^27.5.1", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "import-local": "^3.0.2", + "jest-config": "^27.5.1", + "jest-util": "^27.5.1", + "jest-validate": "^27.5.1", + "prompts": "^2.0.1", + "yargs": "^16.2.0" + }, + "devDependencies": { + "@types/exit": "^0.1.30", + "@types/graceful-fs": "^4.1.3", + "@types/prompts": "^2.0.1", + "@types/yargs": "^16.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + }, + "bin": { + "jest": "./bin/jest.js" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/facebook/jest", + "directory": "packages/jest-cli" + }, + "bugs": { + "url": "https://github.com/facebook/jest/issues" + }, + "homepage": "https://jestjs.io/", + "license": "MIT", + "keywords": [ + "ava", + "babel", + "coverage", + "easy", + "expect", + "facebook", + "immersive", + "instant", + "jasmine", + "jest", + "jsdom", + "mocha", + "mocking", + "painless", + "qunit", + "runner", + "sandboxed", + "snapshot", + "tap", + "tape", + "test", + "testing", + "typescript", + "watch" + ], + "publishConfig": { + "access": "public" + }, + "gitHead": "67c1aa20c5fec31366d733e901fee2b981cb1850" +} |