Skip to content

Commit

Permalink
chore: migrate jest-util to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 9, 2019
1 parent dc35500 commit 02aa43c
Show file tree
Hide file tree
Showing 45 changed files with 889 additions and 690 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- `[jest-serializer]`: Migrate to TypeScript ([#7841](https://github.com/facebook/jest/pull/7841))
- `[jest-message-util]`: Migrate to TypeScript ([#7834](https://github.com/facebook/jest/pull/7834))
- `[@jest/types]`: New package to handle shared types ([#7834](https://github.com/facebook/jest/pull/7834))
- `[jest-util]`: Migrate to TypeScript ([#7844](https://github.com/facebook/jest/pull/7844))

### Performance

Expand Down
1 change: 1 addition & 0 deletions packages/jest-circus/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
TestMode,
} from 'types/Circus';
import {bind as bindEach} from 'jest-each';
// $FlowFixMe: Converted to TS
import {ErrorWithStack} from 'jest-util';
import {dispatch} from './state';

Expand Down
1 change: 1 addition & 0 deletions packages/jest-circus/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
TestName,
TestResults,
} from 'types/Circus';
// $FlowFixMe: Converted to TS
import {convertDescriptorToString} from 'jest-util';
import isGeneratorFn from 'is-generator-fn';
import co from 'co';
Expand Down
11 changes: 5 additions & 6 deletions packages/jest-message-util/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import slash from 'slash';
import {codeFrameColumns} from '@babel/code-frame';
import StackUtils from 'stack-utils';

type Glob = Config.Glob;
type Path = Config.Path;
type AssertionResult = TestResult.AssertionResult;
type SerializableError = TestResult.SerializableError;
Expand All @@ -33,12 +32,12 @@ try {
// node internals in the browser though, so no issue.
}

type StackTraceConfig = {
rootDir: string;
testMatch: Array<Glob>;
};
export type StackTraceConfig = Pick<
Config.ProjectConfig,
'rootDir' | 'testMatch'
>;

type StackTraceOptions = {
export type StackTraceOptions = {
noStackTrace: boolean;
};

Expand Down
2 changes: 0 additions & 2 deletions packages/jest-runner/src/runTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function freezeConsole(
testConsole: BufferedConsole | Console | NullConsole,
config: ProjectConfig,
) {
// $FlowFixMe: overwrite it for pretty errors
testConsole._log = function fakeConsolePush(_type, message) {
const error = new ErrorWithStack(
`${chalk.red(
Expand Down Expand Up @@ -89,7 +88,6 @@ async function runTestInternal(
if (customEnvironment) {
testEnvironment = getTestEnvironment({
...config,
// $FlowFixMe
testEnvironment: customEnvironment,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +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 type {Global} from 'types/Global';

export default (global: Global, key: string, value: any) =>
(global[key] = value);
export type SourceMapRegistry = {[key: string]: string};
9 changes: 5 additions & 4 deletions packages/jest-types/src/TestResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export type AssertionResult = {
};

export type FormattedAssertionResult = {
ancestorTitles: Array<string>;
failureMessages: Array<string> | null;
fullName: string;
location: Callsite | null | undefined;
Expand Down Expand Up @@ -150,7 +151,7 @@ export type AggregatedResultWithoutCoverage = {
};

export type AggregatedResult = AggregatedResultWithoutCoverage & {
coverageMap?: CoverageMap | null | undefined;
coverageMap?: CoverageMap | null;
};

export type Suite = {
Expand All @@ -160,10 +161,10 @@ export type Suite = {
};

export type TestResult = {
console: ConsoleBuffer | null | undefined;
console?: ConsoleBuffer | null;
coverage?: RawCoverage;
displayName: string | null | undefined;
failureMessage: string | null | undefined;
displayName?: string | null;
failureMessage?: string | null;
leaks: boolean;
memoryUsage?: Bytes;
numFailingTests: number;
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import * as Config from './Config';
import * as Console from './Console';
import * as SourceMaps from './SourceMaps';
import * as TestResult from './TestResult';

export {Config, Console, TestResult};
export {Config, Console, SourceMaps, TestResult};
8 changes: 6 additions & 2 deletions packages/jest-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@
"license": "MIT",
"main": "build/index.js",
"dependencies": {
"@jest/types": "^24.1.0",
"@types/node": "*",
"callsites": "^3.0.0",
"chalk": "^2.0.1",
"graceful-fs": "^4.1.15",
"is-ci": "^2.0.0",
"jest-message-util": "^24.0.0",
"jest-mock": "^24.0.0",
"mkdirp": "^0.5.1",
"readable-stream": "^3.1.1",
"slash": "^2.0.0",
"source-map": "^0.6.0"
},
"devDependencies": {
"@types/callsites": "^2.0.0",
"@types/graceful-fs": "^4.1.2",
"@types/is-ci": "^1.0.10",
"@types/mkdirp": "^0.5.2",
"jest-mock": "^24.0.0"
"@types/readable-stream": "^2.3.0",
"@types/slash": "^2.0.0"
},
"engines": {
"node": ">= 6"
Expand Down
167 changes: 0 additions & 167 deletions packages/jest-util/src/BufferedConsole.js

This file was deleted.

Loading

0 comments on commit 02aa43c

Please sign in to comment.