Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate jest-util to TypeScript #7844

Merged
merged 6 commits into from Feb 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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
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
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
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
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
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
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
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",
thymikee marked this conversation as resolved.
Show resolved Hide resolved
"@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.