jest-editor-support
Advanced tools
Comparing version 22.4.0 to 22.4.1
@@ -1,26 +0,70 @@ | ||
'use strict';var _Process; | ||
'use strict'; | ||
var _Process; | ||
function _load_Process() { | ||
return _Process = _interopRequireWildcard(require('./Process')); | ||
} | ||
var _project_workspace; | ||
function _load_project_workspace() { | ||
return _project_workspace = _interopRequireDefault(require('./project_workspace')); | ||
} | ||
var _Runner; | ||
function _load_Runner() { | ||
return _Runner = _interopRequireDefault(require('./Runner')); | ||
} | ||
var _Settings; | ||
function _load_Process() {return _Process = _interopRequireWildcard(require('./Process'));}var _project_workspace; | ||
function _load_Settings() { | ||
return _Settings = _interopRequireDefault(require('./Settings')); | ||
} | ||
function _load_project_workspace() {return _project_workspace = _interopRequireDefault(require('./project_workspace'));}var _Runner; | ||
function _load_Runner() {return _Runner = _interopRequireDefault(require('./Runner'));}var _Settings; | ||
function _load_Settings() {return _Settings = _interopRequireDefault(require('./Settings'));}var _Snapshot; | ||
function _load_Snapshot() {return _Snapshot = _interopRequireDefault(require('./Snapshot'));}var _parser_nodes; | ||
function _load_parser_nodes() {return _parser_nodes = require('./parsers/parser_nodes');}var _babylon_parser; | ||
function _load_babylon_parser() {return _babylon_parser = require('./parsers/babylon_parser');}var _test_reconciler; | ||
function _load_test_reconciler() {return _test_reconciler = _interopRequireDefault(require('./test_reconciler'));}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _interopRequireWildcard(obj) {if (obj && obj.__esModule) {return obj;} else {var newObj = {};if (obj != null) {for (var key in obj) {if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];}}newObj.default = obj;return newObj;}} /** | ||
* 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. | ||
* | ||
* | ||
*/module.exports = { Expect: (_parser_nodes || _load_parser_nodes()).Expect, ItBlock: (_parser_nodes || _load_parser_nodes()).ItBlock, Node: (_parser_nodes || _load_parser_nodes()).Node, Process: _Process || _load_Process(), ProjectWorkspace: (_project_workspace || _load_project_workspace()).default, | ||
var _Snapshot; | ||
function _load_Snapshot() { | ||
return _Snapshot = _interopRequireDefault(require('./Snapshot')); | ||
} | ||
var _parser_nodes; | ||
function _load_parser_nodes() { | ||
return _parser_nodes = require('./parsers/parser_nodes'); | ||
} | ||
var _babylon_parser; | ||
function _load_babylon_parser() { | ||
return _babylon_parser = require('./parsers/babylon_parser'); | ||
} | ||
var _test_reconciler; | ||
function _load_test_reconciler() { | ||
return _test_reconciler = _interopRequireDefault(require('./test_reconciler')); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
/** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
module.exports = { | ||
Expect: (_parser_nodes || _load_parser_nodes()).Expect, | ||
ItBlock: (_parser_nodes || _load_parser_nodes()).ItBlock, | ||
Node: (_parser_nodes || _load_parser_nodes()).Node, | ||
Process: _Process || _load_Process(), | ||
ProjectWorkspace: (_project_workspace || _load_project_workspace()).default, | ||
Runner: (_Runner || _load_Runner()).default, | ||
@@ -30,2 +74,3 @@ Settings: (_Settings || _load_Settings()).default, | ||
TestReconciler: (_test_reconciler || _load_test_reconciler()).default, | ||
parse: (_babylon_parser || _load_babylon_parser()).parse }; | ||
parse: (_babylon_parser || _load_babylon_parser()).parse | ||
}; |
@@ -1,21 +0,26 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.parse = exports.getASTfor = undefined;var _fs; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.parse = exports.getASTfor = undefined; | ||
var _fs; | ||
function _load_fs() { | ||
return _fs = require('fs'); | ||
} | ||
var _babylon; | ||
function _load_babylon() { | ||
return _babylon = require('babylon'); | ||
} | ||
var _parser_nodes; | ||
function _load_parser_nodes() { | ||
return _parser_nodes = require('./parser_nodes'); | ||
} | ||
function _load_fs() {return _fs = require('fs');}var _babylon; | ||
function _load_babylon() {return _babylon = require('babylon');}var _parser_nodes; | ||
function _load_parser_nodes() {return _parser_nodes = require('./parser_nodes');} | ||
const getASTfor = exports.getASTfor = file => { | ||
@@ -32,3 +37,10 @@ const data = (0, (_fs || _load_fs()).readFileSync)(file).toString(); | ||
* | ||
*/const parse = exports.parse = file => {const itBlocks = [];const expects = [];const ast = getASTfor(file); | ||
*/ | ||
const parse = exports.parse = file => { | ||
const itBlocks = []; | ||
const expects = []; | ||
const ast = getASTfor(file); | ||
// An `it`/`test` was found in the AST | ||
@@ -65,14 +77,7 @@ // So take the AST node and create an object for us | ||
const isFunctionCall = node => { | ||
return ( | ||
node.type === 'ExpressionStatement' && | ||
node.expression && | ||
node.expression.type === 'CallExpression'); | ||
return node.type === 'ExpressionStatement' && node.expression && node.expression.type === 'CallExpression'; | ||
}; | ||
const isFunctionDeclaration = nodeType => { | ||
return ( | ||
nodeType === 'ArrowFunctionExpression' || | ||
nodeType === 'FunctionExpression'); | ||
return nodeType === 'ArrowFunctionExpression' || nodeType === 'FunctionExpression'; | ||
}; | ||
@@ -86,13 +91,4 @@ | ||
} | ||
let name = | ||
node && node.expression && node.expression.callee ? | ||
node.expression.callee.name : | ||
undefined; | ||
if ( | ||
!name && | ||
node && | ||
node.expression && | ||
node.expression.callee && | ||
node.expression.callee.object) | ||
{ | ||
let name = node && node.expression && node.expression.callee ? node.expression.callee.name : undefined; | ||
if (!name && node && node.expression && node.expression.callee && node.expression.callee.object) { | ||
name = node.expression.callee.object.name; | ||
@@ -143,30 +139,11 @@ } | ||
} else if (element && element.type === 'VariableDeclaration') { | ||
element.declarations. | ||
filter( | ||
declaration => | ||
declaration.init && isFunctionDeclaration(declaration.init.type)). | ||
forEach(declaration => searchNodes(declaration.init.body, file)); | ||
} else if ( | ||
element && | ||
element.type === 'ExpressionStatement' && | ||
element.expression && | ||
element.expression.type === 'AssignmentExpression' && | ||
element.expression.right && | ||
isFunctionDeclaration(element.expression.right.type)) | ||
{ | ||
element.declarations.filter(declaration => declaration.init && isFunctionDeclaration(declaration.init.type)).forEach(declaration => searchNodes(declaration.init.body, file)); | ||
} else if (element && element.type === 'ExpressionStatement' && element.expression && element.expression.type === 'AssignmentExpression' && element.expression.right && isFunctionDeclaration(element.expression.right.type)) { | ||
searchNodes(element.expression.right.body, file); | ||
} else if ( | ||
element.type === 'ReturnStatement' && | ||
element.argument.arguments) | ||
{ | ||
element.argument.arguments. | ||
filter(argument => isFunctionDeclaration(argument.type)). | ||
forEach(argument => searchNodes(argument.body, file)); | ||
} else if (element.type === 'ReturnStatement' && element.argument.arguments) { | ||
element.argument.arguments.filter(argument => isFunctionDeclaration(argument.type)).forEach(argument => searchNodes(argument.body, file)); | ||
} | ||
if (isFunctionCall(element)) { | ||
element.expression.arguments. | ||
filter(argument => isFunctionDeclaration(argument.type)). | ||
forEach(argument => searchNodes(argument.body, file)); | ||
element.expression.arguments.filter(argument => isFunctionDeclaration(argument.type)).forEach(argument => searchNodes(argument.body, file)); | ||
} | ||
@@ -180,4 +157,4 @@ } | ||
expects, | ||
itBlocks }; | ||
itBlocks | ||
}; | ||
}; |
@@ -1,20 +0,21 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
class Node {} | ||
exports.Node = Node; /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
class Expect extends Node {} | ||
class Node {}exports.Node = Node; /** | ||
* 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. | ||
* | ||
* | ||
*/class Expect extends Node {}exports.Expect = Expect; | ||
class ItBlock extends Node {}exports.ItBlock = ItBlock; | ||
exports.Expect = Expect; | ||
class ItBlock extends Node {} | ||
exports.ItBlock = ItBlock; |
@@ -1,30 +0,45 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.createProcess = undefined;var _child_process; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createProcess = undefined; | ||
var _child_process; | ||
function _load_child_process() { | ||
return _child_process = require('child_process'); | ||
} | ||
var _project_workspace; | ||
function _load_project_workspace() { | ||
return _project_workspace = _interopRequireDefault(require('./project_workspace')); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Spawns and returns a Jest process with specific args | ||
* | ||
* @param {string[]} args | ||
* @returns {ChildProcess} | ||
*/ | ||
/** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
function _load_child_process() {return _child_process = require('child_process');}var _project_workspace; | ||
function _load_project_workspace() {return _project_workspace = _interopRequireDefault(require('./project_workspace'));}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
const createProcess = exports.createProcess = function (workspace, args) { | ||
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
/** | ||
* Spawns and returns a Jest process with specific args | ||
* | ||
* @param {string[]} args | ||
* @returns {ChildProcess} | ||
*/ /** | ||
* 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. | ||
* | ||
* | ||
*/const createProcess = exports.createProcess = function (workspace, args) {let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; // A command could look like `npm run test`, which we cannot use as a command | ||
// A command could look like `npm run test`, which we cannot use as a command | ||
// as they can only be the first command, so take out the command, and add | ||
// any other bits into the args | ||
const runtimeExecutable = workspace.pathToJest;const parameters = runtimeExecutable.split(' '); | ||
const runtimeExecutable = workspace.pathToJest; | ||
const parameters = runtimeExecutable.split(' '); | ||
const command = parameters[0]; | ||
@@ -48,5 +63,5 @@ const initialArgs = parameters.slice(1); | ||
env, | ||
shell: options.shell }; | ||
shell: options.shell | ||
}; | ||
return (0, (_child_process || _load_child_process()).spawn)(command, runtimeArgs, spawnOptions); | ||
}; |
@@ -1,55 +0,32 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", { value: true }); /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* Represents the project that the extension is running on and it's state | ||
*/ | ||
* 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. | ||
* | ||
* | ||
*/ | ||
/** | ||
* Represents the project that the extension is running on and it's state | ||
*/ | ||
class ProjectWorkspace { | ||
/** | ||
* Path to a local Jest config file. | ||
* | ||
* @type {string} | ||
*/ | ||
/** | ||
* Path to a local Jest config file. | ||
* | ||
* @type {string} | ||
*/ /** | ||
* The path to the root of the project's workspace | ||
* | ||
* @type {string} | ||
*/ | ||
constructor( | ||
rootPath, | ||
pathToJest, | ||
pathToConfig, | ||
localJestMajorVersion) | ||
{ | ||
* The path to the root of the project's workspace | ||
* | ||
* @type {string} | ||
*/ | ||
constructor(rootPath, pathToJest, pathToConfig, localJestMajorVersion) { | ||
this.rootPath = rootPath; | ||
@@ -59,17 +36,24 @@ this.pathToJest = pathToJest; | ||
this.localJestMajorVersion = localJestMajorVersion; | ||
} /** | ||
* local Jest major release version, as the runner could run against | ||
* any version of Jest. | ||
* | ||
* @type {number} | ||
*/ /** | ||
* The path to Jest, this is normally a file path like | ||
* `node_modules/.bin/jest` but you should not make the assumption that | ||
* it is always a direct file path, as in a create-react app it would look | ||
* like `npm test --`. | ||
* | ||
* This means when launching a process, you will need to split on the first | ||
* space, and then move any other args into the args of the process. | ||
* | ||
* @type {string} | ||
*/}exports.default = ProjectWorkspace; | ||
} | ||
/** | ||
* local Jest major release version, as the runner could run against | ||
* any version of Jest. | ||
* | ||
* @type {number} | ||
*/ | ||
/** | ||
* The path to Jest, this is normally a file path like | ||
* `node_modules/.bin/jest` but you should not make the assumption that | ||
* it is always a direct file path, as in a create-react app it would look | ||
* like `npm test --`. | ||
* | ||
* This means when launching a process, you will need to split on the first | ||
* space, and then move any other args into the args of the process. | ||
* | ||
* @type {string} | ||
*/ | ||
} | ||
exports.default = ProjectWorkspace; |
@@ -1,37 +0,65 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _types; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _types; | ||
function _load_types() { | ||
return _types = require('./types'); | ||
} | ||
var _child_process; | ||
function _load_child_process() { | ||
return _child_process = require('child_process'); | ||
} | ||
var _fs; | ||
function _load_fs() { | ||
return _fs = require('fs'); | ||
} | ||
var _os; | ||
function _load_types() {return _types = require('./types');}var _child_process; | ||
function _load_os() { | ||
return _os = require('os'); | ||
} | ||
function _load_child_process() {return _child_process = require('child_process');}var _fs; | ||
function _load_fs() {return _fs = require('fs');}var _os; | ||
function _load_os() {return _os = require('os');}var _events; | ||
function _load_events() {return _events = _interopRequireDefault(require('events'));}var _project_workspace; | ||
function _load_project_workspace() {return _project_workspace = _interopRequireDefault(require('./project_workspace'));}var _Process; | ||
function _load_Process() {return _Process = require('./Process');}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _toConsumableArray(arr) {if (Array.isArray(arr)) {for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];return arr2;} else {return Array.from(arr);}} /** | ||
* 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. | ||
* | ||
* | ||
*/ // This class represents the running process, and | ||
// passes out events when it understands what data is being | ||
// pass sent out of the process | ||
class Runner extends (_events || _load_events()).default { | ||
var _events; | ||
function _load_events() { | ||
return _events = _interopRequireDefault(require('events')); | ||
} | ||
var _project_workspace; | ||
function _load_project_workspace() { | ||
return _project_workspace = _interopRequireDefault(require('./project_workspace')); | ||
} | ||
var _Process; | ||
function _load_Process() { | ||
return _Process = require('./Process'); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
// This class represents the running process, and | ||
// passes out events when it understands what data is being | ||
// pass sent out of the process | ||
class Runner extends (_events || _load_events()).default { | ||
constructor(workspace, options) { | ||
@@ -47,3 +75,6 @@ super(); | ||
start() {let watchMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;let watchAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
start() { | ||
let watchMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; | ||
let watchAll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (this.debugprocess) { | ||
@@ -72,5 +103,5 @@ return; | ||
const options = { | ||
shell: this.options.shell }; | ||
shell: this.options.shell | ||
}; | ||
this.debugprocess = this._createProcess(this.workspace, args, options); | ||
@@ -80,6 +111,3 @@ this.debugprocess.stdout.on('data', data => { | ||
// and it can be hard to put it back together. | ||
const stringValue = data. | ||
toString(). | ||
replace(/\n$/, ''). | ||
trim(); | ||
const stringValue = data.toString().replace(/\n$/, '').trim(); | ||
@@ -133,7 +161,3 @@ if (stringValue.startsWith('Test results written to')) { | ||
const options = { shell: this.options.shell }; | ||
const updateProcess = this._createProcess( | ||
this.workspace, [].concat( | ||
defaultArgs, _toConsumableArray(args ? args : [])), | ||
options); | ||
const updateProcess = this._createProcess(this.workspace, [].concat(defaultArgs, _toConsumableArray(args ? args : [])), options); | ||
updateProcess.on('close', () => { | ||
@@ -176,9 +200,8 @@ completion(); | ||
if (this.prevMessageTypes.length === 2) { | ||
return ( | ||
this.prevMessageTypes[0] === (_types || _load_types()).messageTypes.noTests && | ||
this.prevMessageTypes[1] === (_types || _load_types()).messageTypes.watchUsage); | ||
return this.prevMessageTypes[0] === (_types || _load_types()).messageTypes.noTests && this.prevMessageTypes[1] === (_types || _load_types()).messageTypes.watchUsage; | ||
} | ||
return false; | ||
}}exports.default = Runner; | ||
} | ||
} | ||
exports.default = Runner; |
@@ -1,16 +0,32 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _child_process; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _child_process; | ||
function _load_child_process() { | ||
return _child_process = require('child_process'); | ||
} | ||
var _events; | ||
function _load_events() { | ||
return _events = _interopRequireDefault(require('events')); | ||
} | ||
var _project_workspace; | ||
function _load_project_workspace() { | ||
return _project_workspace = _interopRequireDefault(require('./project_workspace')); | ||
} | ||
var _Process; | ||
function _load_Process() { | ||
return _Process = require('./Process'); | ||
} | ||
function _load_child_process() {return _child_process = require('child_process');}var _events; | ||
function _load_events() {return _events = _interopRequireDefault(require('events'));}var _project_workspace; | ||
function _load_project_workspace() {return _project_workspace = _interopRequireDefault(require('./project_workspace'));}var _Process; | ||
function _load_Process() {return _Process = require('./Process');}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,22 +44,4 @@ // This class represents the the configuration of Jest's process | ||
class Settings extends (_events || _load_events()).default { | ||
constructor(workspace, options) { | ||
@@ -57,5 +55,5 @@ super(); | ||
testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)(spec|test).js?(x)'], | ||
testRegex: '(/__tests__/.*|\\.(test|spec))\\.jsx?$' }; | ||
testRegex: '(/__tests__/.*|\\.(test|spec))\\.jsx?$' | ||
}; | ||
this.configs = [this.settings]; | ||
@@ -65,11 +63,8 @@ } | ||
getConfigs(completed) { | ||
this.getConfigProcess = this._createProcess(this.workspace, [ | ||
'--showConfig']); | ||
this.getConfigProcess = this._createProcess(this.workspace, ['--showConfig']); | ||
this.getConfigProcess.stdout.on('data', data => { | ||
const settings = JSON.parse(data.toString()); | ||
this.jestVersionMajor = parseInt(settings.version.split('.').shift(), 10); | ||
this.configs = | ||
this.jestVersionMajor >= 21 ? settings.configs : [settings.config]; | ||
this.configs = this.jestVersionMajor >= 21 ? settings.configs : [settings.config]; | ||
}); | ||
@@ -84,3 +79,5 @@ | ||
getConfig(completed) {let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
getConfig(completed) { | ||
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
this.getConfigs(() => { | ||
@@ -90,9 +87,11 @@ this.settings = this.configs[index]; | ||
}); | ||
}}exports.default = Settings; /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
} | ||
} | ||
exports.default = Settings; /** | ||
* 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. | ||
* | ||
* | ||
*/ |
@@ -11,66 +11,55 @@ /** | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _babelTraverse; | ||
'use strict'; | ||
function _load_babelTraverse() {return _babelTraverse = _interopRequireDefault(require('babel-traverse'));}var _babylon_parser; | ||
function _load_babylon_parser() {return _babylon_parser = require('./parsers/babylon_parser');}var _jestSnapshot; | ||
function _load_jestSnapshot() {return _jestSnapshot = require('jest-snapshot');}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _babelTraverse; | ||
function _load_babelTraverse() { | ||
return _babelTraverse = _interopRequireDefault(require('babel-traverse')); | ||
} | ||
var _babylon_parser; | ||
function _load_babylon_parser() { | ||
return _babylon_parser = require('./parsers/babylon_parser'); | ||
} | ||
var _jestSnapshot; | ||
function _load_jestSnapshot() { | ||
return _jestSnapshot = require('jest-snapshot'); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const describeVariants = Object.assign( | ||
Object.create(null), | ||
{ | ||
const describeVariants = Object.assign(Object.create(null), { | ||
describe: true, | ||
fdescribe: true, | ||
xdescribe: true }); | ||
const base = Object.assign( | ||
Object.create(null), | ||
{ | ||
xdescribe: true | ||
}); | ||
const base = Object.assign(Object.create(null), { | ||
describe: true, | ||
it: true, | ||
test: true }); | ||
const decorators = Object.assign( | ||
Object.create(null), | ||
{ | ||
test: true | ||
}); | ||
const decorators = Object.assign(Object.create(null), { | ||
only: true, | ||
skip: true }); | ||
skip: true | ||
}); | ||
const validParents = Object.assign( | ||
Object.create(null), | ||
base, | ||
describeVariants, | ||
Object.assign(Object.create(null), { | ||
const validParents = Object.assign(Object.create(null), base, describeVariants, Object.assign(Object.create(null), { | ||
fit: true, | ||
xit: true, | ||
xtest: true })); | ||
xtest: true | ||
})); | ||
const isValidMemberExpression = node => node.object && base[node.object.name] && node.property && decorators[node.property.name]; | ||
const isDescribe = node => describeVariants[node.name] || isValidMemberExpression(node) && node.object.name === 'describe'; | ||
const isValidMemberExpression = node => | ||
node.object && | ||
base[node.object.name] && | ||
node.property && | ||
decorators[node.property.name]; | ||
const isValidParent = parent => parent.callee && (validParents[parent.callee.name] || isValidMemberExpression(parent.callee)); | ||
const isDescribe = node => | ||
describeVariants[node.name] || | ||
isValidMemberExpression(node) && node.object.name === 'describe'; | ||
const isValidParent = parent => | ||
parent.callee && ( | ||
validParents[parent.callee.name] || isValidMemberExpression(parent.callee)); | ||
const getArrayOfParents = path => { | ||
@@ -86,7 +75,3 @@ const result = []; | ||
const buildName = | ||
(snapshotNode, parents, position) => { | ||
const buildName = (snapshotNode, parents, position) => { | ||
const fullName = parents.map(parent => parent.arguments[0].value).join(' '); | ||
@@ -105,9 +90,5 @@ | ||
class Snapshot { | ||
constructor(parser, customMatchers) { | ||
this._parser = parser || (_babylon_parser || _load_babylon_parser()).getASTfor; | ||
this._matchers = ['toMatchSnapshot', 'toThrowErrorMatchingSnapshot'].concat( | ||
customMatchers || []); | ||
this._matchers = ['toMatchSnapshot', 'toThrowErrorMatchingSnapshot'].concat(customMatchers || []); | ||
} | ||
@@ -118,4 +99,4 @@ | ||
const state = { | ||
found: [] }; | ||
found: [] | ||
}; | ||
const Visitors = { | ||
@@ -126,8 +107,8 @@ Identifier(path, state, matchers) { | ||
node: path.node, | ||
parents: getArrayOfParents(path) }); | ||
parents: getArrayOfParents(path) | ||
}); | ||
} | ||
} }; | ||
} | ||
}; | ||
(0, (_babelTraverse || _load_babelTraverse()).default)(fileNode, { | ||
@@ -139,5 +120,5 @@ enter: path => { | ||
} | ||
} }); | ||
} | ||
}); | ||
const snapshotPath = (_jestSnapshot || _load_jestSnapshot()).utils.getSnapshotPath(filePath); | ||
@@ -162,5 +143,5 @@ const snapshots = (_jestSnapshot || _load_jestSnapshot()).utils.getSnapshotData(snapshotPath, 'none').data; | ||
name: '', | ||
node: snapshotNode.node }; | ||
node: snapshotNode.node | ||
}; | ||
if (!innerAssertion || isDescribe(innerAssertion.callee)) { | ||
@@ -179,2 +160,4 @@ // An expectation inside describe never gets executed. | ||
}); | ||
}}exports.default = Snapshot; | ||
} | ||
} | ||
exports.default = Snapshot; |
@@ -1,33 +0,24 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _path; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _path; | ||
function _load_path() { | ||
return _path = _interopRequireDefault(require('path')); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _load_path() {return _path = _interopRequireDefault(require('path'));}function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
/** | ||
* You have a Jest test runner watching for changes, and you have | ||
* an extension that wants to know where to show errors after file parsing. | ||
* | ||
* This class represents the state between runs, keeping track of passes/fails | ||
* at a file level, generating useful error messages and providing a nice API. | ||
*/ | ||
* You have a Jest test runner watching for changes, and you have | ||
* an extension that wants to know where to show errors after file parsing. | ||
* | ||
* This class represents the state between runs, keeping track of passes/fails | ||
* at a file level, generating useful error messages and providing a nice API. | ||
*/ | ||
class TestReconciler { | ||
constructor() { | ||
@@ -41,5 +32,3 @@ this.fileStatuses = {}; | ||
// all the results anyway. | ||
updateFileWithJestStatus( | ||
results) | ||
{ | ||
updateFileWithJestStatus(results) { | ||
// Loop through all files inside the report from Jest | ||
@@ -55,4 +44,4 @@ const statusList = []; | ||
message: file.message, | ||
status }; | ||
status | ||
}; | ||
this.fileStatuses[file.name] = fileStatus; | ||
@@ -68,6 +57,3 @@ statusList.push(fileStatus); | ||
mapAssertions( | ||
filename, | ||
assertions) | ||
{ | ||
mapAssertions(filename, assertions) { | ||
// Is it jest < 17? e.g. Before I added this to the JSON | ||
@@ -98,4 +84,4 @@ if (!assertions) { | ||
terseMessage: terse, | ||
title: assertion.title }; | ||
title: assertion.title | ||
}; | ||
}); | ||
@@ -114,9 +100,3 @@ } | ||
return string. | ||
split('\n'). | ||
splice(2). | ||
join(''). | ||
replace(/\s\s+/g, ' '). | ||
replace('Received:', ', Received:'). | ||
split('Difference:')[0]; | ||
return string.split('\n').splice(2).join('').replace(/\s\s+/g, ' ').replace('Received:', ', Received:').split('Difference:')[0]; | ||
} | ||
@@ -140,4 +120,4 @@ | ||
default: | ||
return 'Unknown';} | ||
return 'Unknown'; | ||
} | ||
} | ||
@@ -158,6 +138,3 @@ | ||
stateForTestAssertion( | ||
file, | ||
name) | ||
{ | ||
stateForTestAssertion(file, name) { | ||
const results = this.fileStatuses[file]; | ||
@@ -172,9 +149,11 @@ if (!results || !results.assertions) { | ||
return assertion; | ||
}}exports.default = TestReconciler; /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
} | ||
} | ||
exports.default = TestReconciler; /** | ||
* 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. | ||
* | ||
* | ||
*/ |
@@ -1,76 +0,24 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* The Jest Extension's version of a status for | ||
* individual assertion fails | ||
* | ||
*/ | ||
/** | ||
* The Jest Extension's version of a status for | ||
* individual assertion fails | ||
* | ||
*/ /** | ||
* Did the thing pass, fail or was it not run? | ||
*/ | ||
* Did the thing pass, fail or was it not run? | ||
*/ | ||
const messageTypes = exports.messageTypes = { | ||
noTests: 1, | ||
unknown: 0, | ||
watchUsage: 2 }; // Definitely skipped | ||
watchUsage: 2 | ||
}; // Definitely skipped | ||
/** | ||
@@ -80,9 +28,10 @@ * The Jest Extension's version of a status for | ||
* | ||
*/ /** | ||
* 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. | ||
* | ||
* | ||
*/ | ||
*/ | ||
/** | ||
* 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. | ||
* | ||
* | ||
*/ |
@@ -11,2 +11,6 @@ /** | ||
export interface SpawnOptions { | ||
shell?: boolean; | ||
} | ||
export interface Options { | ||
@@ -16,7 +20,7 @@ createProcess?( | ||
args: string[], | ||
debugPort?: number, | ||
options?: SpawnOptions, | ||
): ChildProcess; | ||
debugPort?: number; | ||
testNamePattern?: string; | ||
testFileNamePattern?: string; | ||
shell?: boolean; | ||
} | ||
@@ -89,8 +93,16 @@ | ||
/** | ||
* 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 { | ||
@@ -100,5 +112,10 @@ file: 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 { | ||
@@ -140,2 +157,3 @@ title: string; | ||
numPendingTests: number; | ||
coverageMap: any; | ||
testResults: Array<JestFileResults>; | ||
@@ -148,3 +166,3 @@ } | ||
export enum MessageTypes { | ||
export enum messageTypes { | ||
noTests = 1, | ||
@@ -156,1 +174,15 @@ unknown = 0, | ||
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[]; | ||
} |
{ | ||
"name": "jest-editor-support", | ||
"version": "22.4.0", | ||
"version": "22.4.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
971
36067