Skip to content

Commit

Permalink
merged master & resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal-kushwaha committed Jul 28, 2020
2 parents 4538211 + 76f356e commit b235a1b
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 25 deletions.
8 changes: 5 additions & 3 deletions packages/jest-config/src/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
*/

import {createHash} from 'crypto';
import chalk = require('chalk');
import type {ForegroundColor} from 'chalk';

const colors: Array<keyof typeof chalk> = [
type Color = typeof ForegroundColor;

const colors: Array<Color> = [
'red',
'green',
'yellow',
Expand All @@ -18,7 +20,7 @@ const colors: Array<keyof typeof chalk> = [
'white',
];

export const getDisplayNameColor = (seed?: string): typeof colors[number] => {
export const getDisplayNameColor = (seed?: string): Color => {
if (seed === undefined) {
return 'white';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/TestScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export default class TestScheduler {
return aggregatedResults;
}

private static _partitionTests(
private _partitionTests(
testRunners: Record<string, TestRunner>,
tests: Array<TestRunner.Test>,
): Record<string, Array<TestRunner.Test>> | null {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-reporters/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
TestResult,
} from '@jest/test-result';
import type {FS as HasteFS, ModuleMap} from 'jest-haste-map';
import HasteResolver = require('jest-resolve');
import type {ResolverType} from 'jest-resolve';
import type {worker} from './coverage_worker';

export type ReporterOnStartOptions = {
Expand All @@ -25,7 +25,7 @@ export type Context = {
config: Config.ProjectConfig;
hasteFS: HasteFS;
moduleMap: ModuleMap;
resolver: HasteResolver;
resolver: ResolverType;
};

export type Test = {
Expand Down
12 changes: 6 additions & 6 deletions packages/jest-resolve-dependencies/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type {Config} from '@jest/types';
import type {FS as HasteFS} from 'jest-haste-map';
import Resolver = require('jest-resolve');
import type {ResolveModuleConfig, ResolverType} from 'jest-resolve';
import {SnapshotResolver, isSnapshotPath} from 'jest-snapshot';

namespace DependencyResolver {
Expand All @@ -24,11 +24,11 @@ namespace DependencyResolver {
/* eslint-disable-next-line no-redeclare */
class DependencyResolver {
private _hasteFS: HasteFS;
private _resolver: Resolver;
private _resolver: ResolverType;
private _snapshotResolver: SnapshotResolver;

constructor(
resolver: Resolver,
resolver: ResolverType,
hasteFS: HasteFS,
snapshotResolver: SnapshotResolver,
) {
Expand All @@ -39,7 +39,7 @@ class DependencyResolver {

resolve(
file: Config.Path,
options?: Resolver.ResolveModuleConfig,
options?: ResolveModuleConfig,
): Array<Config.Path> {
const dependencies = this._hasteFS.getDependencies(file);
if (!dependencies) {
Expand Down Expand Up @@ -76,7 +76,7 @@ class DependencyResolver {
resolveInverseModuleMap(
paths: Set<Config.Path>,
filter: (file: Config.Path) => boolean,
options?: Resolver.ResolveModuleConfig,
options?: ResolveModuleConfig,
): Array<DependencyResolver.ResolvedModule> {
if (!paths.size) {
return [];
Expand Down Expand Up @@ -141,7 +141,7 @@ class DependencyResolver {
resolveInverse(
paths: Set<Config.Path>,
filter: (file: Config.Path) => boolean,
options?: Resolver.ResolveModuleConfig,
options?: ResolveModuleConfig,
): Array<Config.Path> {
return this.resolveInverseModuleMap(paths, filter, options).map(
module => module.file,
Expand Down
1 change: 1 addition & 0 deletions packages/jest-resolve/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace Resolver {
skipNodeResolution?: boolean;
paths?: Array<Config.Path>;
};
export type ResolverType = Resolver;
}

const NATIVE_PLATFORM = 'native';
Expand Down
10 changes: 7 additions & 3 deletions packages/jest-runner/src/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import RuntimeClass = require('jest-runtime');
import * as fs from 'graceful-fs';
import {ErrorWithStack, interopRequireDefault, setGlobal} from 'jest-util';
import LeakDetector from 'jest-leak-detector';
import Resolver = require('jest-resolve');
import type {ResolverType} from 'jest-resolve';
import {getTestEnvironment} from 'jest-config';
import * as docblock from 'jest-docblock';
import {formatExecError} from 'jest-message-util';
Expand Down Expand Up @@ -79,8 +79,10 @@ async function runTestInternal(
path: Config.Path,
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
resolver: Resolver,

resolver: ResolverType,
sendMessageToJest?: TestFileEvent,

context?: TestRunnerContext,
): Promise<RunTestInternalResult> {
const testSource = fs.readFileSync(path, 'utf8');
Expand Down Expand Up @@ -313,8 +315,10 @@ export default async function runTest(
path: Config.Path,
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
resolver: Resolver,

resolver: ResolverType,
sendMessageToJest?: TestFileEvent,

context?: TestRunnerContext,
): Promise<TestResult> {
const {leakDetector, result} = await runTestInternal(
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-runner/src/testWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import HasteMap = require('jest-haste-map');
import exit = require('exit');
import {separateMessageFromStack} from 'jest-message-util';
import Runtime = require('jest-runtime');
import Resolver = require('jest-resolve');

import type {ResolverType} from 'jest-resolve';
import {messageParent} from 'jest-worker';
import type {
ErrorWithCode,
TestFileEvent,
TestRunnerSerializedContext,
} from './types';

import runTest from './runTest';

export type SerializableResolver = {
Expand Down Expand Up @@ -57,7 +59,7 @@ const formatError = (error: string | ErrorWithCode): SerializableError => {
};
};

const resolvers = new Map<string, Resolver>();
const resolvers = new Map<string, ResolverType>();
const getResolver = (config: Config.ProjectConfig) => {
const resolver = resolvers.get(config.name);
if (!resolver) {
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-runner/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type {
} from '@jest/test-result';
import type {JestEnvironment} from '@jest/environment';
import type {FS as HasteFS, ModuleMap} from 'jest-haste-map';
import HasteResolver = require('jest-resolve');
import Runtime = require('jest-runtime');
import type {ResolverType} from 'jest-resolve';
import type {RuntimeType} from 'jest-runtime';

export type ErrorWithCode = Error & {code?: string};
export type Test = {
Expand All @@ -28,7 +28,7 @@ export type Context = {
config: Config.ProjectConfig;
hasteFS: HasteFS;
moduleMap: ModuleMap;
resolver: HasteResolver;
resolver: ResolverType;
};

export type OnTestStart = (test: Test) => Promise<void>;
Expand Down Expand Up @@ -58,7 +58,7 @@ export type TestFramework = (
globalConfig: Config.GlobalConfig,
config: Config.ProjectConfig,
environment: JestEnvironment,
runtime: Runtime,
runtime: RuntimeType,
testPath: string,
sendMessageToJest?: TestFileEvent,
) => Promise<TestResult>;
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-runtime/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

import type {Config} from '@jest/types';
import HasteResolver = require('jest-resolve');
import type {ResolverType} from 'jest-resolve';
import type {FS as HasteFS, ModuleMap} from 'jest-haste-map';

export type Context = {
config: Config.ProjectConfig;
hasteFS: HasteFS;
moduleMap: ModuleMap;
resolver: HasteResolver;
resolver: ResolverType;
};
4 changes: 2 additions & 2 deletions packages/jest-types/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type {Arguments} from 'yargs';
import type {ReportOptions} from 'istanbul-reports';
import chalk = require('chalk');
import type {ForegroundColor} from 'chalk';

type CoverageProvider = 'babel' | 'v8';

Expand Down Expand Up @@ -86,7 +86,7 @@ export type DefaultOptions = {

export type DisplayName = {
name: string;
color: typeof chalk.Color;
color: typeof ForegroundColor;
};

export type InitialOptionsWithRootDir = InitialOptions &
Expand Down

0 comments on commit b235a1b

Please sign in to comment.