Skip to content

Commit

Permalink
[jest-editor-support] update TypeScript definition (#5625)
Browse files Browse the repository at this point in the history
* update TypeScript definition

* fix typo

* add changelog item

* add definitions from within jest-editor-support

* update changelog

* remove semicolons

* fix SnapshotMetadata.node

* remove empty line

* add coverage map
  • Loading branch information
stephtr authored and orta committed Feb 21, 2018
1 parent 4b6f850 commit 1203ed6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## master

### Fixes

* `[jest-editor-support]` Update TypeScript definitions
([#5625](https://github.com/facebook/jest/pull/5625))

### Features

* `[jest-runtime]` Provide `require.main` property set to module with test suite
Expand Down
48 changes: 40 additions & 8 deletions packages/jest-editor-support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import {EventEmitter} from 'events';
import {ChildProcess} from 'child_process';

export interface SpawnOptions {
shell?: boolean;
}

export interface Options {
createProcess?(
workspace: ProjectWorkspace,
args: string[],
debugPort?: number,
options?: SpawnOptions,
): ChildProcess;
debugPort?: number;
testNamePattern?: string;
testFileNamePattern?: string;
shell?: boolean;
}

export class Runner extends EventEmitter {
Expand Down Expand Up @@ -84,19 +88,32 @@ export class TestReconciler {
updateFileWithJestStatus(data: any): TestFileAssertionStatus[];
}

/**
* Did the thing pass, fail or was it not run?
*/
export type TestReconcilationState =
| 'Unknown'
| 'KnownSuccess'
| 'KnownFail'
| 'KnownSkip';
| 'Unknown' // The file has not changed, so the watcher didn't hit it
| 'KnownFail' // Definitely failed
| 'KnownSuccess' // Definitely passed
| 'KnownSkip'; // Definitely skipped

/**
* The Jest Extension's version of a status for
* whether the file passed or not
*
*/
export interface TestFileAssertionStatus {
file: string;
message: string;
status: TestReconcilationState;
assertions: Array<TestAssertionStatus>;
assertions: Array<TestAssertionStatus> | null;
}

/**
* The Jest Extension's version of a status for
* individual assertion fails
*
*/
export interface TestAssertionStatus {
title: string;
status: TestReconcilationState;
Expand Down Expand Up @@ -133,17 +150,32 @@ export interface JestTotalResults {
numPassedTests: number;
numFailedTests: number;
numPendingTests: number;
coverageMap: any;
testResults: Array<JestFileResults>;
}

export interface JestTotalResultsMeta {
noTestsFound: boolean;
}

export enum MessageTypes {
export enum messageTypes {
noTests = 1,
unknown = 0,
watchUsage = 2,
}

export type MessageType = number;

export interface SnapshotMetadata {
exists: boolean;
name: string;
node: {
loc: editor.Node
};
content?: string;
}

export class Snapshot {
constructor(parser: any, customMatchers?: string[]);
getMetadata(filepath: string): SnapshotMetadata[];
}

0 comments on commit 1203ed6

Please sign in to comment.