From 5ff6e7a89a2fb85f87e6b9875446ee3f59336e20 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 6 Mar 2019 13:39:12 +0100 Subject: [PATCH 1/4] chore: delete flow types from the repo --- .circleci/config.yml | 2 +- .eslintrc.js | 2 +- .flowconfig | 23 - flow-typed/co.js | 12 - flow-typed/console.js | 32 - flow-typed/graceful-fs.js | 167 --- flow-typed/is-generator-fn.js | 12 - flow-typed/npm/glob_v7.1.x.js | 87 -- flow-typed/npm/jest_v23.x.x.js | 1131 ----------------- flow-typed/resolve.js | 24 - flow-typed/stack-utils.js | 23 - package.json | 6 +- packages/jest-circus/runner.js | 2 - .../src/__tests__/circusItTestError.test.ts | 4 - .../src/ReporterValidationErrors.ts | 1 - ...porter.test.js => notify_reporter.test.ts} | 41 +- .../src/__tests__/runtime_cli.test.js | 2 - types/Argv.js | 101 -- types/ChangedFiles.js | 30 - types/Circus.js | 214 ---- types/Config.js | 304 ----- types/Console.js | 31 - types/Context.js | 19 - types/Environment.js | 43 - types/Errors.js | 10 - types/Global.js | 10 - types/HasteMap.js | 77 -- types/Jasmine.js | 10 - types/Jest.js | 54 - types/JestHooks.js | 39 - types/Matchers.js | 91 -- types/Mock.js | 16 - types/PrettyFormat.js | 130 -- types/Process.js | 13 - types/Reporters.js | 13 - types/Resolve.js | 24 - types/SnapshotResolver.js | 9 - types/SourceMaps.js | 10 - types/TestResult.js | 238 ---- types/TestRunner.js | 71 -- types/TestScheduler.js | 16 - types/Transform.js | 51 - types/Watch.js | 13 - yarn.lock | 5 - 44 files changed, 29 insertions(+), 3184 deletions(-) delete mode 100644 .flowconfig delete mode 100644 flow-typed/co.js delete mode 100644 flow-typed/console.js delete mode 100644 flow-typed/graceful-fs.js delete mode 100644 flow-typed/is-generator-fn.js delete mode 100644 flow-typed/npm/glob_v7.1.x.js delete mode 100644 flow-typed/npm/jest_v23.x.x.js delete mode 100644 flow-typed/resolve.js delete mode 100644 flow-typed/stack-utils.js rename packages/jest-reporters/src/__tests__/{notify_reporter.test.js => notify_reporter.test.ts} (83%) delete mode 100644 types/Argv.js delete mode 100644 types/ChangedFiles.js delete mode 100644 types/Circus.js delete mode 100644 types/Config.js delete mode 100644 types/Console.js delete mode 100644 types/Context.js delete mode 100644 types/Environment.js delete mode 100644 types/Errors.js delete mode 100644 types/Global.js delete mode 100644 types/HasteMap.js delete mode 100644 types/Jasmine.js delete mode 100644 types/Jest.js delete mode 100644 types/JestHooks.js delete mode 100644 types/Matchers.js delete mode 100644 types/Mock.js delete mode 100644 types/PrettyFormat.js delete mode 100644 types/Process.js delete mode 100644 types/Reporters.js delete mode 100644 types/Resolve.js delete mode 100644 types/SnapshotResolver.js delete mode 100644 types/SourceMaps.js delete mode 100644 types/TestResult.js delete mode 100644 types/TestRunner.js delete mode 100644 types/TestScheduler.js delete mode 100644 types/Transform.js delete mode 100644 types/Watch.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 44cae7e80065..ac2e90961811 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ jobs: - run: yarn --no-progress --frozen-lockfile - save-cache: *save-cache - run: echo server.max_workers=1 >> .flowconfig - - run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn typecheck && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci && yarn check-copyright-headers + - run: yarn lint --format junit -o reports/junit/js-lint-results.xml && yarn lint-es5-build --format junit -o reports/junit/js-es5-lint-results.xml && yarn lint:md:ci && yarn check-copyright-headers - store_test_results: path: reports/junit diff --git a/.eslintrc.js b/.eslintrc.js index e8b92949990d..8d6ac703ad22 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -66,7 +66,7 @@ module.exports = { }, }, { - files: ['types/**/*', 'packages/jest-types/**/*'], + files: ['packages/jest-types/**/*'], rules: { 'import/no-extraneous-dependencies': 0, }, diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index f97fe78d8983..000000000000 --- a/.flowconfig +++ /dev/null @@ -1,23 +0,0 @@ -[ignore] -.*/examples/.* -.*/node_modules/metro-bundler/.* -.*/node_modules/metro-config/.* -.*/node_modules/metro/.* -.*/node_modules/module-deps/.* - -[strict] -nonstrict-import -unclear-type -unsafe-getters-setters -untyped-import -untyped-type-import - -[version] -^0.94.0 - -[options] -module.name_mapper='^pretty-format$' -> '/packages/pretty-format/src/index.js' -module.name_mapper='^types/\(.*\)$' -> '/types/\1.js' -module.name_mapper='\(jest-[^/]*\)' -> '/packages/\1/src/index.js' -include_warnings=true -emoji=true diff --git a/flow-typed/co.js b/flow-typed/co.js deleted file mode 100644 index 9b0b612a07b4..000000000000 --- a/flow-typed/co.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -declare module 'co' { - declare export default {wrap: Function => () => Promise}; -} diff --git a/flow-typed/console.js b/flow-typed/console.js deleted file mode 100644 index caf62e2583ba..000000000000 --- a/flow-typed/console.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -declare module "console" { - declare export class Console { - constructor(stdout: mixed, stderr: mixed): void; - assert(value: mixed, message?: string, ...messageParts: Array): void; - dir(data: mixed, options?: Object): void; - - error(msg: string, ...msgParts: Array): void; - error(data: mixed): void; - - info(msg: string, ...msgParts: Array): void; - info(data: mixed): void; - - log(msg: string, ...msgParts: Array): void; - log(data: mixed): void; - - time(label: string): void; - timeEnd(label: string): void; - trace(msg: string, ...msgParts: Array): void; - - warn(msg: string, ...msgParts: Array): void; - warn(data: mixed): void; - } -} diff --git a/flow-typed/graceful-fs.js b/flow-typed/graceful-fs.js deleted file mode 100644 index 5c21cebfcc95..000000000000 --- a/flow-typed/graceful-fs.js +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -declare module "graceful-fs" { - declare class Stats { - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - } - - declare class FSWatcher extends events$EventEmitter { - close(): void - } - - declare class ReadStream extends stream$Readable { - close(): void - } - - declare class WriteStream extends stream$Writable { - close(): void - } - - declare function gracefulify(fs: Object): void; - declare function rename(oldPath: string, newPath: string, callback?: (err: ?Error) => void): void; - declare function renameSync(oldPath: string, newPath: string): void; - declare function ftruncate(fd: number, len: number, callback?: (err: ?Error) => void): void; - declare function ftruncateSync(fd: number, len: number): void; - declare function truncate(path: string, len: number, callback?: (err: ?Error) => void): void; - declare function truncateSync(path: string, len: number): void; - declare function chown(path: string, uid: number, gid: number, callback?: (err: ?Error) => void): void; - declare function chownSync(path: string, uid: number, gid: number): void; - declare function fchown(fd: number, uid: number, gid: number, callback?: (err: ?Error) => void): void; - declare function fchownSync(fd: number, uid: number, gid: number): void; - declare function lchown(path: string, uid: number, gid: number, callback?: (err: ?Error) => void): void; - declare function lchownSync(path: string, uid: number, gid: number): void; - declare function chmod(path: string, mode: number | string, callback?: (err: ?Error) => void): void; - declare function chmodSync(path: string, mode: number | string): void; - declare function fchmod(fd: number, mode: number | string, callback?: (err: ?Error) => void): void; - declare function fchmodSync(fd: number, mode: number | string): void; - declare function lchmod(path: string, mode: number | string, callback?: (err: ?Error) => void): void; - declare function lchmodSync(path: string, mode: number | string): void; - declare function stat(path: string, callback?: (err: ?Error, stats: Stats) => any): void; - declare function statSync(path: string): Stats; - declare function fstat(fd: number, callback?: (err: ?Error, stats: Stats) => any): void; - declare function fstatSync(fd: number): Stats; - declare function lstat(path: string, callback?: (err: ?Error, stats: Stats) => any): void; - declare function lstatSync(path: string): Stats; - declare function link(srcpath: string, dstpath: string, callback?: (err: ?Error) => void): void; - declare function linkSync(srcpath: string, dstpath: string): void; - declare function symlink(srcpath: string, dtspath: string, type?: string, callback?: (err: ?Error) => void): void; - declare function symlinkSync(srcpath: string, dstpath: string, type: string): void; - declare function readlink(path: string, callback: (err: ?Error, linkString: string) => void): void; - declare function readlinkSync(path: string): string; - declare function realpath(path: string, cache?: Object, callback?: (err: ?Error, resolvedPath: string) => void): void; - declare function realpathSync(path: string, cache?: Object): string; - declare function unlink(path: string, callback?: (err: ?Error) => void): void; - declare function unlinkSync(path: string): void; - declare function rmdir(path: string, callback?: (err: ?Error) => void): void; - declare function rmdirSync(path: string): void; - declare function mkdir(path: string, mode?: number, callback?: (err: ?Error) => void): void; - declare function mkdirSync(path: string, mode?: number): void; - declare function readdir(path: string, callback?: (err: ?Error, files: Array) => void): void; - declare function readdirSync(path: string): Array; - declare function close(fd: number, callback?: (err: ?Error) => void): void; - declare function closeSync(fd: number): void; - declare function open(path: string, flags: string, mode?: number, callback?: (err: ?Error, fd: number) => void): void; - declare function openSync(path: string, flags: string, mode?: number): number; - declare function utimes(path: string, atime: number, mtime: number, callback?: (err: ?Error) => void): void; - declare function utimesSync(path: string, atime: number, mtime: number): void; - declare function futimes(fd: number, atime: number, mtime: number, callback?: (err: ?Error) => void): void; - declare function futimesSync(fd: number, atime: number, mtime: number): void; - declare function fsync(fd: number, callback?: (err: ?Error) => void): void; - declare function fsyncSync(fd: number): void; - declare var write: (fd: number, buffer: Buffer, offset: number, length: number, position?: mixed, callback?: (err: ?Error, write: number, str: string) => void) => void - | (fd: number, data: mixed, position?: mixed, encoding?: string, callback?: (err: ?Error, write: number, str: string) => void) => void; - declare var writeSync: (fd: number, buffer: Buffer, offset: number, length: number, position?: number) => number - | (fd: number, data: mixed, position?: mixed, encoding?: string) => number; - declare function read( - fd: number, - buffer: Buffer, - offset: number, - length: number, - position: ?number, - callback?: (err: ?Error, bytesRead: number, buffer: Buffer) => void - ): void; - declare function readSync( - fd: number, - buffer: Buffer, - offset: number, - length: number, - position: number - ): number; - declare function readFile( - filename: string, - callback: (err: ?Error, data: Buffer) => void - ): void; - declare function readFile( - filename: string, - encoding: string, - callback: (err: ?Error, data: string) => void - ): void; - declare function readFile( - filename: string, - options: { encoding: string; flag?: string }, - callback: (err: ?Error, data: string) => void - ): void; - declare function readFile( - filename: string, - options: { flag?: string }, - callback: (err: ?Error, data: Buffer) => void - ): void; - declare function readFileSync(filename: string, _: void): Buffer; - declare function readFileSync(filename: string, encoding: string): string; - declare function readFileSync(filename: string, options: { encoding: string, flag?: string }): string; - declare function readFileSync(filename: string, options: { encoding?: void, flag?: string }): Buffer; - declare function writeFile( - filename: string, - data: Buffer | string, - options?: Object | string, - callback?: (err: ?Error) => void - ): void; - declare function writeFileSync( - filename: string, - data: Buffer | string, - options?: Object | string - ): void; - declare function appendFile(filename: string, data: string | Buffer, options?: Object, callback?: (err: ?Error) => void): void; - declare function appendFileSync(filename: string, data: string | Buffer, options?: Object): void; - declare function watchFile(filename: string, options?: Object, listener?: (curr: Stats, prev: Stats) => void): void; - declare function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - declare function watch(filename: string, options?: Object, listener?: (event: string, filename: string) => void): FSWatcher; - declare function exists(path: string, callback?: (exists: boolean) => void): void; - declare function existsSync(path: string): boolean; - declare function access(path: string, mode?: any, callback?: (err: ?Error) => void): void; - declare function accessSync(path: string, mode?: any): void; - declare function createReadStream(path: string, options?: Object): ReadStream; - declare function createWriteStream(path: string, options?: Object): WriteStream; - - declare var F_OK: number; - declare var R_OK: number; - declare var W_OK: number; - declare var X_OK: number; -} diff --git a/flow-typed/is-generator-fn.js b/flow-typed/is-generator-fn.js deleted file mode 100644 index 463dfa59da75..000000000000 --- a/flow-typed/is-generator-fn.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -declare module 'is-generator-fn' { - declare export default (Function) => boolean; -} diff --git a/flow-typed/npm/glob_v7.1.x.js b/flow-typed/npm/glob_v7.1.x.js deleted file mode 100644 index b1d523f8ec54..000000000000 --- a/flow-typed/npm/glob_v7.1.x.js +++ /dev/null @@ -1,87 +0,0 @@ -// flow-typed signature: 7c09aef8ac07163d6ef9e3f50c6bc35c -// flow-typed version: a12a42a747/glob_v7.1.x/flow_>=v0.42.x - -declare module "glob" { - declare type MinimatchOptions = {| - debug?: boolean, - nobrace?: boolean, - noglobstar?: boolean, - dot?: boolean, - noext?: boolean, - nocase?: boolean, - nonull?: boolean, - matchBase?: boolean, - nocomment?: boolean, - nonegate?: boolean, - flipNegate?: boolean - |}; - - declare type Options = {| - ...MinimatchOptions, - cwd?: string, - root?: string, - nomount?: boolean, - mark?: boolean, - nosort?: boolean, - stat?: boolean, - silent?: boolean, - strict?: boolean, - cache?: { - [path: string]: boolean | "DIR" | "FILE" | $ReadOnlyArray - }, - statCache?: { - [path: string]: boolean | { isDirectory(): boolean } | void - }, - symlinks?: { [path: string]: boolean | void }, - realpathCache?: { [path: string]: string }, - sync?: boolean, - nounique?: boolean, - nodir?: boolean, - ignore?: string | $ReadOnlyArray, - follow?: boolean, - realpath?: boolean, - absolute?: boolean - |}; - - /** - * Called when an error occurs, or matches are found - * err - * matches: filenames found matching the pattern - */ - declare type CallBack = (err: ?Error, matches: Array) => void; - - declare class Glob extends events$EventEmitter { - constructor(pattern: string): this; - constructor(pattern: string, callback: CallBack): this; - constructor(pattern: string, options: Options, callback: CallBack): this; - - minimatch: {}; - options: Options; - aborted: boolean; - cache: { - [path: string]: boolean | "DIR" | "FILE" | $ReadOnlyArray - }; - statCache: { - [path: string]: boolean | { isDirectory(): boolean } | void - }; - symlinks: { [path: string]: boolean | void }; - realpathCache: { [path: string]: string }; - found: Array; - - pause(): void; - resume(): void; - abort(): void; - } - - declare class GlobModule { - Glob: Class; - - (pattern: string, callback: CallBack): void; - (pattern: string, options: Options, callback: CallBack): void; - - hasMagic(pattern: string, options?: Options): boolean; - sync(pattern: string, options?: Options): Array; - } - - declare module.exports: GlobModule; -} diff --git a/flow-typed/npm/jest_v23.x.x.js b/flow-typed/npm/jest_v23.x.x.js deleted file mode 100644 index 153bfd3b6b23..000000000000 --- a/flow-typed/npm/jest_v23.x.x.js +++ /dev/null @@ -1,1131 +0,0 @@ -// flow-typed signature: f5a484315a3dea13d273645306e4076a -// flow-typed version: 7c5d14b3d4/jest_v23.x.x/flow_>=v0.39.x - -type JestMockFn, TReturn> = { - (...args: TArguments): TReturn, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: Array - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): void, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): void, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): void, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a string to use in test result output in place of "jest.fn()" to - * indicate which mock function is being referenced. - */ - mockName(name: string): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Accepts a value that will be returned whenever the mock function is called. - */ - mockReturnValue(value: TReturn): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: TReturn): JestMockFn, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) - */ - mockResolvedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) - */ - mockResolvedValueOnce(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) - */ - mockRejectedValue(value: TReturn): JestMockFn>, - /** - * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) - */ - mockRejectedValueOnce(value: TReturn): JestMockFn> -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -/** - * Jest allows functions and classes to be used as test names in test() and - * describe() - */ -type JestTestName = string | Function; - -/** - * Plugin: jest-styled-components - */ - -type JestStyledComponentsMatcherValue = - | string - | JestAsymmetricEqualityType - | RegExp - | typeof undefined; - -type JestStyledComponentsMatcherOptions = { - media?: string; - modifier?: string; - supports?: string; -} - -type JestStyledComponentsMatchersType = { - toHaveStyleRule( - property: string, - value: JestStyledComponentsMatcherValue, - options?: JestStyledComponentsMatcherOptions - ): void, -}; - -/** - * Plugin: jest-enzyme - */ -type EnzymeMatchersType = { - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeEmptyRender(): void, - toBePresent(): void, - toContainReact(element: React$Element): void, - toExist(): void, - toHaveClassName(className: string): void, - toHaveHTML(html: string): void, - toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), - toHaveRef(refName: string): void, - toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), - toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), - toHaveTagName(tagName: string): void, - toHaveText(text: string): void, - toIncludeText(text: string): void, - toHaveValue(value: any): void, - toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void -}; - -// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers -type DomTestingLibraryType = { - toBeInTheDOM(): void, - toHaveTextContent(content: string): void, - toHaveAttribute(name: string, expectedValue?: string): void -}; - -// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers -type JestJQueryMatchersType = { - toExist(): void, - toHaveLength(len: number): void, - toHaveId(id: string): void, - toHaveClass(className: string): void, - toHaveTag(tag: string): void, - toHaveAttr(key: string, val?: any): void, - toHaveProp(key: string, val?: any): void, - toHaveText(text: string | RegExp): void, - toHaveData(key: string, val?: any): void, - toHaveValue(val: any): void, - toHaveCss(css: {[key: string]: any}): void, - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBeHidden(): void, - toBeSelected(): void, - toBeVisible(): void, - toBeFocused(): void, - toBeInDom(): void, - toBeMatchedBy(sel: string): void, - toHaveDescendant(sel: string): void, - toHaveDescendantWithText(sel: string, text: string | RegExp): void -}; - - -// Jest Extended Matchers: https://github.com/jest-community/jest-extended -type JestExtendedMatchersType = { - /** - * Note: Currently unimplemented - * Passing assertion - * - * @param {String} message - */ - // pass(message: string): void; - - /** - * Note: Currently unimplemented - * Failing assertion - * - * @param {String} message - */ - // fail(message: string): void; - - /** - * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. - */ - toBeEmpty(): void; - - /** - * Use .toBeOneOf when checking if a value is a member of a given Array. - * @param {Array.<*>} members - */ - toBeOneOf(members: any[]): void; - - /** - * Use `.toBeNil` when checking a value is `null` or `undefined`. - */ - toBeNil(): void; - - /** - * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. - * @param {Function} predicate - */ - toSatisfy(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeArray` when checking if a value is an `Array`. - */ - toBeArray(): void; - - /** - * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. - * @param {Number} x - */ - toBeArrayOfSize(x: number): void; - - /** - * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. - * @param {Array.<*>} members - */ - toIncludeAllMembers(members: any[]): void; - - /** - * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. - * @param {Array.<*>} members - */ - toIncludeAnyMembers(members: any[]): void; - - /** - * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. - * @param {Function} predicate - */ - toSatisfyAll(predicate: (n: any) => boolean): void; - - /** - * Use `.toBeBoolean` when checking if a value is a `Boolean`. - */ - toBeBoolean(): void; - - /** - * Use `.toBeTrue` when checking a value is equal (===) to `true`. - */ - toBeTrue(): void; - - /** - * Use `.toBeFalse` when checking a value is equal (===) to `false`. - */ - toBeFalse(): void; - - /** - * Use .toBeDate when checking if a value is a Date. - */ - toBeDate(): void; - - /** - * Use `.toBeFunction` when checking if a value is a `Function`. - */ - toBeFunction(): void; - - /** - * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. - * - * Note: Required Jest version >22 - * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same - * - * @param {Mock} mock - */ - toHaveBeenCalledBefore(mock: JestMockFn): void; - - /** - * Use `.toBeNumber` when checking if a value is a `Number`. - */ - toBeNumber(): void; - - /** - * Use `.toBeNaN` when checking a value is `NaN`. - */ - toBeNaN(): void; - - /** - * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. - */ - toBeFinite(): void; - - /** - * Use `.toBePositive` when checking if a value is a positive `Number`. - */ - toBePositive(): void; - - /** - * Use `.toBeNegative` when checking if a value is a negative `Number`. - */ - toBeNegative(): void; - - /** - * Use `.toBeEven` when checking if a value is an even `Number`. - */ - toBeEven(): void; - - /** - * Use `.toBeOdd` when checking if a value is an odd `Number`. - */ - toBeOdd(): void; - - /** - * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). - * - * @param {Number} start - * @param {Number} end - */ - toBeWithin(start: number, end: number): void; - - /** - * Use `.toBeObject` when checking if a value is an `Object`. - */ - toBeObject(): void; - - /** - * Use `.toContainKey` when checking if an object contains the provided key. - * - * @param {String} key - */ - toContainKey(key: string): void; - - /** - * Use `.toContainKeys` when checking if an object has all of the provided keys. - * - * @param {Array.} keys - */ - toContainKeys(keys: string[]): void; - - /** - * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. - * - * @param {Array.} keys - */ - toContainAllKeys(keys: string[]): void; - - /** - * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. - * - * @param {Array.} keys - */ - toContainAnyKeys(keys: string[]): void; - - /** - * Use `.toContainValue` when checking if an object contains the provided value. - * - * @param {*} value - */ - toContainValue(value: any): void; - - /** - * Use `.toContainValues` when checking if an object contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainValues(values: any[]): void; - - /** - * Use `.toContainAllValues` when checking if an object only contains all of the provided values. - * - * @param {Array.<*>} values - */ - toContainAllValues(values: any[]): void; - - /** - * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. - * - * @param {Array.<*>} values - */ - toContainAnyValues(values: any[]): void; - - /** - * Use `.toContainEntry` when checking if an object contains the provided entry. - * - * @param {Array.} entry - */ - toContainEntry(entry: [string, string]): void; - - /** - * Use `.toContainEntries` when checking if an object contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. - * - * @param {Array.>} entries - */ - toContainAllEntries(entries: [string, string][]): void; - - /** - * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. - * - * @param {Array.>} entries - */ - toContainAnyEntries(entries: [string, string][]): void; - - /** - * Use `.toBeExtensible` when checking if an object is extensible. - */ - toBeExtensible(): void; - - /** - * Use `.toBeFrozen` when checking if an object is frozen. - */ - toBeFrozen(): void; - - /** - * Use `.toBeSealed` when checking if an object is sealed. - */ - toBeSealed(): void; - - /** - * Use `.toBeString` when checking if a value is a `String`. - */ - toBeString(): void; - - /** - * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. - * - * @param {String} string - */ - toEqualCaseInsensitive(string: string): void; - - /** - * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. - * - * @param {String} prefix - */ - toStartWith(prefix: string): void; - - /** - * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. - * - * @param {String} suffix - */ - toEndWith(suffix: string): void; - - /** - * Use `.toInclude` when checking if a `String` includes the given `String` substring. - * - * @param {String} substring - */ - toInclude(substring: string): void; - - /** - * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. - * - * @param {String} substring - * @param {Number} times - */ - toIncludeRepeated(substring: string, times: number): void; - - /** - * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. - * - * @param {Array.} substring - */ - toIncludeMultiple(substring: string[]): void; -}; - -interface JestExpectType { - not: - & JestExpectType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - toBeCalled(): void; - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - toBeCalledTimes(number: number): void; - /** - * - */ - toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; - nthCalledWith(nthCall: number, ...args: Array): void; - /** - * - */ - toHaveReturned(): void; - toReturn(): void; - /** - * - */ - toHaveReturnedTimes(number: number): void; - toReturnTimes(number: number): void; - /** - * - */ - toHaveReturnedWith(value: any): void; - toReturnWith(value: any): void; - /** - * - */ - toHaveLastReturnedWith(value: any): void; - lastReturnedWith(value: any): void; - /** - * - */ - toHaveNthReturnedWith(nthCall: number, value: any): void; - nthReturnedWith(nthCall: number, value: any): void; - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - toBeCalledWith(...args: Array): void, - /** - * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called - * with specific arguments. - */ - toHaveBeenLastCalledWith(...args: Array): void, - lastCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression or string. - */ - toMatch(regexpOrString: RegExp | string): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object | Array): void, - /** - * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. - */ - toStrictEqual(value: any): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, - /** - * This ensures that an Object matches the most recent snapshot. - */ - toMatchSnapshot(name: string): void, - - toMatchInlineSnapshot(snapshot?: string): void, - toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void, - toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, -} - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Restores all mocks back to their original value. - */ - restoreAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn, TReturn>( - implementation?: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Returns the actual module instead of a mock, bypassing all checks on - * whether the module should receive a mock implementation or not. - */ - requireActual(moduleName: string): any, - /** - * Returns a mock module instead of the actual module, bypassing all checks - * on whether the module should be required normally or not. - */ - requireMock(moduleName: string): any, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - advanceTimersByTime(msToRun: number): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - * - * Renamed to `advanceTimersByTime`. - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, - /** - * Set the default timeout interval for tests and before/after hooks in milliseconds. - * Note: The default timeout interval is 5 seconds if this method is not called. - */ - setTimeout(timeout: number): JestObjectType -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before every test inside this context */ -declare function beforeEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; - -/** A context for grouping tests together */ -declare var describe: { - /** - * Creates a block that groups together several related tests - */ - (name: JestTestName, fn: () => void): void, - - /** - * Only run this describe block - */ - only(name: JestTestName, fn: () => void): void, - - /** - * Skip running this describe block - */ - skip(name: JestTestName, fn: () => void): void, - - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array | mixed> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, -}; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - ( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array | mixed> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - /** - * Only run this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - only( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): { - each( - table: Array | mixed> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, - }, - /** - * Skip running this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - skip( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Run the test concurrently - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - concurrent( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: Array | mixed> - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise - ) => void, -}; -declare function fit( - name: JestTestName, - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -type JestPrettyFormatColors = { - comment: { close: string, open: string }, - content: { close: string, open: string }, - prop: { close: string, open: string }, - tag: { close: string, open: string }, - value: { close: string, open: string }, -}; - -type JestPrettyFormatIndent = string => string; -type JestPrettyFormatRefs = Array; -type JestPrettyFormatPrint = any => string; -type JestPrettyFormatStringOrNull = string | null; - -type JestPrettyFormatOptions = {| - callToJSON: boolean, - edgeSpacing: string, - escapeRegex: boolean, - highlight: boolean, - indent: number, - maxDepth: number, - min: boolean, - plugins: JestPrettyFormatPlugins, - printFunctionName: boolean, - spacing: string, - theme: {| - comment: string, - content: string, - prop: string, - tag: string, - value: string, - |}, -|}; - -type JestPrettyFormatPlugin = { - print: ( - val: any, - serialize: JestPrettyFormatPrint, - indent: JestPrettyFormatIndent, - opts: JestPrettyFormatOptions, - colors: JestPrettyFormatColors, - ) => string, - test: any => boolean, -}; - -type JestPrettyFormatPlugins = Array; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): - & JestExpectType - & JestPromiseType - & EnzymeMatchersType - & DomTestingLibraryType - & JestJQueryMatchersType - & JestStyledComponentsMatchersType - & JestExtendedMatchersType, - - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - objectContaining(value: Object): Object, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): string, - stringMatching(value: string | RegExp): string, - not: { - arrayContaining: (value: $ReadOnlyArray) => Array, - objectContaining: (value: {}) => Object, - stringContaining: (value: string) => string, - stringMatching: (value: string | RegExp) => string, - }, -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jasmine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): any, - arrayContaining(value: Array): Array, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): Object, - stringMatching(value: string): string -}; diff --git a/flow-typed/resolve.js b/flow-typed/resolve.js deleted file mode 100644 index f5084be331f8..000000000000 --- a/flow-typed/resolve.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -declare module "resolve" { - declare function isCore(moduleName: string): boolean; - declare function sync(path: string, opts: Object): string; -} - -declare module "resolve/lib/node-modules-paths" { - declare type NodeModulesPathsOptions = { - moduleDirectory: Array, - }; - - declare module.exports: ( - path: string, - options: NodeModulesPathsOptions, - ) => Array; -} diff --git a/flow-typed/stack-utils.js b/flow-typed/stack-utils.js deleted file mode 100644 index 4f8c1ccb6dae..000000000000 --- a/flow-typed/stack-utils.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. 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. - * - * @flow - */ - -type ParsedFrame = { - line: number, - column: number, - file: string, -}; -declare class StackUtils { - constructor(?{cwd?: string}): StackUtils; - parseLine(string): ParsedFrame; - static nodeInternals: () => Array; -} - -declare module 'stack-utils' { - declare export default typeof StackUtils; -} diff --git a/package.json b/package.json index 30e53111f386..495b73c3f80f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "eslint-plugin-react": "^7.1.0", "eslint-plugin-relay": "~0.0.19", "execa": "^1.0.0", - "flow-bin": "^0.94.0", "glob": "^7.1.1", "graceful-fs": "^4.1.15", "isbinaryfile": "^4.0.0", @@ -87,14 +86,13 @@ "lint:md": "yarn --silent lint:md:ci --fix", "lint:md:ci": "prettylint '**/*.{md,yml,yaml}' --ignore-path .gitignore", "postinstall": "opencollective postinstall && yarn build", - "publish": "yarn build-clean && yarn typecheck && yarn build && lerna publish --silent", + "publish": "yarn build-clean && yarn build && lerna publish --silent", "test-ci-es5-build-in-browser": "karma start --single-run", "test-ci": "yarn jest-coverage -i --config jest.config.ci.js && yarn test-leak && node scripts/mapCoverage.js && codecov", "test-ci-partial": "yarn jest -i --config jest.config.ci.js", "test-pretty-format-perf": "node packages/pretty-format/perf/test.js", "test-leak": "yarn jest -i --detectLeaks jest-mock jest-diff jest-repl", - "test": "yarn typecheck && yarn lint && yarn jest", - "typecheck": "flow check --include-warnings", + "test": "yarn lint && yarn jest", "watch": "yarn build && node ./scripts/watch.js", "watch:ts": "yarn build:ts --watch" }, diff --git a/packages/jest-circus/runner.js b/packages/jest-circus/runner.js index 25c43719babb..9dd2221862f9 100644 --- a/packages/jest-circus/runner.js +++ b/packages/jest-circus/runner.js @@ -4,8 +4,6 @@ * 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. - * - * @flow */ // Allow people to use `jest-circus/runner` as a runner. diff --git a/packages/jest-circus/src/__tests__/circusItTestError.test.ts b/packages/jest-circus/src/__tests__/circusItTestError.test.ts index 05a4035decfb..a267f511e836 100644 --- a/packages/jest-circus/src/__tests__/circusItTestError.test.ts +++ b/packages/jest-circus/src/__tests__/circusItTestError.test.ts @@ -21,10 +21,6 @@ const aliasCircusIt = () => { aliasCircusIt(); -// A few of these tests require incorrect types to throw errors and thus pass -// the test. The typechecks on jest-circus would prevent that, so -// this file has been listed in the .flowconfig ignore section. - describe('test/it error throwing', () => { it(`it doesn't throw an error with valid arguments`, () => { expect(() => { diff --git a/packages/jest-config/src/ReporterValidationErrors.ts b/packages/jest-config/src/ReporterValidationErrors.ts index 557d33c34234..3a658382d993 100644 --- a/packages/jest-config/src/ReporterValidationErrors.ts +++ b/packages/jest-config/src/ReporterValidationErrors.ts @@ -3,7 +3,6 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - * @flow */ import {Config} from '@jest/types'; diff --git a/packages/jest-reporters/src/__tests__/notify_reporter.test.js b/packages/jest-reporters/src/__tests__/notify_reporter.test.ts similarity index 83% rename from packages/jest-reporters/src/__tests__/notify_reporter.test.js rename to packages/jest-reporters/src/__tests__/notify_reporter.test.ts index 9460c82ef1b7..3c04db68af5c 100644 --- a/packages/jest-reporters/src/__tests__/notify_reporter.test.js +++ b/packages/jest-reporters/src/__tests__/notify_reporter.test.ts @@ -5,21 +5,22 @@ * LICENSE file in the root directory of this source tree. */ -import type {TestSchedulerContext} from 'types/TestScheduler'; +import {AggregatedResult} from '@jest/test-result'; +import {Config} from '@jest/types'; import NotifyReporter from '../notify_reporter'; -import type {AggregatedResult} from '../../../../types/TestResult'; +import {makeGlobalConfig} from '../../../../TestUtils'; jest.mock('../default_reporter'); jest.mock('node-notifier', () => ({ notify: jest.fn(), })); -const initialContext: TestSchedulerContext = { +const initialContext = { firstRun: true, previousSuccess: false, }; -const aggregatedResultsSuccess: AggregatedResult = { +const aggregatedResultsSuccess = { numFailedTestSuites: 0, numFailedTests: 0, numPassedTestSuites: 1, @@ -28,9 +29,9 @@ const aggregatedResultsSuccess: AggregatedResult = { numTotalTestSuites: 1, numTotalTests: 3, success: true, -}; +} as AggregatedResult; -const aggregatedResultsFailure: AggregatedResult = { +const aggregatedResultsFailure = { numFailedTestSuites: 1, numFailedTests: 3, numPassedTestSuites: 0, @@ -39,9 +40,9 @@ const aggregatedResultsFailure: AggregatedResult = { numTotalTestSuites: 1, numTotalTests: 3, success: false, -}; +} as AggregatedResult; -const aggregatedResultsNoTests: AggregatedResult = { +const aggregatedResultsNoTests = { numFailedTestSuites: 0, numFailedTests: 0, numPassedTestSuites: 0, @@ -51,7 +52,7 @@ const aggregatedResultsNoTests: AggregatedResult = { numRuntimeErrorTestSuites: 0, numTotalTestSuites: 0, numTotalTests: 0, -}; +} as AggregatedResult; // Simulated sequence of events for NotifyReporter const notifyEvents = [ @@ -64,20 +65,27 @@ const notifyEvents = [ aggregatedResultsFailure, ]; -const testModes = ({notifyMode, arl, rootDir, moduleName}) => { +const testModes = ({ + notifyMode, + arl, + rootDir, + moduleName, +}: {arl: Array; moduleName?: string} & Pick< + Config.GlobalConfig, + 'notifyMode' +> & + Partial>) => { const notify = require('node-notifier'); + const config = makeGlobalConfig({notify: true, notifyMode, rootDir}); + let previousContext = initialContext; arl.forEach((ar, i) => { const newContext = Object.assign(previousContext, { firstRun: i === 0, previousSuccess: previousContext.previousSuccess, }); - const reporter = new NotifyReporter( - {notify: true, notifyMode, rootDir}, - {}, - newContext, - ); + const reporter = new NotifyReporter(config, () => {}, newContext); previousContext = newContext; const contexts = new Set(); @@ -102,8 +110,9 @@ const testModes = ({notifyMode, arl, rootDir, moduleName}) => { } }); + const calls: Array = notify.notify.mock.calls; expect( - notify.notify.mock.calls.map(([{message, title}]) => ({ + calls.map(([{message, title}]) => ({ message: message.replace('\u26D4\uFE0F ', '').replace('\u2705 ', ''), title, })), diff --git a/packages/jest-runtime/src/__tests__/runtime_cli.test.js b/packages/jest-runtime/src/__tests__/runtime_cli.test.js index 8fb96c442b62..611b1794eb65 100644 --- a/packages/jest-runtime/src/__tests__/runtime_cli.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_cli.test.js @@ -3,8 +3,6 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - * - * @flow */ import path from 'path'; diff --git a/types/Argv.js b/types/Argv.js deleted file mode 100644 index 7449ab253f3d..000000000000 --- a/types/Argv.js +++ /dev/null @@ -1,101 +0,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. - * - * @flow - */ -'use strict'; - -export type Argv = {| - _: Array, - $0: string, - all: boolean, - automock: boolean, - bail: boolean | number, - browser: boolean, - cache: boolean, - cacheDirectory: string, - changedFilesWithAncestor: boolean, - changedSince: string, - ci: boolean, - clearCache: boolean, - clearMocks: boolean, - collectCoverage: boolean, - collectCoverageFrom: Array, - collectCoverageOnlyFrom: Array, - config: string, - coverage: boolean, - coverageDirectory: string, - coveragePathIgnorePatterns: Array, - coverageReporters: Array, - coverageThreshold: string, - debug: boolean, - env: string, - expand: boolean, - findRelatedTests: boolean, - forceExit: boolean, - globals: string, - globalSetup: ?string, - globalTeardown: ?string, - h: boolean, - haste: string, - help: boolean, - init: boolean, - json: boolean, - lastCommit: boolean, - logHeapUsage: boolean, - maxWorkers: number, - moduleDirectories: Array, - moduleFileExtensions: Array, - moduleLoader: string, - moduleNameMapper: string, - modulePathIgnorePatterns: Array, - modulePaths: Array, - name: string, - noSCM: boolean, - noStackTrace: boolean, - notify: boolean, - notifyMode: string, - onlyChanged: boolean, - outputFile: string, - preset: ?string, - projects: Array, - prettierPath: ?string, - replname: ?string, - resetMocks: boolean, - resetModules: boolean, - resolver: ?string, - restoreMocks: boolean, - rootDir: string, - roots: Array, - runInBand: boolean, - setupFiles: Array, - setupFilesAfterEnv: Array, - showConfig: boolean, - silent: boolean, - snapshotSerializers: Array, - testEnvironment: string, - testFailureExitCode: ?string, - testMatch: Array, - testNamePattern: string, - testPathIgnorePatterns: Array, - testPathPattern: Array, - testRegex: string | Array, - testResultsProcessor: ?string, - testRunner: string, - testURL: string, - timers: 'real' | 'fake', - transform: string, - transformIgnorePatterns: Array, - unmockedModulePathPatterns: ?Array, - updateSnapshot: boolean, - useStderr: boolean, - verbose: ?boolean, - version: boolean, - watch: boolean, - watchAll: boolean, - watchman: boolean, - watchPathIgnorePatterns: Array, -|}; diff --git a/types/ChangedFiles.js b/types/ChangedFiles.js deleted file mode 100644 index 9e0914c01016..000000000000 --- a/types/ChangedFiles.js +++ /dev/null @@ -1,30 +0,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. - * - * @flow - */ - -import type {Path} from 'types/Config'; - -export type Options = {| - lastCommit?: boolean, - withAncestor?: boolean, - changedSince?: string, - includePaths?: Array, -|}; - -export type ChangedFiles = Set; -export type Repos = {|git: Set, hg: Set|}; -export type ChangedFilesInfo = {| - repos: Repos, - changedFiles: ChangedFiles, -|}; -export type ChangedFilesPromise = Promise; - -export type SCMAdapter = {| - findChangedFiles: (cwd: Path, options: Options) => Promise>, - getRoot: (cwd: Path) => Promise, -|}; diff --git a/types/Circus.js b/types/Circus.js deleted file mode 100644 index f255e3914284..000000000000 --- a/types/Circus.js +++ /dev/null @@ -1,214 +0,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. - * - * @flow - */ - -export type DoneFn = (reason?: string | Error) => void; -export type BlockFn = () => void; -export type BlockName = string; -export type BlockMode = void | 'skip' | 'only' | 'todo'; -export type TestMode = BlockMode; -export type TestName = string; -export type TestFn = (done?: DoneFn) => ?Promise; -export type HookFn = (done?: DoneFn) => ?Promise; -export type AsyncFn = TestFn | HookFn; -export type SharedHookType = 'afterAll' | 'beforeAll'; -export type HookType = SharedHookType | 'afterEach' | 'beforeEach'; -export type TestContext = Object; -export type Exception = any; // Since in JS anything can be thrown as an error. -export type FormattedError = string; // String representation of error. -export type Hook = { - asyncError: Exception, - fn: HookFn, - type: HookType, - parent: DescribeBlock, - timeout: ?number, -}; - -export type EventHandler = (event: Event, state: State) => void; - -export type Event = - | {| - name: 'include_test_location_in_result', - |} - | {| - asyncError: Exception, - mode: BlockMode, - name: 'start_describe_definition', - blockName: BlockName, - |} - | {| - mode: BlockMode, - name: 'finish_describe_definition', - blockName: BlockName, - |} - | {| - asyncError: Exception, - name: 'add_hook', - hookType: HookType, - fn: HookFn, - timeout: ?number, - |} - | {| - asyncError: Exception, - name: 'add_test', - testName: TestName, - fn?: TestFn, - mode?: TestMode, - timeout: ?number, - |} - | {| - name: 'hook_start', - hook: Hook, - |} - | {| - name: 'hook_success', - describeBlock: ?DescribeBlock, - test: ?TestEntry, - hook: Hook, - |} - | {| - name: 'hook_failure', - error: string | Exception, - describeBlock: ?DescribeBlock, - test: ?TestEntry, - hook: Hook, - |} - | {| - name: 'test_fn_start', - test: TestEntry, - |} - | {| - name: 'test_fn_success', - test: TestEntry, - |} - | {| - name: 'test_fn_failure', - error: Exception, - test: TestEntry, - |} - | {| - name: 'test_retry', - test: TestEntry, - |} - | {| - // the `test` in this case is all hooks + it/test function, not just the - // function passed to `it/test` - name: 'test_start', - test: TestEntry, - |} - | {| - name: 'test_skip', - test: TestEntry, - |} - | {| - name: 'test_todo', - test: TestEntry, - |} - | {| - // test failure is defined by presence of errors in `test.errors`, - // `test_done` indicates that the test and all its hooks were run, - // and nothing else will change it's state in the future. (except third - // party extentions/plugins) - name: 'test_done', - test: TestEntry, - |} - | {| - name: 'run_describe_start', - describeBlock: DescribeBlock, - |} - | {| - name: 'run_describe_finish', - describeBlock: DescribeBlock, - |} - | {| - name: 'run_start', - |} - | {| - name: 'run_finish', - |} - | {| - // Any unhandled error that happened outside of test/hooks (unless it is - // an `afterAll` hook) - name: 'error', - error: Exception, - |} - | {| - // first action to dispatch. Good time to initialize all settings - name: 'setup', - testNamePattern?: string, - parentProcess: Process, - |} - | {| - // Action dispatched after everything is finished and we're about to wrap - // things up and return test results to the parent process (caller). - name: 'teardown', - |}; - -export type TestStatus = 'skip' | 'done' | 'todo'; -export type TestResult = {| - duration: ?number, - errors: Array, - invocations: number, - status: TestStatus, - location: ?{|column: number, line: number|}, - testPath: Array, -|}; - -export type RunResult = { - unhandledErrors: Array, - testResults: TestResults, -}; - -export type TestResults = Array; - -export type GlobalErrorHandlers = { - uncaughtException: Array<(Exception) => void>, - unhandledRejection: Array<(Exception) => void>, -}; - -export type State = {| - currentDescribeBlock: DescribeBlock, - currentlyRunningTest: ?TestEntry, // including when hooks are being executed - expand?: boolean, // expand error messages - hasFocusedTests: boolean, // that are defined using test.only - // Store process error handlers. During the run we inject our own - // handlers (so we could fail tests on unhandled errors) and later restore - // the original ones. - originalGlobalErrorHandlers?: GlobalErrorHandlers, - parentProcess: ?Process, // process object from the outer scope - rootDescribeBlock: DescribeBlock, - testNamePattern: ?RegExp, - testTimeout: number, - unhandledErrors: Array, - includeTestLocationInResult: boolean, -|}; - -export type DescribeBlock = {| - children: Array, - hooks: Array, - mode: BlockMode, - name: BlockName, - parent: ?DescribeBlock, - tests: Array, -|}; - -type TestError = Exception | Array<[?Exception, Exception]>; // the error from the test, as well as a backup error for async - -export type TestEntry = {| - asyncError: Exception, // Used if the test failure contains no usable stack trace - errors: TestError, - fn: ?TestFn, - invocations: number, - mode: TestMode, - name: TestName, - parent: DescribeBlock, - startedAt: ?number, - duration: ?number, - status: ?TestStatus, // whether the test has been skipped or run already - timeout: ?number, -|}; diff --git a/types/Config.js b/types/Config.js deleted file mode 100644 index 375278326abb..000000000000 --- a/types/Config.js +++ /dev/null @@ -1,304 +0,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. - * - * @flow - */ - -export type Path = string; -export type Glob = string; - -export type HasteConfig = {| - computeSha1?: boolean, - defaultPlatform?: ?string, - hasteImplModulePath?: string, - platforms?: Array, - providesModuleNodeModules: Array, -|}; - -export type ReporterConfig = [string, Object]; - -export type ConfigGlobals = Object; - -export type DefaultOptions = {| - automock: boolean, - bail: number, - browser: boolean, - cache: boolean, - cacheDirectory: Path, - changedFilesWithAncestor: boolean, - clearMocks: boolean, - collectCoverage: boolean, - collectCoverageFrom: ?Array, - coverageDirectory: ?string, - coveragePathIgnorePatterns: Array, - coverageReporters: Array, - coverageThreshold: ?{global: {[key: string]: number}}, - cwd: Path, - dependencyExtractor: ?string, - errorOnDeprecated: boolean, - expand: boolean, - filter: ?Path, - forceCoverageMatch: Array, - globals: ConfigGlobals, - globalSetup: ?string, - globalTeardown: ?string, - haste: HasteConfig, - maxConcurrency: number, - moduleDirectories: Array, - moduleFileExtensions: Array, - moduleNameMapper: {[key: string]: string}, - modulePathIgnorePatterns: Array, - noStackTrace: boolean, - notify: boolean, - notifyMode: string, - preset: ?string, - prettierPath: ?string, - projects: ?Array, - resetMocks: boolean, - resetModules: boolean, - resolver: ?Path, - restoreMocks: boolean, - rootDir: ?Path, - roots: ?Array, - runner: string, - runTestsByPath: boolean, - setupFiles: Array, - setupFilesAfterEnv: Array, - skipFilter: boolean, - snapshotSerializers: Array, - testEnvironment: string, - testEnvironmentOptions: Object, - testFailureExitCode: string | number, - testLocationInResults: boolean, - testMatch: Array, - testPathIgnorePatterns: Array, - testRegex: Array, - testResultsProcessor: ?string, - testRunner: ?string, - testURL: string, - timers: 'real' | 'fake', - transform: ?{[key: string]: string}, - transformIgnorePatterns: Array, - watchPathIgnorePatterns: Array, - useStderr: boolean, - verbose: ?boolean, - watch: boolean, - watchman: boolean, -|}; - -export type InitialOptions = { - automock?: boolean, - bail?: boolean | number, - browser?: boolean, - cache?: boolean, - cacheDirectory?: Path, - clearMocks?: boolean, - changedFilesWithAncestor?: boolean, - changedSince?: string, - collectCoverage?: boolean, - collectCoverageFrom?: Array, - collectCoverageOnlyFrom?: {[key: string]: boolean}, - coverageDirectory?: string, - coveragePathIgnorePatterns?: Array, - coverageReporters?: Array, - coverageThreshold?: {global: {[key: string]: number}}, - dependencyExtractor?: string, - detectLeaks?: boolean, - detectOpenHandles?: boolean, - displayName?: string, - expand?: boolean, - extraGlobals?: Array, - filter?: Path, - findRelatedTests?: boolean, - forceCoverageMatch?: Array, - forceExit?: boolean, - json?: boolean, - globals?: ConfigGlobals, - globalSetup?: ?string, - globalTeardown?: ?string, - haste?: HasteConfig, - reporters?: Array, - logHeapUsage?: boolean, - lastCommit?: boolean, - listTests?: boolean, - mapCoverage?: boolean, - maxConcurrency?: number, - moduleDirectories?: Array, - moduleFileExtensions?: Array, - moduleLoader?: Path, - moduleNameMapper?: {[key: string]: string}, - modulePathIgnorePatterns?: Array, - modulePaths?: Array, - name?: string, - noStackTrace?: boolean, - notify?: boolean, - notifyMode?: string, - onlyChanged?: boolean, - outputFile?: Path, - passWithNoTests?: boolean, - preprocessorIgnorePatterns?: Array, - preset?: ?string, - prettierPath?: ?string, - projects?: Array, - replname?: ?string, - resetMocks?: boolean, - resetModules?: boolean, - resolver?: ?Path, - restoreMocks?: boolean, - rootDir: Path, - roots?: Array, - runner?: string, - runTestsByPath?: boolean, - scriptPreprocessor?: string, - setupFiles?: Array, - setupTestFrameworkScriptFile?: Path, - setupFilesAfterEnv?: Array, - silent?: boolean, - skipFilter?: boolean, - skipNodeResolution?: boolean, - snapshotResolver?: Path, - snapshotSerializers?: Array, - errorOnDeprecated?: boolean, - testEnvironment?: string, - testEnvironmentOptions?: Object, - testFailureExitCode?: string | number, - testLocationInResults?: boolean, - testMatch?: Array, - testNamePattern?: string, - testPathDirs?: Array, - testPathIgnorePatterns?: Array, - testRegex?: string | Array, - testResultsProcessor?: ?string, - testRunner?: string, - testURL?: string, - timers?: 'real' | 'fake', - transform?: {[key: string]: string}, - transformIgnorePatterns?: Array, - watchPathIgnorePatterns?: Array, - unmockedModulePathPatterns?: Array, - updateSnapshot?: boolean, - useStderr?: boolean, - verbose?: ?boolean, - watch?: boolean, - watchAll?: boolean, - watchman?: boolean, - watchPlugins?: Array, -}; - -export type SnapshotUpdateState = 'all' | 'new' | 'none'; - -export type GlobalConfig = {| - bail: number, - changedSince: string, - changedFilesWithAncestor: boolean, - collectCoverage: boolean, - collectCoverageFrom: Array, - collectCoverageOnlyFrom: ?{[key: string]: boolean}, - coverageDirectory: string, - coveragePathIgnorePatterns?: Array, - coverageReporters: Array, - coverageThreshold: {global: {[key: string]: number}}, - detectLeaks: boolean, - detectOpenHandles: boolean, - enabledTestsMap: ?{[key: string]: {[key: string]: boolean}}, - expand: boolean, - extraGlobals: Array, - filter: ?Path, - findRelatedTests: boolean, - forceExit: boolean, - json: boolean, - globalSetup: ?string, - globalTeardown: ?string, - lastCommit: boolean, - logHeapUsage: boolean, - listTests: boolean, - maxConcurrency: number, - maxWorkers: number, - noStackTrace: boolean, - nonFlagArgs: Array, - noSCM: ?boolean, - notify: boolean, - notifyMode: string, - outputFile: ?Path, - onlyChanged: boolean, - onlyFailures: boolean, - passWithNoTests: boolean, - projects: Array, - replname: ?string, - reporters: Array, - runTestsByPath: boolean, - rootDir: Path, - silent: boolean, - skipFilter: boolean, - errorOnDeprecated: boolean, - testFailureExitCode: number, - testNamePattern: string, - testPathPattern: string, - testResultsProcessor: ?string, - updateSnapshot: SnapshotUpdateState, - useStderr: boolean, - verbose: ?boolean, - watch: boolean, - watchAll: boolean, - watchman: boolean, - watchPlugins: ?Array<{path: string, config: Object}>, -|}; - -export type ProjectConfig = {| - automock: boolean, - browser: boolean, - cache: boolean, - cacheDirectory: Path, - clearMocks: boolean, - coveragePathIgnorePatterns: Array, - cwd: Path, - dependencyExtractor?: string, - detectLeaks: boolean, - detectOpenHandles: boolean, - displayName: ?string, - errorOnDeprecated: boolean, - extraGlobals: Array, - filter: ?Path, - forceCoverageMatch: Array, - globalSetup: ?string, - globalTeardown: ?string, - globals: ConfigGlobals, - haste: HasteConfig, - moduleDirectories: Array, - moduleFileExtensions: Array, - moduleLoader: Path, - moduleNameMapper: Array<[string, string]>, - modulePathIgnorePatterns: Array, - modulePaths: Array, - name: string, - prettierPath: string, - resetMocks: boolean, - resetModules: boolean, - resolver: ?Path, - restoreMocks: boolean, - rootDir: Path, - roots: Array, - runner: string, - setupFiles: Array, - setupFilesAfterEnv: Array, - skipFilter: boolean, - skipNodeResolution: boolean, - snapshotResolver: ?Path, - snapshotSerializers: Array, - testEnvironment: string, - testEnvironmentOptions: Object, - testMatch: Array, - testLocationInResults: boolean, - testPathIgnorePatterns: Array, - testRegex: Array, - testRunner: string, - testURL: string, - timers: 'real' | 'fake', - transform: Array<[string, Path]>, - transformIgnorePatterns: Array, - watchPathIgnorePatterns: Array, - unmockedModulePathPatterns: ?Array, -|}; diff --git a/types/Console.js b/types/Console.js deleted file mode 100644 index 962a97db4a79..000000000000 --- a/types/Console.js +++ /dev/null @@ -1,31 +0,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. - * - * @flow - */ - -export type LogMessage = string; -export type LogEntry = {| - message: LogMessage, - origin: string, - type: LogType, -|}; -export type LogCounters = {[label: string]: number}; -export type LogTimers = {[label: string]: Date}; -export type LogType = - | 'assert' - | 'count' - | 'debug' - | 'dir' - | 'dirxml' - | 'error' - | 'group' - | 'groupCollapsed' - | 'info' - | 'log' - | 'time' - | 'warn'; -export type ConsoleBuffer = Array; diff --git a/types/Context.js b/types/Context.js deleted file mode 100644 index c49ba458695e..000000000000 --- a/types/Context.js +++ /dev/null @@ -1,19 +0,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. - * - * @flow - */ - -import type {ProjectConfig} from './Config'; -import type {HasteFS, ModuleMap} from './HasteMap'; -import type HasteResolver from 'jest-resolve'; - -export type Context = {| - config: ProjectConfig, - hasteFS: HasteFS, - moduleMap: ModuleMap, - resolver: HasteResolver, -|}; diff --git a/types/Environment.js b/types/Environment.js deleted file mode 100644 index b11fc9658370..000000000000 --- a/types/Environment.js +++ /dev/null @@ -1,43 +0,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. - * - * @flow - */ - -import type {ProjectConfig} from './Config'; -import type {Global} from './Global'; -import type {Script} from 'vm'; -import type {ModuleMocker} from 'jest-mock'; - -export type EnvironmentContext = { - console?: Object, - testPath?: string, -}; - -declare class $JestEnvironment { - constructor(config: ProjectConfig, context?: EnvironmentContext): void; - runScript(script: Script): any; - global: Global; - fakeTimers: { - clearAllTimers(): void, - runAllImmediates(): void, - runAllTicks(): void, - runAllTimers(): void, - advanceTimersByTime(msToRun: number): void, - runOnlyPendingTimers(): void, - runWithRealTimers(callback: any): void, - getTimerCount(): number, - useFakeTimers(): void, - useRealTimers(): void, - }; - testFilePath: string; - moduleMocker: ModuleMocker; - setup(): Promise; - teardown(): Promise; -} - -export type Environment = $JestEnvironment; -export type EnvironmentClass = typeof $JestEnvironment; diff --git a/types/Errors.js b/types/Errors.js deleted file mode 100644 index 01ac0b28b446..000000000000 --- a/types/Errors.js +++ /dev/null @@ -1,10 +0,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. - * - * @flow - */ - -export type ErrorWithCode = Error & {code?: string}; diff --git a/types/Global.js b/types/Global.js deleted file mode 100644 index 049e12d3b08f..000000000000 --- a/types/Global.js +++ /dev/null @@ -1,10 +0,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. - * - * @flow - */ - -export type Global = Object; diff --git a/types/HasteMap.js b/types/HasteMap.js deleted file mode 100644 index 6c3d59d8afd9..000000000000 --- a/types/HasteMap.js +++ /dev/null @@ -1,77 +0,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. - * - * @flow - */ - -import type { - ModuleMap as _ModuleMap, - SerializableModuleMap as _SerializableModuleMap, - FS, -} from 'jest-haste-map'; -import type {Path} from 'types/Config'; - -export type HasteFS = FS; -export type ModuleMap = _ModuleMap; -export type SerializableModuleMap = _SerializableModuleMap; - -export type FileData = Map; -export type MockData = Map; -export type ModuleMapData = Map; -export type WatchmanClocks = Map; -export type HasteRegExp = RegExp | ((str: string) => boolean); - -export type DuplicatesSet = Map; -export type DuplicatesIndex = Map>; - -export type InternalHasteMap = {| - clocks: WatchmanClocks, - duplicates: DuplicatesIndex, - files: FileData, - map: ModuleMapData, - mocks: MockData, -|}; - -export type HasteMap = {| - hasteFS: HasteFS, - moduleMap: ModuleMap, - __hasteMapForTest?: ?InternalHasteMap, -|}; - -export type RawModuleMap = {| - rootDir: Path, - duplicates: DuplicatesIndex, - map: ModuleMapData, - mocks: MockData, -|}; - -export type FileMetaData = [ - /* id */ string, - /* mtime */ number, - /* size */ number, - /* visited */ 0 | 1, - /* dependencies */ Array, - /* sha1 */ ?string, -]; - -type ModuleMapItem = {[platform: string]: ModuleMetaData, __proto__: null}; -export type ModuleMetaData = [Path, /* type */ number]; - -export type HType = {| - ID: 0, - MTIME: 1, - SIZE: 2, - VISITED: 3, - DEPENDENCIES: 4, - PATH: 0, - TYPE: 1, - MODULE: 0, - PACKAGE: 1, - GENERIC_PLATFORM: 'g', - NATIVE_PLATFORM: 'native', -|}; - -export type HTypeValue = $Values; diff --git a/types/Jasmine.js b/types/Jasmine.js deleted file mode 100644 index 965d2b355994..000000000000 --- a/types/Jasmine.js +++ /dev/null @@ -1,10 +0,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. - * - * @flow - */ - -export type Jasmine = Object; diff --git a/types/Jest.js b/types/Jest.js deleted file mode 100644 index 23f7c8e04996..000000000000 --- a/types/Jest.js +++ /dev/null @@ -1,54 +0,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. - * - * @flow - */ - -type JestMockFn = Function; - -export type LocalModuleRequire = (moduleName: string) => any; - -export type Jest = {| - addMatchers(matchers: Object): void, - autoMockOff(): Jest, - autoMockOn(): Jest, - clearAllMocks(): Jest, - clearAllTimers(): void, - deepUnmock(moduleName: string): Jest, - disableAutomock(): Jest, - doMock(moduleName: string, moduleFactory?: any): Jest, - dontMock(moduleName: string): Jest, - enableAutomock(): Jest, - fn: (implementation?: Function) => JestMockFn, - genMockFromModule(moduleName: string): any, - isMockFunction(fn: Function): boolean, - mock(moduleName: string, moduleFactory?: any, options?: Object): Jest, - requireActual: LocalModuleRequire, - requireMock: LocalModuleRequire, - resetAllMocks(): Jest, - resetModuleRegistry(): Jest, - resetModules(): Jest, - restoreAllMocks(): Jest, - retryTimes(numRetries: number): Jest, - runAllImmediates(): void, - runAllTicks(): void, - runAllTimers(): void, - runOnlyPendingTimers(): void, - advanceTimersByTime(msToRun: number): void, - runTimersToTime(msToRun: number): void, - getTimerCount(): number, - setMock(moduleName: string, moduleExports: any): Jest, - setTimeout(timeout: number): Jest, - spyOn( - object: Object, - methodName: string, - accessType?: 'get' | 'set', - ): JestMockFn, - unmock(moduleName: string): Jest, - useFakeTimers(): Jest, - useRealTimers(): Jest, - isolateModules(fn: () => void): Jest, -|}; diff --git a/types/JestHooks.js b/types/JestHooks.js deleted file mode 100644 index f92359bec389..000000000000 --- a/types/JestHooks.js +++ /dev/null @@ -1,39 +0,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. - * - * @flow - */ - -import type {AggregatedResult} from './TestResult'; -import type {Path, ProjectConfig} from './Config'; - -type TestSuiteInfo = { - config: ProjectConfig, - duration: ?number, - testPath: string, -}; - -export type JestHookExposedFS = { - projects: Array<{config: ProjectConfig, testPaths: Array}>, -}; - -export type FileChange = (fs: JestHookExposedFS) => void; -export type ShouldRunTestSuite = ( - testSuiteInfo: TestSuiteInfo, -) => Promise; -export type TestRunComplete = (results: AggregatedResult) => void; - -export type JestHookSubscriber = { - onFileChange: (fn: FileChange) => void, - onTestRunComplete: (fn: TestRunComplete) => void, - shouldRunTestSuite: (fn: ShouldRunTestSuite) => void, -}; - -export type JestHookEmitter = { - onFileChange: (fs: JestHookExposedFS) => void, - onTestRunComplete: (results: AggregatedResult) => void, - shouldRunTestSuite: (testSuiteInfo: TestSuiteInfo) => Promise, -}; diff --git a/types/Matchers.js b/types/Matchers.js deleted file mode 100644 index ac31b7456564..000000000000 --- a/types/Matchers.js +++ /dev/null @@ -1,91 +0,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. - * - * @flow - */ - -import type {Path} from 'types/Config'; -import type {SnapshotState} from 'jest-snapshot'; - -export type SyncExpectationResult = { - pass: boolean, - message: () => string, -}; - -export type AsyncExpectationResult = Promise; - -export type ExpectationResult = SyncExpectationResult | AsyncExpectationResult; - -export type RawMatcherFn = ( - expected: any, - actual: any, - options: any, -) => ExpectationResult; - -export type ThrowingMatcherFn = (actual: any) => void; -export type PromiseMatcherFn = (actual: any) => Promise; -export type MatcherState = { - assertionCalls: number, - currentTestName?: string, - error?: Error, - equals: (any, any, ?Array) => boolean, - expand?: boolean, - expectedAssertionsNumber: ?number, - isExpectingAssertions: ?boolean, - isNot: boolean, - promise: string, - snapshotState: SnapshotState, - suppressedErrors: Array, - testPath?: Path, - utils: Object, -}; - -export type AsymmetricMatcher = Object; -export type MatchersObject = {[id: string]: RawMatcherFn}; -export type Expect = { - (expected: any): ExpectationObject, - addSnapshotSerializer(any): void, - assertions(number): void, - extend(any): void, - extractExpectedAssertionsErrors: () => Array<{ - actual: string | number, - error: Error, - expected: string, - }>, - getState(): MatcherState, - hasAssertions(): void, - setState(Object): void, - - any(expectedObject: any): AsymmetricMatcher, - anything(): AsymmetricMatcher, - arrayContaining(sample: Array): AsymmetricMatcher, - objectContaining(sample: Object): AsymmetricMatcher, - stringContaining(expected: string): AsymmetricMatcher, - stringMatching(expected: string | RegExp): AsymmetricMatcher, - [id: string]: AsymmetricMatcher, - not: {[id: string]: AsymmetricMatcher}, -}; - -export type ExpectationObject = { - [id: string]: ThrowingMatcherFn, - resolves: { - [id: string]: PromiseMatcherFn, - not: {[id: string]: PromiseMatcherFn}, - }, - rejects: { - [id: string]: PromiseMatcherFn, - not: {[id: string]: PromiseMatcherFn}, - }, - not: {[id: string]: ThrowingMatcherFn}, -}; - -export type MatcherHintOptions = { - comment?: string, - isDirectExpectCall?: boolean, - isNot?: boolean, - promise?: string, - secondArgument?: ?string, -}; diff --git a/types/Mock.js b/types/Mock.js deleted file mode 100644 index 793819056cae..000000000000 --- a/types/Mock.js +++ /dev/null @@ -1,16 +0,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. - * - * @flow - */ - -import type { - MockFunctionMetadata as _MockFunctionMetadata, - ModuleMocker as _ModuleMocker, -} from 'jest-mock'; - -export type MockFunctionMetadata = _MockFunctionMetadata; -export type ModuleMocker = _ModuleMocker; diff --git a/types/PrettyFormat.js b/types/PrettyFormat.js deleted file mode 100644 index af1e0f6e1971..000000000000 --- a/types/PrettyFormat.js +++ /dev/null @@ -1,130 +0,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. - * - * @flow - */ - -export type Colors = { - comment: {close: string, open: string}, - content: {close: string, open: string}, - prop: {close: string, open: string}, - tag: {close: string, open: string}, - value: {close: string, open: string}, -}; -export type Indent = string => string; -export type Refs = Array; -export type Print = any => string; -export type StringOrNull = string | null; - -export type Theme = {| - comment: string, - content: string, - prop: string, - tag: string, - value: string, -|}; - -export type ThemeReceived = {| - comment?: string, - content?: string, - prop?: string, - tag?: string, - value?: string, -|}; - -export type Options = {| - callToJSON: boolean, - escapeRegex: boolean, - escapeString: boolean, - highlight: boolean, - indent: number, - maxDepth: number, - min: boolean, - plugins: Plugins, - printFunctionName: boolean, - theme: Theme, -|}; - -export type OptionsReceived = {| - callToJSON?: boolean, - escapeRegex?: boolean, - escapeString?: boolean, - highlight?: boolean, - indent?: number, - maxDepth?: number, - min?: boolean, - plugins?: Plugins, - printFunctionName?: boolean, - theme?: ThemeReceived, -|}; - -export type Config = {| - callToJSON: boolean, - colors: Colors, - escapeRegex: boolean, - escapeString: boolean, - indent: string, - maxDepth: number, - min: boolean, - plugins: Plugins, - printFunctionName: boolean, - spacingInner: string, - spacingOuter: string, -|}; - -export type Printer = ( - val: any, - config: Config, - indentation: string, - depth: number, - refs: Refs, - hasCalledToJSON?: boolean, -) => string; - -export type Test = any => boolean; - -export type NewPlugin = {| - serialize: ( - val: any, - config: Config, - indentation: string, - depth: number, - refs: Refs, - printer: Printer, - ) => string, - test: Test, -|}; - -export type PluginOptions = {| - edgeSpacing: string, - min: boolean, - spacing: string, -|}; - -export type OldPlugin = {| - print: ( - val: any, - print: Print, - indent: Indent, - options: PluginOptions, - colors: Colors, - ) => string, - test: Test, -|}; - -export type Plugin = NewPlugin | OldPlugin; - -export type Plugins = Array; - -export type ReactTestObject = {| - $$typeof: Symbol, - type: string, - props?: Object, - children?: null | Array, -|}; - -// Child can be `number` in Stack renderer but not in Fiber renderer. -export type ReactTestChild = ReactTestObject | string | number; diff --git a/types/Process.js b/types/Process.js deleted file mode 100644 index b1c500f0d80b..000000000000 --- a/types/Process.js +++ /dev/null @@ -1,13 +0,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. - * - * @flow - */ - -export interface Process { - stdout: stream$Writable | tty$WriteStream; - exit(code?: number): void; -} diff --git a/types/Reporters.js b/types/Reporters.js deleted file mode 100644 index 07d35e93a3d0..000000000000 --- a/types/Reporters.js +++ /dev/null @@ -1,13 +0,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. - * - * @flow - */ - -export type ReporterOnStartOptions = {| - estimatedTime: number, - showStatus: boolean, -|}; diff --git a/types/Resolve.js b/types/Resolve.js deleted file mode 100644 index facd55e4fc56..000000000000 --- a/types/Resolve.js +++ /dev/null @@ -1,24 +0,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. - * - * @flow - */ - -import type _Resolver from 'jest-resolve'; - -import type {Path} from './Config'; - -export type ResolveModuleConfig = {| - skipNodeResolution?: boolean, - paths?: Path[], -|}; - -export type ResolvedModule = { - file: string, - dependencies?: string[], -}; - -export type Resolver = _Resolver; diff --git a/types/SnapshotResolver.js b/types/SnapshotResolver.js deleted file mode 100644 index 6127d1ed4968..000000000000 --- a/types/SnapshotResolver.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - -import type {Path} from './Config'; - -export type SnapshotResolver = {| - testPathForConsistencyCheck: string, - resolveSnapshotPath(testPath: Path): Path, - resoveTestPath(snapshotPath: Path): Path, -|}; diff --git a/types/SourceMaps.js b/types/SourceMaps.js deleted file mode 100644 index dc0ee2398c84..000000000000 --- a/types/SourceMaps.js +++ /dev/null @@ -1,10 +0,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. - * - * @flow - */ - -export type SourceMapRegistry = {[key: string]: string, __proto__: null}; diff --git a/types/TestResult.js b/types/TestResult.js deleted file mode 100644 index 60436b6c77e9..000000000000 --- a/types/TestResult.js +++ /dev/null @@ -1,238 +0,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. - * - * @flow - */ - -import type {ConsoleBuffer} from './Console'; - -export type RawFileCoverage = {| - path: string, - s: {[statementId: number]: number}, - b: {[branchId: number]: number}, - f: {[functionId: number]: number}, - l: {[lineId: number]: number}, - fnMap: {[functionId: number]: any}, - statementMap: {[statementId: number]: any}, - branchMap: {[branchId: number]: any}, - inputSourceMap?: Object, -|}; - -export type RawCoverage = { - [filePath: string]: RawFileCoverage, -}; - -type FileCoverageTotal = {| - total: number, - covered: number, - skipped: number, - pct: number, -|}; - -export type CoverageSummary = {| - lines: FileCoverageTotal, - statements: FileCoverageTotal, - branches: FileCoverageTotal, - functions: FileCoverageTotal, - merge: (other: CoverageSummary) => void, -|}; - -export type FileCoverage = {| - getLineCoverage: () => Object, - getUncoveredLines: () => Array, - getBranchCoverageByLine: () => Object, - toJSON: () => Object, - merge: (other: Object) => void, - computeSimpleTotals: (property: string) => FileCoverageTotal, - computeBranchTotals: () => FileCoverageTotal, - resetHits: () => void, - toSummary: () => CoverageSummary, -|}; - -export type CoverageMap = {| - merge: (data: Object) => void, - getCoverageSummary: () => FileCoverage, - data: RawCoverage, - addFileCoverage: (fileCoverage: RawFileCoverage) => void, - files: () => Array, - fileCoverageFor: (file: string) => FileCoverage, -|}; - -export type SerializableError = {| - code?: mixed, - message: string, - stack: ?string, - type?: string, -|}; - -export type FailedAssertion = {| - matcherName: string, - message?: string, - actual?: any, - pass?: boolean, - expected?: any, - isNot?: boolean, - stack?: string, -|}; - -export type AssertionLocation = {| - fullName: string, - path: string, -|}; - -export type Status = - | 'passed' - | 'failed' - | 'skipped' - | 'pending' - | 'todo' - | 'disabled'; - -export type Bytes = number; -export type Milliseconds = number; - -type Callsite = {| - column: number, - line: number, -|}; - -export type AssertionResult = {| - ancestorTitles: Array, - duration?: ?Milliseconds, - failureMessages: Array, - fullName: string, - invocations?: number, - location: ?Callsite, - numPassingAsserts: number, - status: Status, - title: string, -|}; - -export type FormattedAssertionResult = { - failureMessages: Array | null, - fullName: string, - location: ?Callsite, - status: Status, - title: string, -}; - -export type AggregatedResultWithoutCoverage = { - numFailedTests: number, - numFailedTestSuites: number, - numPassedTests: number, - numPassedTestSuites: number, - numPendingTests: number, - numTodoTests: number, - numPendingTestSuites: number, - numRuntimeErrorTestSuites: number, - numTotalTests: number, - numTotalTestSuites: number, - openHandles: Array, - snapshot: SnapshotSummary, - startTime: number, - success: boolean, - testResults: Array, - wasInterrupted: boolean, -}; - -export type AggregatedResult = AggregatedResultWithoutCoverage & { - coverageMap?: ?CoverageMap, -}; - -export type Suite = {| - title: string, - suites: Array, - tests: Array, -|}; - -export type TestResult = {| - console: ?ConsoleBuffer, - coverage?: RawCoverage, - displayName: ?string, - failureMessage: ?string, - leaks: boolean, - memoryUsage?: Bytes, - numFailingTests: number, - numPassingTests: number, - numPendingTests: number, - numTodoTests: number, - openHandles: Array, - perfStats: {| - end: Milliseconds, - start: Milliseconds, - |}, - skipped: boolean, - snapshot: {| - added: number, - fileDeleted: boolean, - matched: number, - unchecked: number, - uncheckedKeys: Array, - unmatched: number, - updated: number, - |}, - sourceMaps: {[sourcePath: string]: string}, - testExecError?: SerializableError, - testFilePath: string, - testResults: Array, -|}; - -export type FormattedTestResult = { - message: string, - name: string, - summary: string, - status: 'failed' | 'passed', - startTime: number, - endTime: number, - coverage: any, - assertionResults: Array, -}; - -export type FormattedTestResults = { - coverageMap?: ?CoverageMap, - numFailedTests: number, - numFailedTestSuites: number, - numPassedTests: number, - numPassedTestSuites: number, - numPendingTests: number, - numPendingTestSuites: number, - numRuntimeErrorTestSuites: number, - numTotalTests: number, - numTotalTestSuites: number, - snapshot: SnapshotSummary, - startTime: number, - success: boolean, - testResults: Array, - wasInterrupted: boolean, -}; - -export type CodeCoverageReporter = any; - -export type CodeCoverageFormatter = ( - coverage: ?RawCoverage, - reporter?: CodeCoverageReporter, -) => ?Object; - -export type UncheckedSnapshot = {| - filePath: string, - keys: Array, -|}; - -export type SnapshotSummary = {| - added: number, - didUpdate: boolean, - failure: boolean, - filesAdded: number, - filesRemoved: number, - filesUnmatched: number, - filesUpdated: number, - matched: number, - total: number, - unchecked: number, - uncheckedKeysByFile: Array, - unmatched: number, - updated: number, -|}; diff --git a/types/TestRunner.js b/types/TestRunner.js deleted file mode 100644 index 2588e1a29296..000000000000 --- a/types/TestRunner.js +++ /dev/null @@ -1,71 +0,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. - * - * @flow - */ - -import type {Context} from './Context'; -import type {Environment} from './Environment'; -import type {GlobalConfig, Path, ProjectConfig} from './Config'; -import type {ReporterOnStartOptions} from './Reporters'; -import type { - AggregatedResult, - SerializableError, - TestResult, -} from './TestResult'; -import type Runtime from 'jest-runtime'; -import type {TestWatcher as _TestWatcher} from '@jest/core'; - -export type Test = {| - context: Context, - duration: ?number, - path: Path, -|}; - -export type TestWatcher = _TestWatcher; - -export type OnTestStart = Test => Promise; -export type OnTestFailure = (Test, SerializableError) => Promise<*>; -export type OnTestSuccess = (Test, TestResult) => Promise<*>; - -export type Reporter = { - +onTestResult: ( - test: Test, - testResult: TestResult, - aggregatedResult: AggregatedResult, - ) => ?Promise, - +onRunStart: ( - results: AggregatedResult, - options: ReporterOnStartOptions, - ) => ?Promise, - +onTestStart: (test: Test) => ?Promise, - +onRunComplete: ( - contexts: Set, - results: AggregatedResult, - ) => ?Promise, - +getLastError: () => ?Error, -}; - -export type TestFramework = ( - globalConfig: GlobalConfig, - config: ProjectConfig, - environment: Environment, - runtime: Runtime, - testPath: string, -) => Promise; - -export type TestRunnerOptions = { - serial: boolean, -}; - -export type TestRunnerContext = { - changedFiles?: Set, -}; - -export type TestRunData = Array<{ - context: Context, - matches: {allTests: number, tests: Array, total: number}, -}>; diff --git a/types/TestScheduler.js b/types/TestScheduler.js deleted file mode 100644 index eab290edb364..000000000000 --- a/types/TestScheduler.js +++ /dev/null @@ -1,16 +0,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. - * - * @flow - */ - -import type {Path} from './Config'; - -export type TestSchedulerContext = {| - firstRun: boolean, - previousSuccess: boolean, - changedFiles?: Set, -|}; diff --git a/types/Transform.js b/types/Transform.js deleted file mode 100644 index af2f83db00c8..000000000000 --- a/types/Transform.js +++ /dev/null @@ -1,51 +0,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. - * - * @flow - */ - -import type {Path, ProjectConfig} from 'types/Config'; -import type {Script} from 'vm'; - -export type TransformedSource = {| - code: string, - map: ?Object | string, -|}; - -export type TransformResult = {| - script: Script, - mapCoverage: boolean, - sourceMapPath: ?string, -|}; - -export type TransformOptions = {| - instrument: boolean, -|}; - -export type CacheKeyOptions = {| - config: ProjectConfig, - instrument: boolean, - rootDir: string, -|}; - -export type Transformer = {| - canInstrument?: boolean, - createTransformer?: (options: any) => Transformer, - - getCacheKey: ( - fileData: string, - filePath: Path, - configStr: string, - options: CacheKeyOptions, - ) => string, - - process: ( - sourceText: string, - sourcePath: Path, - config: ProjectConfig, - options?: TransformOptions, - ) => string | TransformedSource, -|}; diff --git a/types/Watch.js b/types/Watch.js deleted file mode 100644 index 54e8d2f17dcc..000000000000 --- a/types/Watch.js +++ /dev/null @@ -1,13 +0,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. - * - * @flow - */ - -export type ScrollOptions = { - offset: number, - max: number, -}; diff --git a/yarn.lock b/yarn.lock index 34e1acc8f2b5..b818a73ac16f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5974,11 +5974,6 @@ flatten@^1.0.2: resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" integrity sha1-2uRqnXj74lKSJYzB54CkHZXAN4I= -flow-bin@^0.94.0: - version "0.94.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.94.0.tgz#b5d58fe7559705b73a18229f97edfc3ab6ffffcb" - integrity sha512-DYF7r9CJ/AksfmmB4+q+TyLMoeQPRnqtF1Pk7KY3zgfkB/nVuA3nXyzqgsIPIvnMSiFEXQcFK4z+iPxSLckZhQ== - flush-write-stream@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8" From f8e5afd5a650b5d5c39222ce344306ebafe6fa05 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 6 Mar 2019 13:43:02 +0100 Subject: [PATCH 2/4] update lint config as well --- .eslintrc.js | 27 -------------- eslintImportResolver.js | 82 ----------------------------------------- 2 files changed, 109 deletions(-) delete mode 100644 eslintImportResolver.js diff --git a/.eslintrc.js b/.eslintrc.js index 8d6ac703ad22..57a9f0a1b93f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,8 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -const customImportResolver = require.resolve('./eslintImportResolver'); - module.exports = { extends: [ './packages/eslint-config-fb-strict/index.js', @@ -71,26 +69,6 @@ module.exports = { 'import/no-extraneous-dependencies': 0, }, }, - { - files: [ - 'e2e/__tests__/**/*.js', - 'packages/babel-jest/**/*.test.js', - 'packages/babel-plugin-jest-hoist/**/*.test.js', - 'packages/babel-preset-jest/**/*.test.js', - 'packages/eslint-config-fb-strict/**/*.test.js', - 'packages/eslint-plugin-jest/**/*.test.js', - 'packages/jest-changed-files/**/*.test.js', - 'packages/jest-circus/**/*.test.js', - 'packages/jest-diff/**/*.test.js', - 'packages/jest-docblock/**/*.test.js', - 'packages/jest-editor-support/**/*.test.js', - 'packages/jest/**/*.test.js', - 'packages/pretty-format/**/*.test.js', - ], - rules: { - 'flowtype/require-valid-file-annotation': [2, 'always'], - }, - }, { files: [ 'website/**', @@ -133,11 +111,6 @@ module.exports = { }, settings: { 'import/resolver': { - [customImportResolver]: { - moduleNameMapper: { - '^types/(.*)': './types/$1', - }, - }, 'eslint-import-resolver-typescript': true, }, }, diff --git a/eslintImportResolver.js b/eslintImportResolver.js deleted file mode 100644 index e610c46936d5..000000000000 --- a/eslintImportResolver.js +++ /dev/null @@ -1,82 +0,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. - * - * Adapted from node resolver: https://github.com/benmosher/eslint-plugin-import/tree/master/resolvers/node - * - */ - -'use strict'; - -const resolve = require('resolve'); -const path = require('path'); - -const log = require('debug')('eslint-plugin-import:resolver:node'); - -module.exports.interfaceVersion = 2; - -module.exports.resolve = function(source, file, config) { - log('Resolving:', source, 'from:', file); - let resolvedPath; - - if (resolve.isCore(source)) { - log('resolved to core'); - return {found: true, path: null}; - } - - source = applyModuleNameMapper(source, config); - - try { - resolvedPath = resolve.sync(source, opts(file, config)); - log('Resolved to:', resolvedPath); - return {found: true, path: resolvedPath}; - } catch (err) { - log('resolve threw error:', err); - return {found: false}; - } -}; - -function opts(file, config) { - return Object.assign( - { - // more closely matches Node (#333) - extensions: ['.js', '.json'], - }, - config, - { - // path.resolve will handle paths relative to CWD - basedir: path.dirname(path.resolve(file)), - packageFilter, - } - ); -} - -function packageFilter(pkg) { - if (pkg['jsnext:main']) { - pkg['main'] = pkg['jsnext:main']; - } - return pkg; -} - -function applyModuleNameMapper(source, config) { - Object.keys(config.moduleNameMapper).forEach(regex => { - const mappedModuleName = config.moduleNameMapper[regex]; - - if (source.match(regex)) { - const matches = source.match(regex); - if (!matches) { - source = mappedModuleName; - } else { - source = mappedModuleName.replace( - /\$([0-9]+)/g, - (_, index) => matches[parseInt(index, 10)] - ); - } - source = path.resolve(source); - } - }); - - return source; -} From 7d1114258bf526fc74514580e76926173f11482e Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 6 Mar 2019 15:33:09 +0100 Subject: [PATCH 3/4] chore: update snapshot --- ...{notify_reporter.test.js.snap => notify_reporter.test.ts.snap} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/jest-reporters/src/__tests__/__snapshots__/{notify_reporter.test.js.snap => notify_reporter.test.ts.snap} (100%) diff --git a/packages/jest-reporters/src/__tests__/__snapshots__/notify_reporter.test.js.snap b/packages/jest-reporters/src/__tests__/__snapshots__/notify_reporter.test.ts.snap similarity index 100% rename from packages/jest-reporters/src/__tests__/__snapshots__/notify_reporter.test.js.snap rename to packages/jest-reporters/src/__tests__/__snapshots__/notify_reporter.test.ts.snap From 19b45955d1500eadf9e398bbb032cd0d9fad5c86 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 14 Mar 2019 15:30:27 +0100 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51411cb970fc..5fb1dff57463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[*]` Remove flow from code base ([#8061](https://github.com/facebook/jest/pull/8061)) + ### Performance ## 24.5.0