jest-editor-support
Advanced tools
Comparing version 18.1.0 to 18.5.0-alpha.7da3df39
@@ -54,3 +54,6 @@ /** | ||
const plugins = babel.plugins.concat(['flow']); | ||
const plugins = Array.isArray(babel.plugins) ? | ||
babel.plugins.concat(['flow']) : | ||
['flow']; | ||
const config = { plugins, sourceType: 'module' }; | ||
@@ -76,3 +79,3 @@ const ast = babylon.parse(data, config); | ||
// So take the AST node and create an object for us | ||
// to store for later usage | ||
// to store for later usage | ||
const foundExpectNode = (node, file) => { | ||
@@ -79,0 +82,0 @@ const expect = new Expect(); |
@@ -22,3 +22,3 @@ /** | ||
*/ | ||
module.exports.jestChildProcessWithArgs = ( | ||
module.exports.createProcess = ( | ||
workspace, args) => | ||
@@ -25,0 +25,0 @@ { |
@@ -40,3 +40,3 @@ /** | ||
* Path to a local Jest config file. | ||
* | ||
* | ||
* @type {string} | ||
@@ -67,3 +67,3 @@ */ /** | ||
* any version of Jest. | ||
* | ||
* | ||
* @type {number} | ||
@@ -70,0 +70,0 @@ */ /** |
@@ -13,3 +13,3 @@ /** | ||
require('child_process');const ChildProcess = _require.ChildProcess;var _require2 = | ||
require('child_process');const ChildProcess = _require.ChildProcess,spawn = _require.spawn;var _require2 = | ||
require('fs');const readFile = _require2.readFile;var _require3 = | ||
@@ -19,4 +19,6 @@ require('os');const tmpdir = _require3.tmpdir;var _require4 = | ||
const ProjectWorkspace = require('./ProjectWorkspace');var _require5 = | ||
require('./Process');const jestChildProcessWithArgs = _require5.jestChildProcessWithArgs; | ||
require('./Process');const createProcess = _require5.createProcess; | ||
// This class represents the running process, and | ||
@@ -30,4 +32,9 @@ // passes out events when it understands what data is being | ||
constructor(workspace) { | ||
constructor(workspace, options) { | ||
super(); | ||
this._createProcess = options && options.createProcess || createProcess; | ||
this.workspace = workspace; | ||
@@ -38,2 +45,5 @@ this.outputPath = tmpdir() + '/jest_runner.json'; | ||
start() { | ||
if (this.debugprocess) { | ||
return; | ||
} | ||
// Handle the arg change on v18 | ||
@@ -51,3 +61,3 @@ const belowEighteen = this.workspace.localJestMajorVersion < 18; | ||
this.debugprocess = jestChildProcessWithArgs(this.workspace, args); | ||
this.debugprocess = this._createProcess(this.workspace, args); | ||
this.debugprocess.stdout.on('data', data => { | ||
@@ -60,3 +70,3 @@ // Make jest save to a file, otherwise we get chunked data | ||
if (err) { | ||
const message = `JSON report not found at ${ this.outputPath }`; | ||
const message = `JSON report not found at ${this.outputPath}`; | ||
this.emit('terminalError', message); | ||
@@ -91,3 +101,3 @@ } else { | ||
const args = ['--updateSnapshot']; | ||
const updateProcess = jestChildProcessWithArgs(this.workspace, args); | ||
const updateProcess = this._createProcess(this.workspace, args); | ||
updateProcess.on('close', () => { | ||
@@ -99,3 +109,9 @@ completion(); | ||
closeProcess() { | ||
this.debugprocess.kill(); | ||
if (process.platform === 'win32') { | ||
// Windows doesn't exit the process when it should. | ||
spawn('taskkill', ['/pid', '' + this.debugprocess.pid, '/T', '/F']); | ||
} else { | ||
this.debugprocess.kill(); | ||
} | ||
delete this.debugprocess; | ||
}}; |
@@ -17,3 +17,3 @@ /** | ||
const ProjectWorkspace = require('./ProjectWorkspace');var _require3 = | ||
require('./Process');const jestChildProcessWithArgs = _require3.jestChildProcessWithArgs; | ||
require('./Process');const createProcess = _require3.createProcess; | ||
@@ -35,2 +35,6 @@ // This class represents the the configuration of Jest's process | ||
module.exports = class Settings extends EventEmitter { | ||
@@ -43,8 +47,16 @@ | ||
constructor(workspace) { | ||
constructor(workspace, options) { | ||
super(); | ||
this.workspace = workspace; | ||
this._createProcess = options && options.createProcess || createProcess; | ||
// Defaults for a Jest project | ||
this.settings = { | ||
testMatch: [ | ||
'**/__tests__/**/*.js?(x)', | ||
'**/?(*.)(spec|test).js?(x)'], | ||
testRegex: '(/__tests__/.*|\\.(test|spec))\\.jsx?$' }; | ||
@@ -59,3 +71,3 @@ | ||
const args = ['--debug', folderThatDoesntExist]; | ||
this.debugprocess = jestChildProcessWithArgs(this.workspace, args); | ||
this.debugprocess = this._createProcess(this.workspace, args); | ||
@@ -65,3 +77,3 @@ this.debugprocess.stdout.on('data', data => { | ||
// We can give warnings to versions under 17 now | ||
// See https://github.com/facebook/jest/issues/2343 for moving this into | ||
// See https://github.com/facebook/jest/issues/2343 for moving this into | ||
// the config object | ||
@@ -68,0 +80,0 @@ if (string.includes('jest version =')) { |
@@ -123,3 +123,3 @@ /** | ||
const restOfTrace = message.split(filename, 2)[1]; | ||
return parseInt(restOfTrace.split(':')[1], 10); | ||
return restOfTrace ? parseInt(restOfTrace.split(':')[1], 10) : null; | ||
} | ||
@@ -126,0 +126,0 @@ |
186
index.d.ts
@@ -9,112 +9,110 @@ /** | ||
declare module 'jest-editor-support' { | ||
import { EventEmitter } from 'events'; | ||
import {EventEmitter} from 'events'; | ||
export class Runner extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace); | ||
start(): void; | ||
closeProcess(): void; | ||
runJestWithUpdateForSnapshots(completion: any): void; | ||
} | ||
export class Runner extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace); | ||
start(): void; | ||
closeProcess(): void; | ||
runJestWithUpdateForSnapshots(completion: any): void; | ||
} | ||
export class Settings extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace); | ||
getConfig(completed: Function): void; | ||
jestVersionMajor: number | null; | ||
settings: { | ||
testRegex: string; | ||
}; | ||
} | ||
export class Settings extends EventEmitter { | ||
constructor(workspace: ProjectWorkspace); | ||
getConfig(completed: Function): void; | ||
jestVersionMajor: number | null; | ||
settings: { | ||
testRegex: string; | ||
}; | ||
} | ||
export class ProjectWorkspace { | ||
constructor( | ||
rootPath: string, | ||
pathToJest: string, | ||
pathToConfig: string, | ||
localJestMajorVersin: number | ||
); | ||
pathToJest: string; | ||
rootPath: string; | ||
localJestMajorVersion: number; | ||
} | ||
export class ProjectWorkspace { | ||
constructor( | ||
rootPath: string, | ||
pathToJest: string, | ||
pathToConfig: string, | ||
localJestMajorVersin: number | ||
); | ||
pathToJest: string; | ||
rootPath: string; | ||
localJestMajorVersion: number; | ||
} | ||
export interface IParseResults { | ||
expects: Expect[]; | ||
itBlocks: ItBlock[]; | ||
} | ||
export interface IParseResults { | ||
expects: Expect[]; | ||
itBlocks: ItBlock[]; | ||
} | ||
export function parse(file: string): IParseResults; | ||
export function parse(file: string): IParseResults; | ||
type Location = { | ||
column: number, | ||
line: number, | ||
}; | ||
export interface Location { | ||
column: number; | ||
line: number; | ||
} | ||
class Node { | ||
start: Location; | ||
end: Location; | ||
file: string; | ||
} | ||
export class Node { | ||
start: Location; | ||
end: Location; | ||
file: string; | ||
} | ||
export class ItBlock extends Node { | ||
name: string; | ||
} | ||
export class ItBlock extends Node { | ||
name: string; | ||
} | ||
export type Expect = Node; | ||
export class Expect extends Node {} | ||
export class TestReconciler { | ||
stateForTestFile(file: string): TestReconcilationState; | ||
stateForTestAssertion(file: string, name: string): TestFileAssertionStatus | null; | ||
failedStatuses(): Array<TestFileAssertionStatus>; | ||
updateFileWithJestStatus(data): void; | ||
} | ||
export class TestReconciler { | ||
stateForTestFile(file: string): TestReconcilationState; | ||
stateForTestAssertion(file: string, name: string): TestFileAssertionStatus | null; | ||
failedStatuses(): Array<TestFileAssertionStatus>; | ||
updateFileWithJestStatus(data): void; | ||
} | ||
type TestReconcilationState = "Unknown" | | ||
"KnownSuccess" | | ||
"KnownFail"; | ||
export type TestReconcilationState = "Unknown" | | ||
"KnownSuccess" | | ||
"KnownFail"; | ||
export type TestFileAssertionStatus = { | ||
file: string, | ||
message: string, | ||
status: TestReconcilationState, | ||
assertions: Array<TestAssertionStatus>, | ||
} | ||
export interface TestFileAssertionStatus { | ||
file: string; | ||
message: string; | ||
status: TestReconcilationState; | ||
assertions: Array<TestAssertionStatus>; | ||
} | ||
export type TestAssertionStatus = { | ||
title: string, | ||
status: TestReconcilationState, | ||
message: string, | ||
shortMessage?: string, | ||
terseMessage?: string, | ||
line?: number, | ||
} | ||
export interface TestAssertionStatus { | ||
title: string; | ||
status: TestReconcilationState; | ||
message: string; | ||
shortMessage?: string; | ||
terseMessage?: string; | ||
line?: number; | ||
} | ||
export type JestFileResults = { | ||
name: string, | ||
summary: string, | ||
message: string, | ||
status: "failed" | "passed", | ||
startTime: number, | ||
endTime: number, | ||
assertionResults: Array<JestAssertionResults>, | ||
} | ||
export interface JestFileResults { | ||
name: string; | ||
summary: string; | ||
message: string; | ||
status: "failed" | "passed"; | ||
startTime: number; | ||
endTime: number; | ||
assertionResults: Array<JestAssertionResults>; | ||
} | ||
export type JestAssertionResults = { | ||
name: string, | ||
title: string, | ||
status: "failed" | "passed", | ||
failureMessages: string[], | ||
} | ||
export interface JestAssertionResults { | ||
name: string; | ||
title: string; | ||
status: "failed" | "passed"; | ||
failureMessages: string[]; | ||
} | ||
export type JestTotalResults = { | ||
success: boolean, | ||
startTime: number, | ||
numTotalTests: number, | ||
numTotalTestSuites: number, | ||
numRuntimeErrorTestSuites: number, | ||
numPassedTests: number, | ||
numFailedTests: number, | ||
numPendingTests: number, | ||
testResults: Array<JestFileResults>, | ||
} | ||
export interface JestTotalResults { | ||
success: boolean; | ||
startTime: number; | ||
numTotalTests: number; | ||
numTotalTestSuites: number; | ||
numRuntimeErrorTestSuites: number; | ||
numPassedTests: number; | ||
numFailedTests: number; | ||
numPendingTests: number; | ||
testResults: Array<JestFileResults>; | ||
} |
{ | ||
"name": "jest-editor-support", | ||
"version": "18.1.0", | ||
"version": "18.5.0-alpha.7da3df39", | ||
"repository": { | ||
@@ -10,6 +10,3 @@ "type": "git", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"test": "../../packages/jest-cli/bin/jest.js" | ||
}, | ||
"optionalDependencies": { | ||
"peerDependencies": { | ||
"typescript": "^2.0.10" | ||
@@ -16,0 +13,0 @@ }, |
# jest-editor-support | ||
The engine that allows editors to build on top of Jest. | ||
The engine that allows editors to build on top of Jest. | ||
@@ -10,1 +10,5 @@ ## Usage | ||
For now as an end user, I'd recommend looking at Orta's [vscode-jest](https://github.com/orta/vscode-jest/). | ||
## Note | ||
Since version `18.2.0` TypeScript is now a peer dependency. | ||
If you don't need to handle `.tsx` files then you can safely ignore the warning during installation. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28278
772
14
2