Skip to content

Commit

Permalink
More accurate flow types. (jestjs#1178)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer authored Jun 17, 2016
1 parent 93c754f commit 6de1b39
Show file tree
Hide file tree
Showing 17 changed files with 334 additions and 102 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/vendor/**
bin/
docs/
flowlibs/**
packages/*/build/**
types/**
website/
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[include]

[libs]
flowlibs

[options]
module.name_mapper='^types/\(.*\)$' -> '<PROJECT_ROOT>/types/\1.js'
Expand Down
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
## master

* Add support for property testing via testcheck-js.
## jest 14.0.0

* Split up `jest-cli` into `jest-runtime` and `jest-config`.
* Added a notification plugin that shows a test run notification
using `--notify`.
* Refactored `TestRunner` into `SearchSource` and improved the
"no tests found" message.
* Added `jest.isMockFunction(jest.fn())` to test for mock functions.
* Improved test reporter printing and added a test failure summary when
running many tests.
* Add support for property testing via testcheck-js.
* Added a webpack tutorial.
* Added support for virtual mocks through
`jest.mock('Module', implementation, {virtual: true})`.
* Added snapshot functionality through `toMatchSnapshot()`.
* Redesigned website.

## jest-cli 12.1.1

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ Jest uses Jasmine 2 by default. An introduction to Jasmine 2 can be found
- [`moduleNameMapper` [object<string, string>]](https://facebook.github.io/jest/docs/api.html#modulenamemapper-object-string-string)
- [`modulePaths` [array<string>]](https://facebook.github.io/jest/docs/api.html#modulepaths-array-string)
- [`modulePathIgnorePatterns` [array<string>]](https://facebook.github.io/jest/docs/api.html#modulepathignorepatterns-array-string)
- [`notify` [boolean]](https://facebook.github.io/jest/docs/api.html#notify-boolean)
- [`preprocessorIgnorePatterns` [array<string>]](https://facebook.github.io/jest/docs/api.html#preprocessorignorepatterns-array-string)
- [`rootDir` [string]](https://facebook.github.io/jest/docs/api.html#rootdir-string)
- [`scriptPreprocessor` [string]](https://facebook.github.io/jest/docs/api.html#scriptpreprocessor-string)
Expand Down Expand Up @@ -815,6 +816,11 @@ Example:
}
```

### `notify` [boolean]
(default: `false`)

Activates notifications for test results.

### `rootDir` [string]
(default: The root of the directory containing the `package.json` *or* the [`pwd`](http://en.wikipedia.org/wiki/Pwd) if no `package.json` is found)

Expand Down
169 changes: 169 additions & 0 deletions flowlibs/graceful-fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

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<string>) => void): void;
declare function readdirSync(path: string): Array<string>;
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;
}
26 changes: 26 additions & 0 deletions flowlibs/resolve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';

declare module "resolve" {
declare function isCore(moduleName: string): boolean;
declare function sync(path: string): string;
}

declare module "resolve/lib/node-modules-paths" {
declare type NodeModulesPathsOptions = {
moduleDirectory: Array<string>,
};

declare function exports(
path: string,
options: NodeModulesPathsOptions,
): Array<string>;
}
Loading

0 comments on commit 6de1b39

Please sign in to comment.