-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-editor-support: Add support for Windows Subsystem for Linux in Runner #6941
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,196 +1,199 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {EventEmitter} from 'events'; | ||
import {ChildProcess} from 'child_process'; | ||
|
||
export interface SpawnOptions { | ||
shell?: boolean; | ||
} | ||
|
||
export interface Options { | ||
createProcess?( | ||
workspace: ProjectWorkspace, | ||
args: string[], | ||
options?: SpawnOptions, | ||
): ChildProcess; | ||
noColor?: boolean; | ||
testNamePattern?: string; | ||
testFileNamePattern?: string; | ||
shell?: boolean; | ||
} | ||
|
||
export class Runner extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace, options?: Options); | ||
watchMode: boolean; | ||
watchAll: boolean; | ||
start(watchMode?: boolean, watchAll?: boolean): void; | ||
closeProcess(): void; | ||
runJestWithUpdateForSnapshots(completion: any): void; | ||
} | ||
|
||
export class Settings extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace, options?: Options); | ||
getConfig(completed: Function): void; | ||
jestVersionMajor: number | null; | ||
settings: { | ||
testRegex: string, | ||
testMatch: string[], | ||
}; | ||
} | ||
|
||
export class ProjectWorkspace { | ||
constructor( | ||
rootPath: string, | ||
pathToJest: string, | ||
pathToConfig: string, | ||
localJestMajorVersin: number, | ||
collectCoverage?: boolean, | ||
debug?: boolean, | ||
); | ||
pathToJest: string; | ||
pathToConfig: string; | ||
rootPath: string; | ||
localJestMajorVersion: number; | ||
collectCoverage?: boolean; | ||
debug?: boolean; | ||
} | ||
|
||
export interface IParseResults { | ||
expects: Expect[]; | ||
itBlocks: ItBlock[]; | ||
} | ||
|
||
export function parse(file: string): IParseResults; | ||
|
||
export interface Location { | ||
column: number; | ||
line: number; | ||
} | ||
|
||
export class Node { | ||
start: Location; | ||
end: Location; | ||
file: string; | ||
} | ||
|
||
export class ItBlock extends Node { | ||
name: string; | ||
} | ||
|
||
export class Expect extends Node {} | ||
|
||
export class TestReconciler { | ||
stateForTestFile(file: string): TestReconcilationState; | ||
assertionsForTestFile(file: string): TestAssertionStatus[] | null; | ||
stateForTestAssertion( | ||
file: string, | ||
name: string, | ||
): TestFileAssertionStatus | null; | ||
updateFileWithJestStatus(data: any): TestFileAssertionStatus[]; | ||
} | ||
|
||
/** | ||
* Did the thing pass, fail or was it not run? | ||
*/ | ||
export type TestReconcilationState = | ||
| '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> | null; | ||
} | ||
|
||
/** | ||
* The Jest Extension's version of a status for | ||
* individual assertion fails | ||
* | ||
*/ | ||
export interface TestAssertionStatus { | ||
title: string; | ||
status: TestReconcilationState; | ||
message: string; | ||
shortMessage?: string; | ||
terseMessage?: string; | ||
line?: number; | ||
} | ||
|
||
export interface JestFileResults { | ||
name: string; | ||
summary: string; | ||
message: string; | ||
status: 'failed' | 'passed'; | ||
startTime: number; | ||
endTime: number; | ||
assertionResults: Array<JestAssertionResults>; | ||
} | ||
|
||
export interface JestAssertionResults { | ||
name: string; | ||
title: string; | ||
status: 'failed' | 'passed'; | ||
failureMessages: string[]; | ||
fullName: string; | ||
} | ||
|
||
export interface JestTotalResults { | ||
success: boolean; | ||
startTime: number; | ||
numTotalTests: number; | ||
numTotalTestSuites: number; | ||
numRuntimeErrorTestSuites: number; | ||
numPassedTests: number; | ||
numFailedTests: number; | ||
numPendingTests: number; | ||
coverageMap: any; | ||
testResults: Array<JestFileResults>; | ||
} | ||
|
||
export interface JestTotalResultsMeta { | ||
noTestsFound: boolean; | ||
} | ||
|
||
export enum messageTypes { | ||
noTests = 1, | ||
testResults = 3, | ||
unknown = 0, | ||
watchUsage = 2, | ||
} | ||
|
||
export type MessageType = number; | ||
|
||
export interface SnapshotMetadata { | ||
exists: boolean; | ||
name: string; | ||
node: { | ||
loc: Node; | ||
}; | ||
content?: string; | ||
} | ||
|
||
export class Snapshot { | ||
constructor(parser?: any, customMatchers?: string[]); | ||
getMetadata(filepath: string): SnapshotMetadata[]; | ||
} | ||
|
||
type FormattedTestResults = { | ||
testResults: TestResult[] | ||
} | ||
|
||
type TestResult = { | ||
name: string | ||
} | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {EventEmitter} from 'events'; | ||
import {ChildProcess} from 'child_process'; | ||
|
||
export interface SpawnOptions { | ||
shell?: boolean; | ||
} | ||
|
||
export interface Options { | ||
createProcess?( | ||
workspace: ProjectWorkspace, | ||
args: string[], | ||
options?: SpawnOptions, | ||
): ChildProcess; | ||
noColor?: boolean; | ||
testNamePattern?: string; | ||
testFileNamePattern?: string; | ||
shell?: boolean; | ||
useWsl?: boolean; | ||
} | ||
|
||
export class Runner extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace, options?: Options); | ||
watchMode: boolean; | ||
watchAll: boolean; | ||
start(watchMode?: boolean, watchAll?: boolean): void; | ||
closeProcess(): void; | ||
runJestWithUpdateForSnapshots(completion: any): void; | ||
} | ||
|
||
export class Settings extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace, options?: Options); | ||
getConfig(completed: Function): void; | ||
jestVersionMajor: number | null; | ||
settings: { | ||
testRegex: string; | ||
testMatch: string[]; | ||
}; | ||
} | ||
|
||
export class ProjectWorkspace { | ||
constructor( | ||
rootPath: string, | ||
pathToJest: string, | ||
pathToConfig: string, | ||
localJestMajorVersin: number, | ||
collectCoverage?: boolean, | ||
debug?: boolean, | ||
useWsl?: boolean | string, | ||
); | ||
pathToJest: string; | ||
pathToConfig: string; | ||
rootPath: string; | ||
localJestMajorVersion: number; | ||
collectCoverage?: boolean; | ||
debug?: boolean; | ||
useWsl?: boolean | string; | ||
} | ||
|
||
export interface IParseResults { | ||
expects: Expect[]; | ||
itBlocks: ItBlock[]; | ||
} | ||
|
||
export function parse(file: string): IParseResults; | ||
|
||
export interface Location { | ||
column: number; | ||
line: number; | ||
} | ||
|
||
export class Node { | ||
start: Location; | ||
end: Location; | ||
file: string; | ||
} | ||
|
||
export class ItBlock extends Node { | ||
name: string; | ||
} | ||
|
||
export class Expect extends Node {} | ||
|
||
export class TestReconciler { | ||
stateForTestFile(file: string): TestReconcilationState; | ||
assertionsForTestFile(file: string): TestAssertionStatus[] | null; | ||
stateForTestAssertion( | ||
file: string, | ||
name: string, | ||
): TestFileAssertionStatus | null; | ||
updateFileWithJestStatus(data: any): TestFileAssertionStatus[]; | ||
} | ||
|
||
/** | ||
* Did the thing pass, fail or was it not run? | ||
*/ | ||
export type TestReconcilationState = | ||
| '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> | null; | ||
} | ||
|
||
/** | ||
* The Jest Extension's version of a status for | ||
* individual assertion fails | ||
* | ||
*/ | ||
export interface TestAssertionStatus { | ||
title: string; | ||
status: TestReconcilationState; | ||
message: string; | ||
shortMessage?: string; | ||
terseMessage?: string; | ||
line?: number; | ||
} | ||
|
||
export interface JestFileResults { | ||
name: string; | ||
summary: string; | ||
message: string; | ||
status: 'failed' | 'passed'; | ||
startTime: number; | ||
endTime: number; | ||
assertionResults: Array<JestAssertionResults>; | ||
} | ||
|
||
export interface JestAssertionResults { | ||
name: string; | ||
title: string; | ||
status: 'failed' | 'passed'; | ||
failureMessages: string[]; | ||
fullName: string; | ||
} | ||
|
||
export interface JestTotalResults { | ||
success: boolean; | ||
startTime: number; | ||
numTotalTests: number; | ||
numTotalTestSuites: number; | ||
numRuntimeErrorTestSuites: number; | ||
numPassedTests: number; | ||
numFailedTests: number; | ||
numPendingTests: number; | ||
coverageMap: any; | ||
testResults: Array<JestFileResults>; | ||
} | ||
|
||
export interface JestTotalResultsMeta { | ||
noTestsFound: boolean; | ||
} | ||
|
||
export enum messageTypes { | ||
noTests = 1, | ||
testResults = 3, | ||
unknown = 0, | ||
watchUsage = 2, | ||
} | ||
|
||
export type MessageType = number; | ||
|
||
export interface SnapshotMetadata { | ||
exists: boolean; | ||
name: string; | ||
node: { | ||
loc: Node; | ||
}; | ||
content?: string; | ||
} | ||
|
||
export class Snapshot { | ||
constructor(parser?: any, customMatchers?: string[]); | ||
getMetadata(filepath: string): SnapshotMetadata[]; | ||
} | ||
|
||
type FormattedTestResults = { | ||
testResults: TestResult[]; | ||
}; | ||
|
||
type TestResult = { | ||
name: string; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's up? lf vs crlf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange - in my local dev environment it's LF (and I disabled autoCLRF), I'll verify that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the master this file is CLRF while all other files are LF - is that intended?
if so, I switch back to CLRF for this file only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite sure that this wasn't intended, but it's probably better to change line endings in a separate PR.