Created
May 6, 2017 22:17
-
-
Save SimenB/9cd6d07959282b1978fbcd968b72d1e6 to your computer and use it in GitHub Desktop.
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
diff --git i/packages/babel-jest/build/index.js w/packages/babel-jest/build/index.js | |
index e7684259..b718e3ba 100644 | |
--- i/packages/babel-jest/build/index.js | |
+++ w/packages/babel-jest/build/index.js | |
@@ -10,9 +10,6 @@ | |
'use strict'; | |
- | |
- | |
- | |
const crypto = require('crypto'); | |
const fs = require('fs'); | |
const jestPreset = require('babel-preset-jest'); | |
@@ -55,51 +52,44 @@ const createTransformer = options => { | |
const packageJsonFileContents = require(packageJsonFilePath); | |
if (packageJsonFileContents[BABEL_CONFIG_KEY]) { | |
cache[directory] = JSON.stringify( | |
- packageJsonFileContents[BABEL_CONFIG_KEY]); | |
+ packageJsonFileContents[BABEL_CONFIG_KEY] | |
+ ); | |
break; | |
} | |
} | |
} | |
- paths.forEach(directoryPath => cache[directoryPath] = cache[directory]); | |
+ paths.forEach(directoryPath => (cache[directoryPath] = cache[directory])); | |
return cache[directory] || ''; | |
}; | |
options = Object.assign({}, options, { | |
- plugins: options && options.plugins || [], | |
- presets: (options && options.presets || []).concat([jestPreset]), | |
- retainLines: true }); | |
+ plugins: (options && options.plugins) || [], | |
+ presets: ((options && options.presets) || []).concat([jestPreset]), | |
+ retainLines: true, | |
+ }); | |
delete options.cacheDirectory; | |
delete options.filename; | |
return { | |
canInstrument: true, | |
- getCacheKey( | |
- fileData, | |
- filename, | |
- configString, _ref) | |
- | |
- {let instrument = _ref.instrument; | |
- return crypto. | |
- createHash('md5'). | |
- update(THIS_FILE). | |
- update('\0', 'utf8'). | |
- update(fileData). | |
- update('\0', 'utf8'). | |
- update(configString). | |
- update('\0', 'utf8'). | |
- update(getBabelRC(filename)). | |
- update('\0', 'utf8'). | |
- update(instrument ? 'instrument' : ''). | |
- digest('hex'); | |
+ getCacheKey(fileData, filename, configString, _ref) { | |
+ let instrument = _ref.instrument; | |
+ return crypto | |
+ .createHash('md5') | |
+ .update(THIS_FILE) | |
+ .update('\0', 'utf8') | |
+ .update(fileData) | |
+ .update('\0', 'utf8') | |
+ .update(configString) | |
+ .update('\0', 'utf8') | |
+ .update(getBabelRC(filename)) | |
+ .update('\0', 'utf8') | |
+ .update(instrument ? 'instrument' : '') | |
+ .digest('hex'); | |
}, | |
- process( | |
- src, | |
- filename, | |
- config, | |
- transformOptions) | |
- { | |
+ process(src, filename, config, transformOptions) { | |
if (!babel) { | |
babel = require('babel-core'); | |
} | |
@@ -108,26 +98,26 @@ const createTransformer = options => { | |
return src; | |
} | |
- const theseOptions = Object.assign({ filename }, options); | |
+ const theseOptions = Object.assign({filename}, options); | |
if (transformOptions && transformOptions.instrument) { | |
theseOptions.auxiliaryCommentBefore = ' istanbul ignore next '; | |
// Copied from jest-runtime transform.js | |
theseOptions.plugins = theseOptions.plugins.concat([ | |
- [ | |
- require('babel-plugin-istanbul').default, | |
- { | |
- // files outside `cwd` will not be instrumented | |
- cwd: config.rootDir, | |
- exclude: [] }]]); | |
- | |
- | |
- | |
+ [ | |
+ require('babel-plugin-istanbul').default, | |
+ { | |
+ // files outside `cwd` will not be instrumented | |
+ cwd: config.rootDir, | |
+ exclude: [], | |
+ }, | |
+ ], | |
+ ]); | |
} | |
return babel.transform(src, theseOptions).code; | |
- } }; | |
- | |
+ }, | |
+ }; | |
}; | |
module.exports = createTransformer(); | |
-module.exports.createTransformer = createTransformer; | |
\ No newline at end of file | |
+module.exports.createTransformer = createTransformer; | |
diff --git i/packages/babel-plugin-jest-hoist/build/index.js w/packages/babel-plugin-jest-hoist/build/index.js | |
index f15824e5..b0dc5901 100644 | |
--- i/packages/babel-plugin-jest-hoist/build/index.js | |
+++ w/packages/babel-plugin-jest-hoist/build/index.js | |
@@ -66,17 +66,18 @@ const WHITELISTED_IDENTIFIERS = { | |
expect: true, | |
jest: true, | |
require: true, | |
- undefined: true }; | |
+ undefined: true, | |
+}; | |
-Object.keys(global).forEach(name => WHITELISTED_IDENTIFIERS[name] = true); | |
+Object.keys(global).forEach(name => (WHITELISTED_IDENTIFIERS[name] = true)); | |
-const JEST_GLOBAL = { name: 'jest' }; | |
+const JEST_GLOBAL = {name: 'jest'}; | |
const IDVisitor = { | |
ReferencedIdentifier(path) { | |
this.ids.add(path); | |
}, | |
- blacklist: ['TypeAnnotation'] }; | |
- | |
+ blacklist: ['TypeAnnotation'], | |
+}; | |
const FUNCTIONS = Object.create(null); | |
FUNCTIONS.mock = args => { | |
@@ -85,13 +86,13 @@ FUNCTIONS.mock = args => { | |
} else if (args.length === 2 || args.length === 3) { | |
const moduleFactory = args[1]; | |
invariant( | |
- moduleFactory.isFunction(), | |
- 'The second argument of `jest.mock` must be a function.'); | |
- | |
+ moduleFactory.isFunction(), | |
+ 'The second argument of `jest.mock` must be a function.' | |
+ ); | |
const ids = new Set(); | |
const parentScope = moduleFactory.parentPath.scope; | |
- moduleFactory.traverse(IDVisitor, { ids }); | |
+ moduleFactory.traverse(IDVisitor, {ids}); | |
for (const id of ids) { | |
const name = id.node.name; | |
let found = false; | |
@@ -108,22 +109,22 @@ FUNCTIONS.mock = args => { | |
if (!found) { | |
invariant( | |
- scope.hasGlobal(name) && WHITELISTED_IDENTIFIERS[name] || | |
- /^mock/.test(name) || | |
- // Allow istanbul's coverage variable to pass. | |
- /^(?:__)?cov/.test(name), | |
- 'The module factory of `jest.mock()` is not allowed to ' + | |
- 'reference any out-of-scope variables.\n' + | |
- 'Invalid variable access: ' + | |
- name + | |
- '\n' + | |
- 'Whitelisted objects: ' + | |
- Object.keys(WHITELISTED_IDENTIFIERS).join(', ') + | |
- '.\n' + | |
- 'Note: This is a precaution to guard against uninitialized mock ' + | |
- 'variables. If it is ensured that the mock is required lazily, ' + | |
- 'variable names prefixed with `mock` are permitted.'); | |
- | |
+ (scope.hasGlobal(name) && WHITELISTED_IDENTIFIERS[name]) || | |
+ /^mock/.test(name) || | |
+ // Allow istanbul's coverage variable to pass. | |
+ /^(?:__)?cov/.test(name), | |
+ 'The module factory of `jest.mock()` is not allowed to ' + | |
+ 'reference any out-of-scope variables.\n' + | |
+ 'Invalid variable access: ' + | |
+ name + | |
+ '\n' + | |
+ 'Whitelisted objects: ' + | |
+ Object.keys(WHITELISTED_IDENTIFIERS).join(', ') + | |
+ '.\n' + | |
+ 'Note: This is a precaution to guard against uninitialized mock ' + | |
+ 'variables. If it is ensured that the mock is required lazily, ' + | |
+ 'variable names prefixed with `mock` are permitted.' | |
+ ); | |
} | |
} | |
@@ -136,12 +137,12 @@ FUNCTIONS.unmock = args => args.length === 1 && args[0].isStringLiteral(); | |
FUNCTIONS.deepUnmock = args => args.length === 1 && args[0].isStringLiteral(); | |
FUNCTIONS.disableAutomock = FUNCTIONS.enableAutomock = args => | |
-args.length === 0; | |
+ args.length === 0; | |
module.exports = () => { | |
const isJest = callee => | |
- callee.get('object').isIdentifier(JEST_GLOBAL) || | |
- callee.isMemberExpression() && isJest(callee.get('object')); | |
+ callee.get('object').isIdentifier(JEST_GLOBAL) || | |
+ (callee.isMemberExpression() && isJest(callee.get('object'))); | |
const shouldHoistExpression = expr => { | |
if (!expr.isCallExpression()) { | |
return false; | |
@@ -152,11 +153,11 @@ module.exports = () => { | |
const property = callee.get('property'); | |
return ( | |
property.isIdentifier() && | |
- FUNCTIONS[property.node.name] && ( | |
- object.isIdentifier(JEST_GLOBAL) || | |
- callee.isMemberExpression() && shouldHoistExpression(object)) && | |
- FUNCTIONS[property.node.name](expr.get('arguments'))); | |
- | |
+ FUNCTIONS[property.node.name] && | |
+ (object.isIdentifier(JEST_GLOBAL) || | |
+ (callee.isMemberExpression() && shouldHoistExpression(object))) && | |
+ FUNCTIONS[property.node.name](expr.get('arguments')) | |
+ ); | |
}; | |
return { | |
visitor: { | |
@@ -164,7 +165,7 @@ module.exports = () => { | |
if (shouldHoistExpression(path.get('expression'))) { | |
path.node._blockHoist = Infinity; | |
} | |
- } } }; | |
- | |
- | |
-}; | |
\ No newline at end of file | |
+ }, | |
+ }, | |
+ }; | |
+}; | |
diff --git i/packages/eslint-plugin-jest/build/index.js w/packages/eslint-plugin-jest/build/index.js | |
index c73bf03d..e7d3dbed 100644 | |
--- i/packages/eslint-plugin-jest/build/index.js | |
+++ w/packages/eslint-plugin-jest/build/index.js | |
@@ -17,9 +17,10 @@ module.exports = { | |
'jest/no-disabled-tests': 'warn', | |
'jest/no-focused-tests': 'error', | |
'jest/no-identical-title': 'error', | |
- 'jest/valid-expect': 'error' } } }, | |
- | |
- | |
+ 'jest/valid-expect': 'error', | |
+ }, | |
+ }, | |
+ }, | |
environments: { | |
globals: { | |
@@ -39,12 +40,15 @@ module.exports = { | |
test: false, | |
xdescribe: false, | |
xit: false, | |
- xtest: false } } }, | |
- | |
- | |
+ xtest: false, | |
+ }, | |
+ }, | |
+ }, | |
rules: { | |
'no-disabled-tests': require('./rules/no-disabled-tests'), | |
'no-focused-tests': require('./rules/no-focused-tests'), | |
'no-identical-title': require('./rules/no-identical-title'), | |
- 'valid-expect': require('./rules/valid-expect') } }; | |
\ No newline at end of file | |
+ 'valid-expect': require('./rules/valid-expect'), | |
+ }, | |
+}; | |
diff --git i/packages/eslint-plugin-jest/build/rules/no-disabled-tests.js w/packages/eslint-plugin-jest/build/rules/no-disabled-tests.js | |
index 231e1ea1..41e5251c 100644 | |
--- i/packages/eslint-plugin-jest/build/rules/no-disabled-tests.js | |
+++ w/packages/eslint-plugin-jest/build/rules/no-disabled-tests.js | |
@@ -9,25 +9,23 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
/* $FlowFixMe */ | |
const testFunctions = Object.assign(Object.create(null), { | |
describe: true, | |
it: true, | |
- test: true }); | |
- | |
+ test: true, | |
+}); | |
const matchesTestFunction = object => object && testFunctions[object.name]; | |
const isCallToSkippedTestFunction = object => | |
-object && object.name[0] === 'x' && testFunctions[object.name.substring(1)]; | |
+ object && object.name[0] === 'x' && testFunctions[object.name.substring(1)]; | |
const isPropertyNamedSkip = property => | |
-property && (property.name === 'skip' || property.value === 'skip'); | |
+ property && (property.name === 'skip' || property.value === 'skip'); | |
const isCallToTestSkipFunction = callee => | |
-matchesTestFunction(callee.object) && isPropertyNamedSkip(callee.property); | |
+ matchesTestFunction(callee.object) && isPropertyNamedSkip(callee.property); | |
module.exports = context => ({ | |
CallExpression(node) { | |
@@ -37,12 +35,13 @@ module.exports = context => ({ | |
} | |
if ( | |
- callee.type === 'MemberExpression' && | |
- isCallToTestSkipFunction(callee)) | |
- { | |
+ callee.type === 'MemberExpression' && | |
+ isCallToTestSkipFunction(callee) | |
+ ) { | |
context.report({ | |
message: 'Unexpected disabled test.', | |
- node: callee.property }); | |
+ node: callee.property, | |
+ }); | |
return; | |
} | |
@@ -50,8 +49,10 @@ module.exports = context => ({ | |
if (callee.type === 'Identifier' && isCallToSkippedTestFunction(callee)) { | |
context.report({ | |
message: 'Unexpected disabled test.', | |
- node: callee }); | |
+ node: callee, | |
+ }); | |
return; | |
} | |
- } }); | |
\ No newline at end of file | |
+ }, | |
+}); | |
diff --git i/packages/eslint-plugin-jest/build/rules/no-focused-tests.js w/packages/eslint-plugin-jest/build/rules/no-focused-tests.js | |
index ed57a65f..8445f095 100644 | |
--- i/packages/eslint-plugin-jest/build/rules/no-focused-tests.js | |
+++ w/packages/eslint-plugin-jest/build/rules/no-focused-tests.js | |
@@ -9,25 +9,23 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
/* $FlowFixMe */ | |
const testFunctions = Object.assign(Object.create(null), { | |
describe: true, | |
it: true, | |
- test: true }); | |
- | |
+ test: true, | |
+}); | |
const matchesTestFunction = object => object && testFunctions[object.name]; | |
const isCallToFocusedTestFunction = object => | |
-object && object.name[0] === 'f' && testFunctions[object.name.substring(1)]; | |
+ object && object.name[0] === 'f' && testFunctions[object.name.substring(1)]; | |
const isPropertyNamedOnly = property => | |
-property && (property.name === 'only' || property.value === 'only'); | |
+ property && (property.name === 'only' || property.value === 'only'); | |
const isCallToTestOnlyFunction = callee => | |
-matchesTestFunction(callee.object) && isPropertyNamedOnly(callee.property); | |
+ matchesTestFunction(callee.object) && isPropertyNamedOnly(callee.property); | |
module.exports = context => ({ | |
CallExpression(node) { | |
@@ -37,12 +35,13 @@ module.exports = context => ({ | |
} | |
if ( | |
- callee.type === 'MemberExpression' && | |
- isCallToTestOnlyFunction(callee)) | |
- { | |
+ callee.type === 'MemberExpression' && | |
+ isCallToTestOnlyFunction(callee) | |
+ ) { | |
context.report({ | |
message: 'Unexpected focused test.', | |
- node: callee.property }); | |
+ node: callee.property, | |
+ }); | |
return; | |
} | |
@@ -50,8 +49,10 @@ module.exports = context => ({ | |
if (callee.type === 'Identifier' && isCallToFocusedTestFunction(callee)) { | |
context.report({ | |
message: 'Unexpected focused test.', | |
- node: callee }); | |
+ node: callee, | |
+ }); | |
return; | |
} | |
- } }); | |
\ No newline at end of file | |
+ }, | |
+}); | |
diff --git i/packages/eslint-plugin-jest/build/rules/no-identical-title.js w/packages/eslint-plugin-jest/build/rules/no-identical-title.js | |
index ece33c48..e66b13a0 100644 | |
--- i/packages/eslint-plugin-jest/build/rules/no-identical-title.js | |
+++ w/packages/eslint-plugin-jest/build/rules/no-identical-title.js | |
@@ -9,16 +9,14 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
/* $FlowFixMe */ | |
const describeAliases = Object.assign(Object.create(null), { | |
describe: true, | |
'describe.only': true, | |
'describe.skip': true, | |
fdescribe: true, | |
- xdescribe: true }); | |
- | |
+ xdescribe: true, | |
+}); | |
/* $FlowFixMe */ | |
const testCaseNames = Object.assign(Object.create(null), { | |
@@ -30,8 +28,8 @@ const testCaseNames = Object.assign(Object.create(null), { | |
'test.only': true, | |
'test.skip': true, | |
xit: true, | |
- xtest: true }); | |
- | |
+ xtest: true, | |
+}); | |
const getNodeName = node => { | |
if (node.type === 'MemberExpression') { | |
@@ -41,27 +39,27 @@ const getNodeName = node => { | |
}; | |
const isDescribe = node => | |
-node && | |
-node.type === 'CallExpression' && | |
-describeAliases[getNodeName(node.callee)]; | |
+ node && | |
+ node.type === 'CallExpression' && | |
+ describeAliases[getNodeName(node.callee)]; | |
const isTestCase = node => | |
-node && | |
-node.type === 'CallExpression' && | |
-testCaseNames[getNodeName(node.callee)]; | |
+ node && | |
+ node.type === 'CallExpression' && | |
+ testCaseNames[getNodeName(node.callee)]; | |
const newDescribeContext = () => ({ | |
describeTitles: [], | |
- testTitles: [] }); | |
- | |
+ testTitles: [], | |
+}); | |
const handleTestCaseTitles = (context, titles, node, title) => { | |
if (isTestCase(node)) { | |
if (titles.indexOf(title) !== -1) { | |
context.report({ | |
message: 'Test title is used multiple times in the same test suite.', | |
- node }); | |
- | |
+ node, | |
+ }); | |
} | |
titles.push(title); | |
} | |
@@ -74,14 +72,14 @@ const handleTestSuiteTitles = (context, titles, node, title) => { | |
if (titles.indexOf(title) !== -1) { | |
context.report({ | |
message: 'Test suite title is used multiple times.', | |
- node }); | |
- | |
+ node, | |
+ }); | |
} | |
titles.push(title); | |
}; | |
const isFirstArgLiteral = node => | |
-node.arguments && node.arguments[0] && node.arguments[0].type === 'Literal'; | |
+ node.arguments && node.arguments[0] && node.arguments[0].type === 'Literal'; | |
module.exports = context => { | |
const contexts = [newDescribeContext()]; | |
@@ -103,6 +101,6 @@ module.exports = context => { | |
if (isDescribe(node)) { | |
contexts.pop(); | |
} | |
- } }; | |
- | |
-}; | |
\ No newline at end of file | |
+ }, | |
+ }; | |
+}; | |
diff --git i/packages/eslint-plugin-jest/build/rules/valid-expect.js w/packages/eslint-plugin-jest/build/rules/valid-expect.js | |
index ebefb26f..f71614f6 100644 | |
--- i/packages/eslint-plugin-jest/build/rules/valid-expect.js | |
+++ w/packages/eslint-plugin-jest/build/rules/valid-expect.js | |
@@ -14,8 +14,6 @@ | |
* MIT license, Tom Vincent. | |
*/ | |
- | |
- | |
const expectProperties = ['not', 'resolves', 'rejects']; | |
module.exports = context => { | |
@@ -28,43 +26,47 @@ module.exports = context => { | |
if (node.arguments.length > 1) { | |
const secondArgumentLocStart = node.arguments[1].loc.start; | |
const lastArgumentLocEnd = | |
- node.arguments[node.arguments.length - 1].loc.end; | |
+ node.arguments[node.arguments.length - 1].loc.end; | |
context.report({ | |
loc: { | |
end: { | |
column: lastArgumentLocEnd.column - 1, | |
- line: lastArgumentLocEnd.line }, | |
+ line: lastArgumentLocEnd.line, | |
+ }, | |
- start: secondArgumentLocStart }, | |
+ start: secondArgumentLocStart, | |
+ }, | |
message: 'More than one argument was passed to expect().', | |
- node }); | |
- | |
+ node, | |
+ }); | |
} else if (node.arguments.length === 0) { | |
const expectLength = calleeName.length; | |
context.report({ | |
loc: { | |
end: { | |
column: node.loc.start.column + expectLength + 1, | |
- line: node.loc.start.line }, | |
+ line: node.loc.start.line, | |
+ }, | |
start: { | |
column: node.loc.start.column + expectLength, | |
- line: node.loc.start.line } }, | |
- | |
+ line: node.loc.start.line, | |
+ }, | |
+ }, | |
message: 'No arguments were passed to expect().', | |
- node }); | |
- | |
+ node, | |
+ }); | |
} | |
// something was called on `expect()` | |
if ( | |
- node.parent && | |
- node.parent.type === 'MemberExpression' && | |
- node.parent.parent) | |
- { | |
+ node.parent && | |
+ node.parent.type === 'MemberExpression' && | |
+ node.parent.parent | |
+ ) { | |
let parentNode = node.parent; | |
let parentProperty = parentNode.property; | |
let propertyName = parentProperty.name; | |
@@ -82,8 +84,8 @@ module.exports = context => { | |
// not added | |
loc: parentProperty.loc, | |
message: `"${propertyName}" is not a valid property of expect.`, | |
- node: parentProperty }); | |
- | |
+ node: parentProperty, | |
+ }); | |
} | |
// this next one should be the matcher | |
@@ -100,8 +102,8 @@ module.exports = context => { | |
// added | |
loc: parentProperty.loc, | |
message: `"${propertyName}" was not called.`, | |
- node: parentProperty }); | |
- | |
+ node: parentProperty, | |
+ }); | |
} | |
} | |
} | |
@@ -110,17 +112,17 @@ module.exports = context => { | |
// nothing called on "expect()" | |
'CallExpression:exit'(node) { | |
if ( | |
- node.callee.name === 'expect' && | |
- node.parent.type === 'ExpressionStatement') | |
- { | |
+ node.callee.name === 'expect' && | |
+ node.parent.type === 'ExpressionStatement' | |
+ ) { | |
context.report({ | |
// For some reason `endColumn` isn't set in tests if `loc` is not | |
// added | |
loc: node.loc, | |
message: 'No assertion was called on expect().', | |
- node }); | |
- | |
+ node, | |
+ }); | |
} | |
- } }; | |
- | |
-}; | |
\ No newline at end of file | |
+ }, | |
+ }; | |
+}; | |
diff --git i/packages/jest-changed-files/build/git.js w/packages/jest-changed-files/build/git.js | |
index 596f1d64..04928225 100644 | |
--- i/packages/jest-changed-files/build/git.js | |
+++ w/packages/jest-changed-files/build/git.js | |
@@ -10,29 +10,19 @@ | |
'use strict'; | |
- | |
- | |
const path = require('path'); | |
const childProcess = require('child_process'); | |
- | |
- | |
- | |
- | |
- | |
-function findChangedFiles( | |
-cwd, | |
-options) | |
-{ | |
+function findChangedFiles(cwd, options) { | |
return new Promise((resolve, reject) => { | |
- const args = options && options.lastCommit ? | |
- ['show', '--name-only', '--pretty=%b', 'HEAD'] : | |
- ['ls-files', '--other', '--modified', '--exclude-standard']; | |
- const child = childProcess.spawn('git', args, { cwd }); | |
+ const args = options && options.lastCommit | |
+ ? ['show', '--name-only', '--pretty=%b', 'HEAD'] | |
+ : ['ls-files', '--other', '--modified', '--exclude-standard']; | |
+ const child = childProcess.spawn('git', args, {cwd}); | |
let stdout = ''; | |
let stderr = ''; | |
- child.stdout.on('data', data => stdout += data); | |
- child.stderr.on('data', data => stderr += data); | |
+ child.stdout.on('data', data => (stdout += data)); | |
+ child.stderr.on('data', data => (stderr += data)); | |
child.on('error', e => reject(e)); | |
child.on('close', code => { | |
if (code === 0) { | |
@@ -41,10 +31,10 @@ options) | |
resolve([]); | |
} else { | |
resolve( | |
- stdout. | |
- split('\n'). | |
- map(changedPath => path.resolve(cwd, changedPath))); | |
- | |
+ stdout | |
+ .split('\n') | |
+ .map(changedPath => path.resolve(cwd, changedPath)) | |
+ ); | |
} | |
} else { | |
reject(code + ': ' + stderr); | |
@@ -58,8 +48,8 @@ function isGitRepository(cwd) { | |
try { | |
let stdout = ''; | |
const options = ['rev-parse', '--show-toplevel']; | |
- const child = childProcess.spawn('git', options, { cwd }); | |
- child.stdout.on('data', data => stdout += data); | |
+ const child = childProcess.spawn('git', options, {cwd}); | |
+ child.stdout.on('data', data => (stdout += data)); | |
child.on('error', () => resolve(null)); | |
child.on('close', code => resolve(code === 0 ? stdout.trim() : null)); | |
} catch (e) { | |
@@ -70,4 +60,5 @@ function isGitRepository(cwd) { | |
module.exports = { | |
findChangedFiles, | |
- isGitRepository }; | |
\ No newline at end of file | |
+ isGitRepository, | |
+}; | |
diff --git i/packages/jest-changed-files/build/hg.js w/packages/jest-changed-files/build/hg.js | |
index ff82b550..55ef5a37 100644 | |
--- i/packages/jest-changed-files/build/hg.js | |
+++ w/packages/jest-changed-files/build/hg.js | |
@@ -10,19 +10,12 @@ | |
'use strict'; | |
- | |
- | |
const path = require('path'); | |
const childProcess = require('child_process'); | |
const env = Object.assign({}, process.env, { | |
- HGPLAIN: 1 }); | |
- | |
- | |
- | |
- | |
- | |
- | |
+ HGPLAIN: 1, | |
+}); | |
function findChangedFiles(cwd, options) { | |
return new Promise((resolve, reject) => { | |
@@ -32,11 +25,11 @@ function findChangedFiles(cwd, options) { | |
} else if (options && options.lastCommit === true) { | |
args = ['tip', '--template', '{files%"{file}\n"}']; | |
} | |
- const child = childProcess.spawn('hg', args, { cwd, env }); | |
+ const child = childProcess.spawn('hg', args, {cwd, env}); | |
let stdout = ''; | |
let stderr = ''; | |
- child.stdout.on('data', data => stdout += data); | |
- child.stderr.on('data', data => stderr += data); | |
+ child.stdout.on('data', data => (stdout += data)); | |
+ child.stderr.on('data', data => (stderr += data)); | |
child.on('error', e => reject(e)); | |
child.on('close', code => { | |
if (code === 0) { | |
@@ -45,10 +38,10 @@ function findChangedFiles(cwd, options) { | |
resolve([]); | |
} else { | |
resolve( | |
- stdout. | |
- split('\n'). | |
- map(changedPath => path.resolve(cwd, changedPath))); | |
- | |
+ stdout | |
+ .split('\n') | |
+ .map(changedPath => path.resolve(cwd, changedPath)) | |
+ ); | |
} | |
} else { | |
reject(code + ': ' + stderr); | |
@@ -61,8 +54,8 @@ function isHGRepository(cwd) { | |
return new Promise(resolve => { | |
try { | |
let stdout = ''; | |
- const child = childProcess.spawn('hg', ['root'], { cwd, env }); | |
- child.stdout.on('data', data => stdout += data); | |
+ const child = childProcess.spawn('hg', ['root'], {cwd, env}); | |
+ child.stdout.on('data', data => (stdout += data)); | |
child.on('error', () => resolve(null)); | |
child.on('close', code => resolve(code === 0 ? stdout.trim() : null)); | |
} catch (e) { | |
@@ -73,4 +66,5 @@ function isHGRepository(cwd) { | |
module.exports = { | |
findChangedFiles, | |
- isHGRepository }; | |
\ No newline at end of file | |
+ isHGRepository, | |
+}; | |
diff --git i/packages/jest-changed-files/build/index.js w/packages/jest-changed-files/build/index.js | |
index e0d2c122..a9dbff45 100644 | |
--- i/packages/jest-changed-files/build/index.js | |
+++ w/packages/jest-changed-files/build/index.js | |
@@ -12,4 +12,5 @@ | |
module.exports = { | |
git: require('./git'), | |
- hg: require('./hg') }; | |
\ No newline at end of file | |
+ hg: require('./hg'), | |
+}; | |
diff --git i/packages/jest-cli/build/PatternPrompt.js w/packages/jest-cli/build/PatternPrompt.js | |
index 9b694b0a..bbde5cbe 100644 | |
--- i/packages/jest-cli/build/PatternPrompt.js | |
+++ w/packages/jest-cli/build/PatternPrompt.js | |
@@ -10,27 +10,20 @@ | |
'use strict'; | |
- | |
- | |
const chalk = require('chalk'); | |
const ansiEscapes = require('ansi-escapes'); | |
const Prompt = require('./lib/Prompt'); | |
const usage = entity => | |
-`\n${chalk.bold('Pattern Mode Usage')}\n` + | |
-` ${chalk.dim('\u203A Press')} Esc ${chalk.dim('to exit pattern mode.')}\n` + | |
-` ${chalk.dim('\u203A Press')} Enter ` + | |
-`${chalk.dim(`to apply pattern to all ${entity}.`)}\n` + | |
-`\n`; | |
+ `\n${chalk.bold('Pattern Mode Usage')}\n` + | |
+ ` ${chalk.dim('\u203A Press')} Esc ${chalk.dim('to exit pattern mode.')}\n` + | |
+ ` ${chalk.dim('\u203A Press')} Enter ` + | |
+ `${chalk.dim(`to apply pattern to all ${entity}.`)}\n` + | |
+ `\n`; | |
const usageRows = usage('').split('\n').length; | |
module.exports = class PatternPrompt { | |
- | |
- | |
- | |
- | |
- | |
constructor(pipe, prompt) { | |
this._pipe = pipe; | |
this._prompt = prompt; | |
@@ -57,4 +50,5 @@ module.exports = class PatternPrompt { | |
_onChange(pattern, options) { | |
this._pipe.write(ansiEscapes.eraseLine); | |
this._pipe.write(ansiEscapes.cursorLeft); | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-cli/build/ReporterDispatcher.js w/packages/jest-cli/build/ReporterDispatcher.js | |
index 2349309c..a23e2c73 100644 | |
--- i/packages/jest-cli/build/ReporterDispatcher.js | |
+++ w/packages/jest-cli/build/ReporterDispatcher.js | |
@@ -8,22 +8,38 @@ | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
class ReporterDispatcher { | |
- | |
- | |
- | |
constructor() { | |
this._reporters = []; | |
} | |
@@ -34,35 +50,39 @@ class ReporterDispatcher { | |
unregister(ReporterClass) { | |
this._reporters = this._reporters.filter( | |
- reporter => !(reporter instanceof ReporterClass)); | |
- | |
+ reporter => !(reporter instanceof ReporterClass) | |
+ ); | |
} | |
onTestResult(test, testResult, results) { | |
this._reporters.forEach( | |
- reporter => | |
- reporter.onTestResult && | |
- reporter.onTestResult(test, testResult, results)); | |
- | |
+ reporter => | |
+ reporter.onTestResult && | |
+ reporter.onTestResult(test, testResult, results) | |
+ ); | |
} | |
onTestStart(test) { | |
this._reporters.forEach( | |
- reporter => reporter.onTestStart && reporter.onTestStart(test)); | |
- | |
+ reporter => reporter.onTestStart && reporter.onTestStart(test) | |
+ ); | |
} | |
onRunStart(results, options) { | |
this._reporters.forEach( | |
- reporter => reporter.onRunStart && reporter.onRunStart(results, options)); | |
- | |
+ reporter => reporter.onRunStart && reporter.onRunStart(results, options) | |
+ ); | |
} | |
- onRunComplete(contexts, results) {var _this = this;return _asyncToGenerator(function* () { | |
- _this._reporters.forEach( | |
- function (reporter) {return ( | |
- reporter.onRunComplete && reporter.onRunComplete(contexts, results));});})(); | |
- | |
+ onRunComplete(contexts, results) { | |
+ var _this = this; | |
+ return _asyncToGenerator(function*() { | |
+ _this._reporters.forEach(function(reporter) { | |
+ return ( | |
+ reporter.onRunComplete && reporter.onRunComplete(contexts, results) | |
+ ); | |
+ }); | |
+ })(); | |
} | |
// Return a list of last errors for every reporter | |
@@ -75,7 +95,7 @@ class ReporterDispatcher { | |
hasErrors() { | |
return this.getErrors().length !== 0; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = ReporterDispatcher; | |
\ No newline at end of file | |
+module.exports = ReporterDispatcher; | |
diff --git i/packages/jest-cli/build/SearchSource.js w/packages/jest-cli/build/SearchSource.js | |
index fd48e41f..76589611 100644 | |
--- i/packages/jest-cli/build/SearchSource.js | |
+++ w/packages/jest-cli/build/SearchSource.js | |
@@ -8,51 +8,62 @@ | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
const micromatch = require('micromatch'); | |
const DependencyResolver = require('jest-resolve-dependencies'); | |
const changedFiles = require('jest-changed-files'); | |
-const path = require('path');var _require = | |
-require('jest-regex-util');const escapePathForRegex = _require.escapePathForRegex,replacePathSepForRegex = _require.replacePathSepForRegex; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+const path = require('path'); | |
+var _require = require('jest-regex-util'); | |
+const escapePathForRegex = _require.escapePathForRegex, | |
+ replacePathSepForRegex = _require.replacePathSepForRegex; | |
const git = changedFiles.git; | |
const hg = changedFiles.hg; | |
const determineSCM = path => | |
-Promise.all([git.isGitRepository(path), hg.isHGRepository(path)]); | |
+ Promise.all([git.isGitRepository(path), hg.isHGRepository(path)]); | |
const pathToRegex = p => replacePathSepForRegex(p); | |
const globsToMatcher = globs => { | |
@@ -60,7 +71,7 @@ const globsToMatcher = globs => { | |
return () => true; | |
} | |
- const matchers = globs.map(each => micromatch.matcher(each, { dot: true })); | |
+ const matchers = globs.map(each => micromatch.matcher(each, {dot: true})); | |
return path => matchers.some(each => each(path)); | |
}; | |
@@ -74,58 +85,44 @@ const regexToMatcher = testRegex => { | |
}; | |
const toTests = (context, tests) => | |
-tests.map(path => ({ | |
- context, | |
- duration: undefined, | |
- path })); | |
- | |
+ tests.map(path => ({ | |
+ context, | |
+ duration: undefined, | |
+ path, | |
+ })); | |
class SearchSource { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- constructor(context, options) {const | |
- config = context.config; | |
+ constructor(context, options) { | |
+ const config = context.config; | |
this._context = context; | |
this._options = options || { | |
- skipNodeResolution: false }; | |
- | |
+ skipNodeResolution: false, | |
+ }; | |
this._rootPattern = new RegExp( | |
- config.roots.map(dir => escapePathForRegex(dir)).join('|')); | |
- | |
+ config.roots.map(dir => escapePathForRegex(dir)).join('|') | |
+ ); | |
const ignorePattern = config.testPathIgnorePatterns; | |
- this._testIgnorePattern = ignorePattern.length ? | |
- new RegExp(ignorePattern.join('|')) : | |
- null; | |
+ this._testIgnorePattern = ignorePattern.length | |
+ ? new RegExp(ignorePattern.join('|')) | |
+ : null; | |
this._testPathCases = { | |
roots: path => this._rootPattern.test(path), | |
testMatch: globsToMatcher(config.testMatch), | |
testPathIgnorePatterns: path => | |
- !this._testIgnorePattern || !this._testIgnorePattern.test(path), | |
- testRegex: regexToMatcher(config.testRegex) }; | |
- | |
+ !this._testIgnorePattern || !this._testIgnorePattern.test(path), | |
+ testRegex: regexToMatcher(config.testRegex), | |
+ }; | |
} | |
- _filterTestPathsWithStats( | |
- allPaths, | |
- testPathPattern) | |
- { | |
+ _filterTestPathsWithStats(allPaths, testPathPattern) { | |
const data = { | |
stats: {}, | |
tests: [], | |
- total: allPaths.length }; | |
- | |
+ total: allPaths.length, | |
+ }; | |
const testCases = Object.assign({}, this._testPathCases); | |
if (testPathPattern) { | |
@@ -150,15 +147,15 @@ class SearchSource { | |
_getAllTestPaths(testPathPattern) { | |
return this._filterTestPathsWithStats( | |
- toTests(this._context, this._context.hasteFS.getAllFiles()), | |
- testPathPattern); | |
- | |
+ toTests(this._context, this._context.hasteFS.getAllFiles()), | |
+ testPathPattern | |
+ ); | |
} | |
isTestFilePath(path) { | |
return Object.keys(this._testPathCases).every(key => | |
- this._testPathCases[key](path)); | |
- | |
+ this._testPathCases[key](path) | |
+ ); | |
} | |
findMatchingTests(testPathPattern) { | |
@@ -167,21 +164,22 @@ class SearchSource { | |
findRelatedTests(allPaths) { | |
const dependencyResolver = new DependencyResolver( | |
- this._context.resolver, | |
- this._context.hasteFS); | |
+ this._context.resolver, | |
+ this._context.hasteFS | |
+ ); | |
return { | |
tests: toTests( | |
- this._context, | |
- dependencyResolver.resolveInverse( | |
- allPaths, | |
- this.isTestFilePath.bind(this), | |
- { | |
- skipNodeResolution: this._options.skipNodeResolution })) }; | |
- | |
- | |
- | |
- | |
+ this._context, | |
+ dependencyResolver.resolveInverse( | |
+ allPaths, | |
+ this.isTestFilePath.bind(this), | |
+ { | |
+ skipNodeResolution: this._options.skipNodeResolution, | |
+ } | |
+ ) | |
+ ), | |
+ }; | |
} | |
findRelatedTestsFromPattern(paths) { | |
@@ -189,48 +187,56 @@ class SearchSource { | |
const resolvedPaths = paths.map(p => path.resolve(process.cwd(), p)); | |
return this.findRelatedTests(new Set(resolvedPaths)); | |
} | |
- return { tests: [] }; | |
+ return {tests: []}; | |
} | |
findChangedTests(options) { | |
return Promise.all( | |
- this._context.config.roots.map(determineSCM)). | |
- then(repos => { | |
- if (!repos.every((_ref) => {var _ref2 = _slicedToArray(_ref, 2);let gitRepo = _ref2[0],hgRepo = _ref2[1];return gitRepo || hgRepo;})) { | |
+ this._context.config.roots.map(determineSCM) | |
+ ).then(repos => { | |
+ if ( | |
+ !repos.every(_ref => { | |
+ var _ref2 = _slicedToArray(_ref, 2); | |
+ let gitRepo = _ref2[0], hgRepo = _ref2[1]; | |
+ return gitRepo || hgRepo; | |
+ }) | |
+ ) { | |
return { | |
noSCM: true, | |
- tests: [] }; | |
- | |
+ tests: [], | |
+ }; | |
} | |
return Promise.all( | |
- repos.map((_ref3) => {var _ref4 = _slicedToArray(_ref3, 2);let gitRepo = _ref4[0],hgRepo = _ref4[1]; | |
- if (gitRepo) { | |
- return git.findChangedFiles(gitRepo, options); | |
- } | |
- if (hgRepo) { | |
- return hg.findChangedFiles(hgRepo, options); | |
- } | |
- return []; | |
- })). | |
- then(changedPathSets => | |
- this.findRelatedTests( | |
- new Set(Array.prototype.concat.apply([], changedPathSets)))); | |
- | |
- | |
+ repos.map(_ref3 => { | |
+ var _ref4 = _slicedToArray(_ref3, 2); | |
+ let gitRepo = _ref4[0], hgRepo = _ref4[1]; | |
+ if (gitRepo) { | |
+ return git.findChangedFiles(gitRepo, options); | |
+ } | |
+ if (hgRepo) { | |
+ return hg.findChangedFiles(hgRepo, options); | |
+ } | |
+ return []; | |
+ }) | |
+ ).then(changedPathSets => | |
+ this.findRelatedTests( | |
+ new Set(Array.prototype.concat.apply([], changedPathSets)) | |
+ ) | |
+ ); | |
}); | |
} | |
getTestPaths(pattern) { | |
if (pattern.onlyChanged) { | |
- return this.findChangedTests({ lastCommit: pattern.lastCommit }); | |
+ return this.findChangedTests({lastCommit: pattern.lastCommit}); | |
} else if (pattern.findRelatedTests && pattern.paths) { | |
return Promise.resolve(this.findRelatedTestsFromPattern(pattern.paths)); | |
} else if (pattern.testPathPattern != null) { | |
return Promise.resolve(this.findMatchingTests(pattern.testPathPattern)); | |
} else { | |
- return Promise.resolve({ tests: [] }); | |
+ return Promise.resolve({tests: []}); | |
} | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = SearchSource; | |
\ No newline at end of file | |
+module.exports = SearchSource; | |
diff --git i/packages/jest-cli/build/TestNamePatternPrompt.js w/packages/jest-cli/build/TestNamePatternPrompt.js | |
index c48920b7..2cd0b39f 100644 | |
--- i/packages/jest-cli/build/TestNamePatternPrompt.js | |
+++ w/packages/jest-cli/build/TestNamePatternPrompt.js | |
@@ -10,27 +10,22 @@ | |
'use strict'; | |
- | |
- | |
- | |
-const scroll = require('./lib/scrollList');var _require = | |
-require('./lib/terminalUtils');const getTerminalWidth = _require.getTerminalWidth; | |
+const scroll = require('./lib/scrollList'); | |
+var _require = require('./lib/terminalUtils'); | |
+const getTerminalWidth = _require.getTerminalWidth; | |
const Prompt = require('./lib/Prompt'); | |
-const formatTestNameByPattern = require('./lib/formatTestNameByPattern');var _require2 = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./lib/patternModeHelpers');const formatTypeaheadSelection = _require2.formatTypeaheadSelection,printMore = _require2.printMore,printPatternCaret = _require2.printPatternCaret,printPatternMatches = _require2.printPatternMatches,printRestoredPatternCaret = _require2.printRestoredPatternCaret,printStartTyping = _require2.printStartTyping,printTypeaheadItem = _require2.printTypeaheadItem; | |
+const formatTestNameByPattern = require('./lib/formatTestNameByPattern'); | |
+var _require2 = require('./lib/patternModeHelpers'); | |
+const formatTypeaheadSelection = _require2.formatTypeaheadSelection, | |
+ printMore = _require2.printMore, | |
+ printPatternCaret = _require2.printPatternCaret, | |
+ printPatternMatches = _require2.printPatternMatches, | |
+ printRestoredPatternCaret = _require2.printRestoredPatternCaret, | |
+ printStartTyping = _require2.printStartTyping, | |
+ printTypeaheadItem = _require2.printTypeaheadItem; | |
const PatternPrompt = require('./PatternPrompt'); | |
module.exports = class TestNamePatternPrompt extends PatternPrompt { | |
- | |
- | |
constructor(pipe, prompt) { | |
super(pipe, prompt); | |
this._entityName = 'tests'; | |
@@ -52,22 +47,23 @@ module.exports = class TestNamePatternPrompt extends PatternPrompt { | |
if (pattern) { | |
printPatternMatches( | |
- total, | |
- 'test', | |
- pipe, | |
- ` from ${require('chalk').yellow('cached')} test suites`); | |
- | |
+ total, | |
+ 'test', | |
+ pipe, | |
+ ` from ${require('chalk').yellow('cached')} test suites` | |
+ ); | |
- const width = getTerminalWidth();var _scroll = | |
- scroll(total, options);const start = _scroll.start,end = _scroll.end,index = _scroll.index; | |
+ const width = getTerminalWidth(); | |
+ var _scroll = scroll(total, options); | |
+ const start = _scroll.start, end = _scroll.end, index = _scroll.index; | |
prompt.setTypeaheadLength(total); | |
- matchedTests. | |
- slice(start, end). | |
- map(name => formatTestNameByPattern(name, pattern, width - 4)). | |
- map((item, i) => formatTypeaheadSelection(item, i, index, prompt)). | |
- forEach(item => printTypeaheadItem(item, pipe)); | |
+ matchedTests | |
+ .slice(start, end) | |
+ .map(name => formatTestNameByPattern(name, pattern, width - 4)) | |
+ .map((item, i) => formatTypeaheadSelection(item, i, index, prompt)) | |
+ .forEach(item => printTypeaheadItem(item, pipe)); | |
if (total > end) { | |
printMore('test', pipe, total - end); | |
@@ -90,17 +86,23 @@ module.exports = class TestNamePatternPrompt extends PatternPrompt { | |
const matchedTests = []; | |
- this._cachedTestResults.forEach((_ref) => {let testResults = _ref.testResults;return ( | |
- testResults.forEach((_ref2) => {let title = _ref2.title; | |
- if (regex.test(title)) { | |
- matchedTests.push(title); | |
- } | |
- }));}); | |
- | |
+ this._cachedTestResults.forEach(_ref => { | |
+ let testResults = _ref.testResults; | |
+ return testResults.forEach(_ref2 => { | |
+ let title = _ref2.title; | |
+ if (regex.test(title)) { | |
+ matchedTests.push(title); | |
+ } | |
+ }); | |
+ }); | |
return matchedTests; | |
} | |
- updateCachedTestResults() {let testResults = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | |
+ updateCachedTestResults() { | |
+ let testResults = arguments.length > 0 && arguments[0] !== undefined | |
+ ? arguments[0] | |
+ : []; | |
this._cachedTestResults = testResults; | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-cli/build/TestPathPatternPrompt.js w/packages/jest-cli/build/TestPathPatternPrompt.js | |
index 0075ed95..eb254511 100644 | |
--- i/packages/jest-cli/build/TestPathPatternPrompt.js | |
+++ w/packages/jest-cli/build/TestPathPatternPrompt.js | |
@@ -10,37 +10,26 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
const chalk = require('chalk'); | |
-const scroll = require('./lib/scrollList');var _require = | |
-require('./lib/terminalUtils');const getTerminalWidth = _require.getTerminalWidth; | |
+const scroll = require('./lib/scrollList'); | |
+var _require = require('./lib/terminalUtils'); | |
+const getTerminalWidth = _require.getTerminalWidth; | |
const highlight = require('./lib/highlight'); | |
-const stringLength = require('string-length');var _require2 = | |
-require('./reporters/utils');const trimAndFormatPath = _require2.trimAndFormatPath; | |
-const Prompt = require('./lib/Prompt');var _require3 = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./lib/patternModeHelpers');const formatTypeaheadSelection = _require3.formatTypeaheadSelection,printMore = _require3.printMore,printPatternCaret = _require3.printPatternCaret,printPatternMatches = _require3.printPatternMatches,printRestoredPatternCaret = _require3.printRestoredPatternCaret,printStartTyping = _require3.printStartTyping,printTypeaheadItem = _require3.printTypeaheadItem; | |
+const stringLength = require('string-length'); | |
+var _require2 = require('./reporters/utils'); | |
+const trimAndFormatPath = _require2.trimAndFormatPath; | |
+const Prompt = require('./lib/Prompt'); | |
+var _require3 = require('./lib/patternModeHelpers'); | |
+const formatTypeaheadSelection = _require3.formatTypeaheadSelection, | |
+ printMore = _require3.printMore, | |
+ printPatternCaret = _require3.printPatternCaret, | |
+ printPatternMatches = _require3.printPatternMatches, | |
+ printRestoredPatternCaret = _require3.printRestoredPatternCaret, | |
+ printStartTyping = _require3.printStartTyping, | |
+ printTypeaheadItem = _require3.printTypeaheadItem; | |
const PatternPrompt = require('./PatternPrompt'); | |
- | |
- | |
- | |
- | |
- | |
module.exports = class TestPathPatternPrompt extends PatternPrompt { | |
- | |
- | |
constructor(pipe, prompt) { | |
super(pipe, prompt); | |
this._entityName = 'filenames'; | |
@@ -64,24 +53,27 @@ module.exports = class TestPathPatternPrompt extends PatternPrompt { | |
const prefix = ` ${chalk.dim('\u203A')} `; | |
const padding = stringLength(prefix) + 2; | |
- const width = getTerminalWidth();var _scroll = | |
- scroll(total, options);const start = _scroll.start,end = _scroll.end,index = _scroll.index; | |
+ const width = getTerminalWidth(); | |
+ var _scroll = scroll(total, options); | |
+ const start = _scroll.start, end = _scroll.end, index = _scroll.index; | |
prompt.setTypeaheadLength(total); | |
- matchedTests. | |
- slice(start, end). | |
- map((_ref) => {let path = _ref.path,context = _ref.context; | |
- const filePath = trimAndFormatPath( | |
- padding, | |
- context.config, | |
- path, | |
- width); | |
- | |
- return highlight(path, filePath, pattern, context.config.rootDir); | |
- }). | |
- map((item, i) => formatTypeaheadSelection(item, i, index, prompt)). | |
- forEach(item => printTypeaheadItem(item, pipe)); | |
+ matchedTests | |
+ .slice(start, end) | |
+ .map(_ref => { | |
+ let path = _ref.path, context = _ref.context; | |
+ const filePath = trimAndFormatPath( | |
+ padding, | |
+ context.config, | |
+ path, | |
+ width | |
+ ); | |
+ | |
+ return highlight(path, filePath, pattern, context.config.rootDir); | |
+ }) | |
+ .map((item, i) => formatTypeaheadSelection(item, i, index, prompt)) | |
+ .forEach(item => printTypeaheadItem(item, pipe)); | |
if (total > end) { | |
printMore('file', pipe, total - end); | |
@@ -102,7 +94,8 @@ module.exports = class TestPathPatternPrompt extends PatternPrompt { | |
let tests = []; | |
if (regex) { | |
- this._searchSources.forEach((_ref2) => {let searchSource = _ref2.searchSource,context = _ref2.context; | |
+ this._searchSources.forEach(_ref2 => { | |
+ let searchSource = _ref2.searchSource, context = _ref2.context; | |
tests = tests.concat(searchSource.findMatchingTests(pattern).tests); | |
}); | |
} | |
@@ -112,4 +105,5 @@ module.exports = class TestPathPatternPrompt extends PatternPrompt { | |
updateSearchSources(searchSources) { | |
this._searchSources = searchSources; | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-cli/build/TestRunner.js w/packages/jest-cli/build/TestRunner.js | |
index 21891c60..f60d6cb1 100644 | |
--- i/packages/jest-cli/build/TestRunner.js | |
+++ w/packages/jest-cli/build/TestRunner.js | |
@@ -7,19 +7,77 @@ | |
* | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-message-util');const formatExecError = _require.formatExecError; | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
+var _require = require('jest-message-util'); | |
+const formatExecError = _require.formatExecError; | |
const DefaultReporter = require('./reporters/DefaultReporter'); | |
const NotifyReporter = require('./reporters/NotifyReporter'); | |
@@ -39,27 +97,12 @@ class CancelRun extends Error { | |
constructor(message) { | |
super(message); | |
this.name = 'CancelRun'; | |
- }} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+ } | |
+} | |
const TEST_WORKER_PATH = require.resolve('./TestWorker'); | |
class TestRunner { | |
- | |
- | |
- | |
- | |
constructor(globalConfig, options) { | |
this._globalConfig = globalConfig; | |
this._dispatcher = new ReporterDispatcher(); | |
@@ -75,10 +118,12 @@ class TestRunner { | |
this._dispatcher.unregister(ReporterClass); | |
} | |
- runTests(tests, watcher) {var _this = this;return _asyncToGenerator(function* () { | |
+ runTests(tests, watcher) { | |
+ var _this = this; | |
+ return _asyncToGenerator(function*() { | |
const timings = []; | |
const contexts = new Set(); | |
- tests.forEach(function (test) { | |
+ tests.forEach(function(test) { | |
contexts.add(test.context); | |
if (test.duration) { | |
timings.push(test.duration); | |
@@ -87,20 +132,22 @@ class TestRunner { | |
const aggregatedResults = createAggregatedResults(tests.length); | |
const estimatedTime = Math.ceil( | |
- getEstimatedTime(timings, _this._options.maxWorkers) / 1000); | |
- | |
+ getEstimatedTime(timings, _this._options.maxWorkers) / 1000 | |
+ ); | |
// Run in band if we only have one test or one worker available. | |
// If we are confident from previous runs that the tests will finish quickly | |
// we also run in band to reduce the overhead of spawning workers. | |
const runInBand = | |
- _this._options.maxWorkers <= 1 || | |
- tests.length <= 1 || | |
- tests.length <= 20 && | |
- timings.length > 0 && | |
- timings.every(function (timing) {return timing < SLOW_TEST_TIME;}); | |
- | |
- const onResult = function (test, testResult) { | |
+ _this._options.maxWorkers <= 1 || | |
+ tests.length <= 1 || | |
+ (tests.length <= 20 && | |
+ timings.length > 0 && | |
+ timings.every(function(timing) { | |
+ return timing < SLOW_TEST_TIME; | |
+ })); | |
+ | |
+ const onResult = function(test, testResult) { | |
if (watcher.isInterrupted()) { | |
return Promise.resolve(); | |
} | |
@@ -108,7 +155,8 @@ class TestRunner { | |
const message = 'Your test suite must contain at least one test.'; | |
onFailure(test, { | |
message, | |
- stack: new Error(message).stack }); | |
+ stack: new Error(message).stack, | |
+ }); | |
return Promise.resolve(); | |
} | |
@@ -117,46 +165,48 @@ class TestRunner { | |
return _this._bailIfNeeded(contexts, aggregatedResults, watcher); | |
}; | |
- const onFailure = function (test, error) { | |
+ const onFailure = function(test, error) { | |
if (watcher.isInterrupted()) { | |
return; | |
} | |
const testResult = buildFailureTestResult(test.path, error); | |
testResult.failureMessage = formatExecError( | |
- testResult, | |
- test.context.config, | |
- _this._globalConfig, | |
- test.path); | |
+ testResult, | |
+ test.context.config, | |
+ _this._globalConfig, | |
+ test.path | |
+ ); | |
addResult(aggregatedResults, testResult); | |
_this._dispatcher.onTestResult(test, testResult, aggregatedResults); | |
}; | |
- const updateSnapshotState = function () { | |
- contexts.forEach(function (context) { | |
+ const updateSnapshotState = function() { | |
+ contexts.forEach(function(context) { | |
const status = snapshot.cleanup( | |
- context.hasteFS, | |
- _this._globalConfig.updateSnapshot); | |
+ context.hasteFS, | |
+ _this._globalConfig.updateSnapshot | |
+ ); | |
aggregatedResults.snapshot.filesRemoved += status.filesRemoved; | |
}); | |
const updateAll = _this._globalConfig.updateSnapshot === 'all'; | |
aggregatedResults.snapshot.didUpdate = updateAll; | |
- aggregatedResults.snapshot.failure = !!(!updateAll && ( | |
- aggregatedResults.snapshot.unchecked || | |
- aggregatedResults.snapshot.unmatched || | |
- aggregatedResults.snapshot.filesRemoved)); | |
+ aggregatedResults.snapshot.failure = !!(!updateAll && | |
+ (aggregatedResults.snapshot.unchecked || | |
+ aggregatedResults.snapshot.unmatched || | |
+ aggregatedResults.snapshot.filesRemoved)); | |
}; | |
_this._dispatcher.onRunStart(aggregatedResults, { | |
estimatedTime, | |
- showStatus: !runInBand }); | |
- | |
+ showStatus: !runInBand, | |
+ }); | |
try { | |
- yield runInBand ? | |
- _this._createInBandTestRun(tests, watcher, onResult, onFailure) : | |
- _this._createParallelTestRun(tests, watcher, onResult, onFailure); | |
+ yield runInBand | |
+ ? _this._createInBandTestRun(tests, watcher, onResult, onFailure) | |
+ : _this._createParallelTestRun(tests, watcher, onResult, onFailure); | |
} catch (error) { | |
if (!watcher.isInterrupted()) { | |
throw error; | |
@@ -168,61 +218,53 @@ class TestRunner { | |
yield _this._dispatcher.onRunComplete(contexts, aggregatedResults); | |
const anyTestFailures = !(aggregatedResults.numFailedTests === 0 && | |
- aggregatedResults.numRuntimeErrorTestSuites === 0); | |
+ aggregatedResults.numRuntimeErrorTestSuites === 0); | |
const anyReporterErrors = _this._dispatcher.hasErrors(); | |
aggregatedResults.success = !(anyTestFailures || | |
- aggregatedResults.snapshot.failure || | |
- anyReporterErrors); | |
+ aggregatedResults.snapshot.failure || | |
+ anyReporterErrors); | |
- return aggregatedResults;})(); | |
+ return aggregatedResults; | |
+ })(); | |
} | |
- _createInBandTestRun( | |
- tests, | |
- watcher, | |
- onResult, | |
- onFailure) | |
- { | |
+ _createInBandTestRun(tests, watcher, onResult, onFailure) { | |
const mutex = throat(1); | |
return tests.reduce( | |
- (promise, test) => | |
- mutex(() => | |
- promise. | |
- then(() => { | |
- if (watcher.isInterrupted()) { | |
- throw new CancelRun(); | |
- } | |
- | |
- this._dispatcher.onTestStart(test); | |
- return runTest( | |
- test.path, | |
- this._globalConfig, | |
- test.context.config, | |
- test.context.resolver); | |
- | |
- }). | |
- then(result => onResult(test, result)). | |
- catch(err => onFailure(test, err))), | |
- | |
- Promise.resolve()); | |
- | |
+ (promise, test) => | |
+ mutex(() => | |
+ promise | |
+ .then(() => { | |
+ if (watcher.isInterrupted()) { | |
+ throw new CancelRun(); | |
+ } | |
+ | |
+ this._dispatcher.onTestStart(test); | |
+ return runTest( | |
+ test.path, | |
+ this._globalConfig, | |
+ test.context.config, | |
+ test.context.resolver | |
+ ); | |
+ }) | |
+ .then(result => onResult(test, result)) | |
+ .catch(err => onFailure(test, err)) | |
+ ), | |
+ Promise.resolve() | |
+ ); | |
} | |
- _createParallelTestRun( | |
- tests, | |
- watcher, | |
- onResult, | |
- onFailure) | |
- { | |
+ _createParallelTestRun(tests, watcher, onResult, onFailure) { | |
const farm = workerFarm( | |
- { | |
- autoStart: true, | |
- maxConcurrentCallsPerWorker: 1, | |
- maxConcurrentWorkers: this._options.maxWorkers, | |
- maxRetries: 2 }, | |
- | |
- TEST_WORKER_PATH); | |
+ { | |
+ autoStart: true, | |
+ maxConcurrentCallsPerWorker: 1, | |
+ maxConcurrentWorkers: this._options.maxWorkers, | |
+ maxRetries: 2, | |
+ }, | |
+ TEST_WORKER_PATH | |
+ ); | |
const mutex = throat(this._options.maxWorkers); | |
const worker = pify(farm); | |
@@ -230,27 +272,28 @@ class TestRunner { | |
// Send test suites to workers continuously instead of all at once to track | |
// the start time of individual tests. | |
const runTestInWorker = test => | |
- mutex(() => { | |
- if (watcher.isInterrupted()) { | |
- return Promise.reject(); | |
- } | |
- this._dispatcher.onTestStart(test); | |
- return worker({ | |
- config: test.context.config, | |
- globalConfig: this._globalConfig, | |
- path: test.path, | |
- rawModuleMap: watcher.isWatchMode() ? | |
- test.context.moduleMap.getRawModuleMap() : | |
- null }); | |
- | |
- }); | |
+ mutex(() => { | |
+ if (watcher.isInterrupted()) { | |
+ return Promise.reject(); | |
+ } | |
+ this._dispatcher.onTestStart(test); | |
+ return worker({ | |
+ config: test.context.config, | |
+ globalConfig: this._globalConfig, | |
+ path: test.path, | |
+ rawModuleMap: watcher.isWatchMode() | |
+ ? test.context.moduleMap.getRawModuleMap() | |
+ : null, | |
+ }); | |
+ }); | |
const onError = (err, test) => { | |
onFailure(test, err); | |
if (err.type === 'ProcessTerminatedError') { | |
console.error( | |
- 'A worker process has quit unexpectedly! ' + | |
- 'Most likely this is an initialization error.'); | |
+ 'A worker process has quit unexpectedly! ' + | |
+ 'Most likely this is an initialization error.' | |
+ ); | |
process.exit(1); | |
} | |
@@ -265,12 +308,12 @@ class TestRunner { | |
}); | |
const runAllTests = Promise.all( | |
- tests.map(test => | |
- runTestInWorker(test). | |
- then(testResult => onResult(test, testResult)). | |
- catch(error => onError(error, test)))); | |
- | |
- | |
+ tests.map(test => | |
+ runTestInWorker(test) | |
+ .then(testResult => onResult(test, testResult)) | |
+ .catch(error => onError(error, test)) | |
+ ) | |
+ ); | |
const cleanup = () => workerFarm.end(farm); | |
return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup); | |
@@ -279,12 +322,15 @@ class TestRunner { | |
_shouldAddDefaultReporters(reporters) { | |
return ( | |
!reporters || | |
- !!reporters.find(reporterConfig => reporterConfig[0] === 'default')); | |
- | |
+ !!reporters.find(reporterConfig => reporterConfig[0] === 'default') | |
+ ); | |
} | |
- _setupReporters() {var _globalConfig = | |
- this._globalConfig;const collectCoverage = _globalConfig.collectCoverage,notify = _globalConfig.notify,reporters = _globalConfig.reporters; | |
+ _setupReporters() { | |
+ var _globalConfig = this._globalConfig; | |
+ const collectCoverage = _globalConfig.collectCoverage, | |
+ notify = _globalConfig.notify, | |
+ reporters = _globalConfig.reporters; | |
const isDefault = this._shouldAddDefaultReporters(reporters); | |
@@ -301,10 +347,10 @@ class TestRunner { | |
// want to require it if we're not in the `--coverage` mode | |
const CoverageReporter = require('./reporters/CoverageReporter'); | |
this.addReporter( | |
- new CoverageReporter(this._globalConfig, { | |
- maxWorkers: this._options.maxWorkers })); | |
- | |
- | |
+ new CoverageReporter(this._globalConfig, { | |
+ maxWorkers: this._options.maxWorkers, | |
+ }) | |
+ ); | |
} | |
if (notify) { | |
@@ -314,38 +360,39 @@ class TestRunner { | |
_setupDefaultReporters() { | |
this.addReporter( | |
- this._globalConfig.verbose ? | |
- new VerboseReporter(this._globalConfig) : | |
- new DefaultReporter(this._globalConfig)); | |
- | |
+ this._globalConfig.verbose | |
+ ? new VerboseReporter(this._globalConfig) | |
+ : new DefaultReporter(this._globalConfig) | |
+ ); | |
this.addReporter( | |
- new SummaryReporter(this._globalConfig, { | |
- pattern: this._options.pattern, | |
- testNamePattern: this._options.testNamePattern, | |
- testPathPattern: this._options.testPathPattern })); | |
- | |
- | |
+ new SummaryReporter(this._globalConfig, { | |
+ pattern: this._options.pattern, | |
+ testNamePattern: this._options.testNamePattern, | |
+ testPathPattern: this._options.testPathPattern, | |
+ }) | |
+ ); | |
} | |
_addCustomReporters(reporters) { | |
const customReporters = reporters.filter( | |
- reporter => reporter !== 'default'); | |
- | |
+ reporter => reporter !== 'default' | |
+ ); | |
- customReporters.forEach((reporter, index) => {var _getReporterProps = | |
- this._getReporterProps(reporter);const options = _getReporterProps.options,path = _getReporterProps.path; | |
+ customReporters.forEach((reporter, index) => { | |
+ var _getReporterProps = this._getReporterProps(reporter); | |
+ const options = _getReporterProps.options, path = _getReporterProps.path; | |
try { | |
const Reporter = require(path); | |
this.addReporter(new Reporter(this._globalConfig, options)); | |
} catch (error) { | |
throw new Error( | |
- 'An error occured while adding the reporter at path "' + | |
- path + | |
- '".' + | |
- error.message); | |
- | |
+ 'An error occured while adding the reporter at path "' + | |
+ path + | |
+ '".' + | |
+ error.message | |
+ ); | |
} | |
}); | |
} | |
@@ -354,38 +401,33 @@ class TestRunner { | |
* Get properties of a reporter in an object | |
* to make dealing with them less painful. | |
*/ | |
- _getReporterProps( | |
- reporter) | |
- { | |
+ _getReporterProps(reporter) { | |
if (typeof reporter === 'string') { | |
- return { path: reporter }; | |
- } else if (Array.isArray(reporter)) {var _reporter = _slicedToArray( | |
- reporter, 2);const path = _reporter[0],options = _reporter[1]; | |
- return { options, path }; | |
+ return {path: reporter}; | |
+ } else if (Array.isArray(reporter)) { | |
+ var _reporter = _slicedToArray(reporter, 2); | |
+ const path = _reporter[0], options = _reporter[1]; | |
+ return {options, path}; | |
} | |
throw new Error('Reproter should be either a string or an array'); | |
} | |
- _bailIfNeeded( | |
- contexts, | |
- aggregatedResults, | |
- watcher) | |
- { | |
+ _bailIfNeeded(contexts, aggregatedResults, watcher) { | |
if (this._globalConfig.bail && aggregatedResults.numFailedTests !== 0) { | |
if (watcher.isWatchMode()) { | |
- watcher.setState({ interrupted: true }); | |
+ watcher.setState({interrupted: true}); | |
} else { | |
const exit = () => process.exit(1); | |
- return this._dispatcher. | |
- onRunComplete(contexts, aggregatedResults). | |
- then(exit). | |
- catch(exit); | |
+ return this._dispatcher | |
+ .onRunComplete(contexts, aggregatedResults) | |
+ .then(exit) | |
+ .catch(exit); | |
} | |
} | |
return Promise.resolve(); | |
- }} | |
- | |
+ } | |
+} | |
const createAggregatedResults = numTotalTestSuites => { | |
return { | |
@@ -411,24 +453,22 @@ const createAggregatedResults = numTotalTestSuites => { | |
total: 0, | |
unchecked: 0, | |
unmatched: 0, | |
- updated: 0 }, | |
+ updated: 0, | |
+ }, | |
startTime: Date.now(), | |
success: false, | |
testResults: [], | |
- wasInterrupted: false }; | |
- | |
+ wasInterrupted: false, | |
+ }; | |
}; | |
-const addResult = ( | |
-aggregatedResults, | |
-testResult) => | |
-{ | |
+const addResult = (aggregatedResults, testResult) => { | |
aggregatedResults.testResults.push(testResult); | |
aggregatedResults.numTotalTests += | |
- testResult.numPassingTests + | |
- testResult.numFailingTests + | |
- testResult.numPendingTests; | |
+ testResult.numPassingTests + | |
+ testResult.numFailingTests + | |
+ testResult.numPendingTests; | |
aggregatedResults.numFailedTests += testResult.numFailingTests; | |
aggregatedResults.numPassedTests += testResult.numPassingTests; | |
aggregatedResults.numPendingTests += testResult.numPendingTests; | |
@@ -465,16 +505,13 @@ testResult) => | |
aggregatedResults.snapshot.unmatched += testResult.snapshot.unmatched; | |
aggregatedResults.snapshot.updated += testResult.snapshot.updated; | |
aggregatedResults.snapshot.total += | |
- testResult.snapshot.added + | |
- testResult.snapshot.matched + | |
- testResult.snapshot.unmatched + | |
- testResult.snapshot.updated; | |
+ testResult.snapshot.added + | |
+ testResult.snapshot.matched + | |
+ testResult.snapshot.unmatched + | |
+ testResult.snapshot.updated; | |
}; | |
-const buildFailureTestResult = ( | |
-testPath, | |
-err) => | |
-{ | |
+const buildFailureTestResult = (testPath, err) => { | |
return { | |
console: null, | |
failureMessage: null, | |
@@ -483,7 +520,8 @@ err) => | |
numPendingTests: 0, | |
perfStats: { | |
end: 0, | |
- start: 0 }, | |
+ start: 0, | |
+ }, | |
skipped: false, | |
snapshot: { | |
@@ -492,13 +530,14 @@ err) => | |
matched: 0, | |
unchecked: 0, | |
unmatched: 0, | |
- updated: 0 }, | |
+ updated: 0, | |
+ }, | |
sourceMaps: {}, | |
testExecError: err, | |
testFilePath: testPath, | |
- testResults: [] }; | |
- | |
+ testResults: [], | |
+ }; | |
}; | |
const getEstimatedTime = (timings, workers) => { | |
@@ -507,9 +546,9 @@ const getEstimatedTime = (timings, workers) => { | |
} | |
const max = Math.max.apply(null, timings); | |
- return timings.length <= workers ? | |
- max : | |
- Math.max(timings.reduce((sum, time) => sum + time) / workers, max); | |
+ return timings.length <= workers | |
+ ? max | |
+ : Math.max(timings.reduce((sum, time) => sum + time) / workers, max); | |
}; | |
-module.exports = TestRunner; | |
\ No newline at end of file | |
+module.exports = TestRunner; | |
diff --git i/packages/jest-cli/build/TestSequencer.js w/packages/jest-cli/build/TestSequencer.js | |
index 7a387b86..156d9833 100644 | |
--- i/packages/jest-cli/build/TestSequencer.js | |
+++ w/packages/jest-cli/build/TestSequencer.js | |
@@ -9,42 +9,32 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
const fs = require('fs'); | |
const getCacheFilePath = require('jest-haste-map').getCacheFilePath; | |
const FAIL = 0; | |
const SUCCESS = 1; | |
- | |
- | |
- | |
- | |
class TestSequencer { | |
- | |
- | |
constructor() { | |
this._cache = new Map(); | |
} | |
- _getCachePath(context) {const | |
- config = context.config; | |
+ _getCachePath(context) { | |
+ const config = context.config; | |
return getCacheFilePath(config.cacheDirectory, 'perf-cache-' + config.name); | |
} | |
- _getCache(test) {const | |
- context = test.context; | |
+ _getCache(test) { | |
+ const context = test.context; | |
if (!this._cache.has(context) && context.config.cache) { | |
const cachePath = this._getCachePath(context); | |
if (fs.existsSync(cachePath)) { | |
try { | |
this._cache.set( | |
- context, | |
- JSON.parse(fs.readFileSync(cachePath, 'utf8'))); | |
- | |
+ context, | |
+ JSON.parse(fs.readFileSync(cachePath, 'utf8')) | |
+ ); | |
} catch (e) {} | |
} | |
} | |
@@ -69,12 +59,12 @@ class TestSequencer { | |
sort(tests) { | |
const stats = {}; | |
const fileSize = test => | |
- stats[test.path] || (stats[test.path] = fs.statSync(test.path).size); | |
+ stats[test.path] || (stats[test.path] = fs.statSync(test.path).size); | |
const hasFailed = (cache, test) => | |
- cache[test.path] && cache[test.path][0] === FAIL; | |
+ cache[test.path] && cache[test.path][0] === FAIL; | |
const time = (cache, test) => cache[test.path] && cache[test.path][1]; | |
- tests.forEach(test => test.duration = time(this._getCache(test), test)); | |
+ tests.forEach(test => (test.duration = time(this._getCache(test), test))); | |
return tests.sort((testA, testB) => { | |
const cacheA = this._getCache(testA); | |
const cacheB = this._getCache(testB); | |
@@ -96,22 +86,22 @@ class TestSequencer { | |
cacheResults(tests, results) { | |
const map = Object.create(null); | |
- tests.forEach(test => map[test.path] = test); | |
+ tests.forEach(test => (map[test.path] = test)); | |
results.testResults.forEach(testResult => { | |
if (testResult && map[testResult.testFilePath] && !testResult.skipped) { | |
const cache = this._getCache(map[testResult.testFilePath]); | |
const perf = testResult.perfStats; | |
cache[testResult.testFilePath] = [ | |
- testResult.numFailingTests ? FAIL : SUCCESS, | |
- perf.end - perf.start || 0]; | |
- | |
+ testResult.numFailingTests ? FAIL : SUCCESS, | |
+ perf.end - perf.start || 0, | |
+ ]; | |
} | |
}); | |
this._cache.forEach((cache, context) => | |
- fs.writeFileSync(this._getCachePath(context), JSON.stringify(cache))); | |
- | |
- }} | |
- | |
+ fs.writeFileSync(this._getCachePath(context), JSON.stringify(cache)) | |
+ ); | |
+ } | |
+} | |
-module.exports = TestSequencer; | |
\ No newline at end of file | |
+module.exports = TestSequencer; | |
diff --git i/packages/jest-cli/build/TestWatcher.js w/packages/jest-cli/build/TestWatcher.js | |
index e97b1633..14f770cf 100644 | |
--- i/packages/jest-cli/build/TestWatcher.js | |
+++ w/packages/jest-cli/build/TestWatcher.js | |
@@ -7,21 +7,15 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('events');const EventEmitter = _require.EventEmitter; | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+var _require = require('events'); | |
+const EventEmitter = _require.EventEmitter; | |
class TestWatcher extends EventEmitter { | |
- | |
- | |
- | |
- constructor(_ref) {let isWatchMode = _ref.isWatchMode; | |
+ constructor(_ref) { | |
+ let isWatchMode = _ref.isWatchMode; | |
super(); | |
- this.state = { interrupted: false }; | |
+ this.state = {interrupted: false}; | |
this._isWatchMode = isWatchMode; | |
} | |
@@ -36,7 +30,7 @@ class TestWatcher extends EventEmitter { | |
isWatchMode() { | |
return this._isWatchMode; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = TestWatcher; | |
\ No newline at end of file | |
+module.exports = TestWatcher; | |
diff --git i/packages/jest-cli/build/TestWorker.js w/packages/jest-cli/build/TestWorker.js | |
index 22c388f0..c3ec728b 100644 | |
--- i/packages/jest-cli/build/TestWorker.js | |
+++ w/packages/jest-cli/build/TestWorker.js | |
@@ -9,46 +9,36 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
// Make sure uncaught errors are logged before we exit. | |
process.on('uncaughtException', err => { | |
console.error(err.stack); | |
process.exit(1); | |
-});var _require = | |
- | |
-require('jest-haste-map');const ModuleMap = _require.ModuleMap;var _require2 = | |
-require('jest-message-util');const separateMessageFromStack = _require2.separateMessageFromStack; | |
+}); | |
+var _require = require('jest-haste-map'); | |
+const ModuleMap = _require.ModuleMap; | |
+var _require2 = require('jest-message-util'); | |
+const separateMessageFromStack = _require2.separateMessageFromStack; | |
const Runtime = require('jest-runtime'); | |
const runTest = require('./runTest'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const formatError = error => { | |
- if (typeof error === 'string') {var _separateMessageFromS = | |
- separateMessageFromStack(error);const message = _separateMessageFromS.message,stack = _separateMessageFromS.stack; | |
+ if (typeof error === 'string') { | |
+ var _separateMessageFromS = separateMessageFromStack(error); | |
+ const message = _separateMessageFromS.message, | |
+ stack = _separateMessageFromS.stack; | |
return { | |
message, | |
stack, | |
- type: 'Error' }; | |
- | |
+ type: 'Error', | |
+ }; | |
} | |
return { | |
message: error.message, | |
stack: error.stack, | |
- type: 'Error' }; | |
- | |
+ type: 'Error', | |
+ }; | |
}; | |
const resolvers = Object.create(null); | |
@@ -59,47 +49,48 @@ const getResolver = (config, rawModuleMap) => { | |
// To make this fast and consistent, we pass it from the TestRunner. | |
if (rawModuleMap) { | |
return Runtime.createResolver( | |
- config, | |
- new ModuleMap(rawModuleMap.map, rawModuleMap.mocks)); | |
- | |
+ config, | |
+ new ModuleMap(rawModuleMap.map, rawModuleMap.mocks) | |
+ ); | |
} else { | |
const name = config.name; | |
if (!resolvers[name]) { | |
resolvers[name] = Runtime.createResolver( | |
- config, | |
- Runtime.createHasteMap(config).readModuleMap()); | |
- | |
+ config, | |
+ Runtime.createHasteMap(config).readModuleMap() | |
+ ); | |
} | |
return resolvers[name]; | |
} | |
}; | |
-module.exports = (_ref, | |
- | |
-callback) => | |
-{let config = _ref.config,globalConfig = _ref.globalConfig,path = _ref.path,rawModuleMap = _ref.rawModuleMap; | |
+module.exports = (_ref, callback) => { | |
+ let config = _ref.config, | |
+ globalConfig = _ref.globalConfig, | |
+ path = _ref.path, | |
+ rawModuleMap = _ref.rawModuleMap; | |
let parentExited = false; | |
- const disconnectCallback = () => parentExited = true; | |
+ const disconnectCallback = () => (parentExited = true); | |
const removeListener = () => | |
- process.removeListener('disconnect', disconnectCallback); | |
+ process.removeListener('disconnect', disconnectCallback); | |
process.on('disconnect', disconnectCallback); | |
try { | |
runTest(path, globalConfig, config, getResolver(config, rawModuleMap)).then( | |
- result => { | |
- removeListener(); | |
- if (!parentExited) { | |
- callback(null, result); | |
+ result => { | |
+ removeListener(); | |
+ if (!parentExited) { | |
+ callback(null, result); | |
+ } | |
+ }, | |
+ error => { | |
+ removeListener(); | |
+ if (!parentExited) { | |
+ callback(formatError(error)); | |
+ } | |
} | |
- }, | |
- error => { | |
- removeListener(); | |
- if (!parentExited) { | |
- callback(formatError(error)); | |
- } | |
- }); | |
- | |
+ ); | |
} catch (error) { | |
callback(formatError(error)); | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/cli/args.js w/packages/jest-cli/build/cli/args.js | |
index f7d72fb9..b879dfea 100644 | |
--- i/packages/jest-cli/build/cli/args.js | |
+++ w/packages/jest-cli/build/cli/args.js | |
@@ -10,40 +10,38 @@ | |
'use strict'; | |
- | |
- | |
const isCI = require('is-ci'); | |
const check = argv => { | |
if (argv.runInBand && argv.hasOwnProperty('maxWorkers')) { | |
throw new Error( | |
- 'Both --runInBand and --maxWorkers were specified, but these two ' + | |
- 'options do not make sense together. Which is it?'); | |
- | |
+ 'Both --runInBand and --maxWorkers were specified, but these two ' + | |
+ 'options do not make sense together. Which is it?' | |
+ ); | |
} | |
if (argv.onlyChanged && argv._.length > 0) { | |
throw new Error( | |
- 'Both --onlyChanged and a path pattern were specified, but these ' + | |
- 'two options do not make sense together. Which is it? Do you want ' + | |
- 'to run tests for changed files? Or for a specific set of files?'); | |
- | |
+ 'Both --onlyChanged and a path pattern were specified, but these ' + | |
+ 'two options do not make sense together. Which is it? Do you want ' + | |
+ 'to run tests for changed files? Or for a specific set of files?' | |
+ ); | |
} | |
if (argv.onlyChanged && argv.watchAll) { | |
throw new Error( | |
- 'Both --onlyChanged and --watchAll were specified, but these two ' + | |
- 'options do not make sense together. Try the --watch option which ' + | |
- 'reruns only tests related to changed files.'); | |
- | |
+ 'Both --onlyChanged and --watchAll were specified, but these two ' + | |
+ 'options do not make sense together. Try the --watch option which ' + | |
+ 'reruns only tests related to changed files.' | |
+ ); | |
} | |
if (argv.findRelatedTests && argv._.length === 0) { | |
throw new Error( | |
- 'The --findRelatedTests option requires file paths to be specified.\n' + | |
- 'Example usage: jest --findRelatedTests ./src/source.js ' + | |
- './src/index.js.'); | |
- | |
+ 'The --findRelatedTests option requires file paths to be specified.\n' + | |
+ 'Example usage: jest --findRelatedTests ./src/source.js ' + | |
+ './src/index.js.' | |
+ ); | |
} | |
return true; | |
@@ -56,425 +54,499 @@ const options = { | |
automock: { | |
default: undefined, | |
description: 'Automock all files by default.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
bail: { | |
alias: 'b', | |
default: undefined, | |
description: 'Exit the test suite immediately upon the first failing test.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
browser: { | |
default: undefined, | |
description: 'Respect the "browser" field in package.json ' + | |
- 'when resolving modules. Some packages export different versions ' + | |
- 'based on whether they are operating in node.js or a browser.', | |
- type: 'boolean' }, | |
+ 'when resolving modules. Some packages export different versions ' + | |
+ 'based on whether they are operating in node.js or a browser.', | |
+ type: 'boolean', | |
+ }, | |
cache: { | |
default: undefined, | |
description: 'Whether to use the transform cache. Disable the cache ' + | |
- 'using --no-cache.', | |
- type: 'boolean' }, | |
+ 'using --no-cache.', | |
+ type: 'boolean', | |
+ }, | |
cacheDirectory: { | |
description: 'The directory where Jest should store its cached ' + | |
- ' dependency information.', | |
- type: 'string' }, | |
+ ' dependency information.', | |
+ type: 'string', | |
+ }, | |
ci: { | |
default: isCI, | |
description: 'Whether to run Jest in continuous integration (CI) mode. ' + | |
- 'This option is on by default in most popular CI environments. It will ' + | |
- ' prevent snapshots from being written unless explicitly requested.', | |
- type: 'boolean' }, | |
+ 'This option is on by default in most popular CI environments. It will ' + | |
+ ' prevent snapshots from being written unless explicitly requested.', | |
+ type: 'boolean', | |
+ }, | |
clearMocks: { | |
default: undefined, | |
description: 'Automatically clear mock calls and instances between every ' + | |
- 'test. Equivalent to calling jest.clearAllMocks() between each test.', | |
- type: 'boolean' }, | |
+ 'test. Equivalent to calling jest.clearAllMocks() between each test.', | |
+ type: 'boolean', | |
+ }, | |
collectCoverage: { | |
default: undefined, | |
description: 'Alias for --coverage.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
collectCoverageFrom: { | |
description: 'relative to <rootDir> glob pattern matching the files ' + | |
- 'that coverage info needs to be collected from.', | |
- type: 'string' }, | |
+ 'that coverage info needs to be collected from.', | |
+ type: 'string', | |
+ }, | |
collectCoverageOnlyFrom: { | |
description: 'Explicit list of paths coverage will be restricted to.', | |
- type: 'array' }, | |
+ type: 'array', | |
+ }, | |
color: { | |
default: undefined, | |
description: 'Forces test results output color highlighting (even if ' + | |
- 'stdout is not a TTY). Set to false if you would like to have no colors.', | |
- type: 'boolean' }, | |
+ 'stdout is not a TTY). Set to false if you would like to have no colors.', | |
+ type: 'boolean', | |
+ }, | |
colors: { | |
default: undefined, | |
description: 'Alias for `--color`.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
config: { | |
alias: 'c', | |
description: 'The path to a jest config file specifying how to find ' + | |
- 'and execute tests. If no rootDir is set in the config, the current ' + | |
- 'directory is assumed to be the rootDir for the project. This can also ' + | |
- 'be a JSON encoded value which Jest will use as configuration.', | |
- type: 'string' }, | |
+ 'and execute tests. If no rootDir is set in the config, the current ' + | |
+ 'directory is assumed to be the rootDir for the project. This can also ' + | |
+ 'be a JSON encoded value which Jest will use as configuration.', | |
+ type: 'string', | |
+ }, | |
coverage: { | |
default: undefined, | |
description: 'Indicates that test coverage information should be ' + | |
- 'collected and reported in the output.', | |
- type: 'boolean' }, | |
+ 'collected and reported in the output.', | |
+ type: 'boolean', | |
+ }, | |
coverageDirectory: { | |
description: 'The directory where Jest should output its coverage files.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
coveragePathIgnorePatterns: { | |
description: 'An array of regexp pattern strings that are matched ' + | |
- 'against all file paths before executing the test. If the file path' + | |
- 'matches any of the patterns, coverage information will be skipped.', | |
- type: 'array' }, | |
+ 'against all file paths before executing the test. If the file path' + | |
+ 'matches any of the patterns, coverage information will be skipped.', | |
+ type: 'array', | |
+ }, | |
coverageReporters: { | |
description: 'A list of reporter names that Jest uses when writing ' + | |
- 'coverage reports. Any istanbul reporter can be used.', | |
- type: 'array' }, | |
+ 'coverage reports. Any istanbul reporter can be used.', | |
+ type: 'array', | |
+ }, | |
coverageThreshold: { | |
description: 'A JSON string with which will be used to configure ' + | |
- 'minimum threshold enforcement for coverage results', | |
- type: 'string' }, | |
+ 'minimum threshold enforcement for coverage results', | |
+ type: 'string', | |
+ }, | |
debug: { | |
default: undefined, | |
description: 'Print debugging info about your jest config.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
env: { | |
description: 'The test environment used for all tests. This can point to ' + | |
- 'any file or node module. Examples: `jsdom`, `node` or ' + | |
- '`path/to/my-environment.js`', | |
- type: 'string' }, | |
+ 'any file or node module. Examples: `jsdom`, `node` or ' + | |
+ '`path/to/my-environment.js`', | |
+ type: 'string', | |
+ }, | |
expand: { | |
alias: 'e', | |
default: undefined, | |
description: 'Use this flag to show full diffs instead of a patch.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
findRelatedTests: { | |
default: undefined, | |
description: 'Find related tests for a list of source files that were ' + | |
- 'passed in as arguments. Useful for pre-commit hook integration to run ' + | |
- 'the minimal amount of tests necessary.', | |
- type: 'boolean' }, | |
+ 'passed in as arguments. Useful for pre-commit hook integration to run ' + | |
+ 'the minimal amount of tests necessary.', | |
+ type: 'boolean', | |
+ }, | |
forceExit: { | |
default: undefined, | |
description: 'Force Jest to exit after all tests have completed running. ' + | |
- 'This is useful when resources set up by test code cannot be ' + | |
- 'adequately cleaned up.', | |
- type: 'boolean' }, | |
+ 'This is useful when resources set up by test code cannot be ' + | |
+ 'adequately cleaned up.', | |
+ type: 'boolean', | |
+ }, | |
globals: { | |
description: 'A JSON string with map of global variables that need ' + | |
- 'to be available in all test environments.', | |
- type: 'string' }, | |
+ 'to be available in all test environments.', | |
+ type: 'string', | |
+ }, | |
haste: { | |
description: 'A JSON string with map of variables for the haste ' + | |
- ' module system', | |
- type: 'string' }, | |
+ ' module system', | |
+ type: 'string', | |
+ }, | |
json: { | |
default: undefined, | |
description: 'Prints the test results in JSON. This mode will send all ' + | |
- 'other test output and user messages to stderr.', | |
- type: 'boolean' }, | |
+ 'other test output and user messages to stderr.', | |
+ type: 'boolean', | |
+ }, | |
lastCommit: { | |
default: undefined, | |
description: 'Will run all tests affected by file changes in the last ' + | |
- 'commit made.', | |
- type: 'boolean' }, | |
+ 'commit made.', | |
+ type: 'boolean', | |
+ }, | |
listTests: { | |
default: false, | |
description: 'Lists all tests Jest will run given the arguments and ' + | |
- 'exits. Most useful in a CI system together with `--findRelatedTests` ' + | |
- 'to determine the tests Jest will run based on specific files', | |
- type: 'boolean' }, | |
+ 'exits. Most useful in a CI system together with `--findRelatedTests` ' + | |
+ 'to determine the tests Jest will run based on specific files', | |
+ type: 'boolean', | |
+ }, | |
logHeapUsage: { | |
default: undefined, | |
description: 'Logs the heap usage after every test. Useful to debug ' + | |
- 'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' + | |
- 'node.', | |
- type: 'boolean' }, | |
+ 'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' + | |
+ 'node.', | |
+ type: 'boolean', | |
+ }, | |
mapCoverage: { | |
default: undefined, | |
description: 'Maps code coverage reports against original source code ' + | |
- 'when transformers supply source maps.', | |
- type: 'boolean' }, | |
+ 'when transformers supply source maps.', | |
+ type: 'boolean', | |
+ }, | |
maxWorkers: { | |
alias: 'w', | |
description: 'Specifies the maximum number of workers the worker-pool ' + | |
- 'will spawn for running tests. This defaults to the number of the ' + | |
- 'cores available on your machine. (its usually best not to override ' + | |
- 'this default)', | |
- type: 'number' }, | |
+ 'will spawn for running tests. This defaults to the number of the ' + | |
+ 'cores available on your machine. (its usually best not to override ' + | |
+ 'this default)', | |
+ type: 'number', | |
+ }, | |
moduleDirectories: { | |
description: 'An array of directory names to be searched recursively ' + | |
- "up from the requiring module's location.", | |
- type: 'array' }, | |
+ "up from the requiring module's location.", | |
+ type: 'array', | |
+ }, | |
moduleFileExtensions: { | |
description: 'An array of file extensions your modules use. If you ' + | |
- 'require modules without specifying a file extension, these are the ' + | |
- 'extensions Jest will look for. ', | |
- type: 'array' }, | |
+ 'require modules without specifying a file extension, these are the ' + | |
+ 'extensions Jest will look for. ', | |
+ type: 'array', | |
+ }, | |
moduleNameMapper: { | |
description: 'A JSON string with a map from regular expressions to ' + | |
- 'module names that allow to stub out resources, like images or ' + | |
- 'styles with a single module', | |
- type: 'string' }, | |
+ 'module names that allow to stub out resources, like images or ' + | |
+ 'styles with a single module', | |
+ type: 'string', | |
+ }, | |
modulePathIgnorePatterns: { | |
description: 'An array of regexp pattern strings that are matched ' + | |
- 'against all module paths before those paths are to be considered ' + | |
- '"visible" to the module loader.', | |
- type: 'array' }, | |
+ 'against all module paths before those paths are to be considered ' + | |
+ '"visible" to the module loader.', | |
+ type: 'array', | |
+ }, | |
modulePaths: { | |
description: 'An alternative API to setting the NODE_PATH env variable, ' + | |
- 'modulePaths is an array of absolute paths to additional locations to ' + | |
- 'search when resolving modules.', | |
- type: 'array' }, | |
+ 'modulePaths is an array of absolute paths to additional locations to ' + | |
+ 'search when resolving modules.', | |
+ type: 'array', | |
+ }, | |
noStackTrace: { | |
default: undefined, | |
description: 'Disables stack trace in test results output', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
notify: { | |
default: undefined, | |
description: 'Activates notifications for test results.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
onlyChanged: { | |
alias: 'o', | |
default: undefined, | |
description: 'Attempts to identify which tests to run based on which ' + | |
- "files have changed in the current repository. Only works if you're " + | |
- 'running tests in a git repository at the moment.', | |
- type: 'boolean' }, | |
+ "files have changed in the current repository. Only works if you're " + | |
+ 'running tests in a git repository at the moment.', | |
+ type: 'boolean', | |
+ }, | |
outputFile: { | |
description: 'Write test results to a file when the --json option is ' + | |
- 'also specified.', | |
- type: 'string' }, | |
+ 'also specified.', | |
+ type: 'string', | |
+ }, | |
preset: { | |
description: "A preset that is used as a base for Jest's configuration.", | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
projects: { | |
description: 'A list of projects that use Jest to run all tests of all ' + | |
- 'projects in a single instance of Jest.', | |
- type: 'array' }, | |
+ 'projects in a single instance of Jest.', | |
+ type: 'array', | |
+ }, | |
reporters: { | |
description: 'A list of custom reporters for the test suite.', | |
- type: 'array' }, | |
+ type: 'array', | |
+ }, | |
resetMocks: { | |
default: undefined, | |
description: 'Automatically reset mock state between every test. ' + | |
- 'Equivalent to calling jest.resetAllMocks() between each test.', | |
- type: 'boolean' }, | |
+ 'Equivalent to calling jest.resetAllMocks() between each test.', | |
+ type: 'boolean', | |
+ }, | |
resetModules: { | |
default: undefined, | |
description: 'If enabled, the module registry for every test file will ' + | |
- 'be reset before running each individual test.', | |
- type: 'boolean' }, | |
+ 'be reset before running each individual test.', | |
+ type: 'boolean', | |
+ }, | |
resolver: { | |
description: 'A JSON string which allows the use of a custom resolver.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
rootDir: { | |
description: 'The root directory that Jest should scan for tests and ' + | |
- 'modules within.', | |
- type: 'string' }, | |
+ 'modules within.', | |
+ type: 'string', | |
+ }, | |
roots: { | |
description: 'A list of paths to directories that Jest should use to ' + | |
- 'search for files in.', | |
- type: 'array' }, | |
+ 'search for files in.', | |
+ type: 'array', | |
+ }, | |
runInBand: { | |
alias: 'i', | |
default: undefined, | |
description: 'Run all tests serially in the current process (rather than ' + | |
- 'creating a worker pool of child processes that run tests). This ' + | |
- 'is sometimes useful for debugging, but such use cases are pretty ' + | |
- 'rare.', | |
- type: 'boolean' }, | |
+ 'creating a worker pool of child processes that run tests). This ' + | |
+ 'is sometimes useful for debugging, but such use cases are pretty ' + | |
+ 'rare.', | |
+ type: 'boolean', | |
+ }, | |
setupFiles: { | |
description: 'The paths to modules that run some code to configure or ' + | |
- 'set up the testing environment before each test. ', | |
- type: 'array' }, | |
+ 'set up the testing environment before each test. ', | |
+ type: 'array', | |
+ }, | |
setupTestFrameworkScriptFile: { | |
description: 'The path to a module that runs some code to configure or ' + | |
- 'set up the testing framework before each test.', | |
- type: 'string' }, | |
+ 'set up the testing framework before each test.', | |
+ type: 'string', | |
+ }, | |
showConfig: { | |
default: undefined, | |
description: 'Print your jest config and then exits.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
silent: { | |
default: undefined, | |
description: 'Prevent tests from printing messages through the console.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
snapshotSerializers: { | |
description: 'A list of paths to snapshot serializer modules Jest should ' + | |
- 'use for snapshot testing.', | |
- type: 'array' }, | |
+ 'use for snapshot testing.', | |
+ type: 'array', | |
+ }, | |
testEnvironment: { | |
description: 'Alias for --env', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
testMatch: { | |
description: 'The glob patterns Jest uses to detect test files.', | |
- type: 'array' }, | |
+ type: 'array', | |
+ }, | |
testNamePattern: { | |
alias: 't', | |
description: 'Run only tests with a name that matches the regex pattern.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
testPathIgnorePatterns: { | |
description: 'An array of regexp pattern strings that are matched ' + | |
- 'against all test paths before executing the test. If the test path ' + | |
- 'matches any of the patterns, it will be skipped.', | |
- type: 'array' }, | |
+ 'against all test paths before executing the test. If the test path ' + | |
+ 'matches any of the patterns, it will be skipped.', | |
+ type: 'array', | |
+ }, | |
testPathPattern: { | |
description: 'A regexp pattern string that is matched against all tests ' + | |
- 'paths before executing the test.', | |
- type: 'string' }, | |
+ 'paths before executing the test.', | |
+ type: 'string', | |
+ }, | |
testRegex: { | |
description: 'The regexp pattern Jest uses to detect test files.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
testResultsProcessor: { | |
description: 'Allows the use of a custom results processor. ' + | |
- 'This processor must be a node module that exports ' + | |
- 'a function expecting as the first argument the result object', | |
- type: 'string' }, | |
+ 'This processor must be a node module that exports ' + | |
+ 'a function expecting as the first argument the result object', | |
+ type: 'string', | |
+ }, | |
testRunner: { | |
description: 'Allows to specify a custom test runner. The default is ' + | |
- ' `jasmine2`. A path to a custom test runner can be provided: ' + | |
- '`<rootDir>/path/to/testRunner.js`.', | |
- type: 'string' }, | |
+ ' `jasmine2`. A path to a custom test runner can be provided: ' + | |
+ '`<rootDir>/path/to/testRunner.js`.', | |
+ type: 'string', | |
+ }, | |
testURL: { | |
description: 'This option sets the URL for the jsdom environment.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
timers: { | |
description: 'Setting this value to fake allows the use of fake timers ' + | |
- 'for functions such as setTimeout.', | |
- type: 'string' }, | |
+ 'for functions such as setTimeout.', | |
+ type: 'string', | |
+ }, | |
transform: { | |
description: 'A JSON string which maps from regular expressions to paths ' + | |
- 'to transformers.', | |
- type: 'string' }, | |
+ 'to transformers.', | |
+ type: 'string', | |
+ }, | |
transformIgnorePatterns: { | |
description: 'An array of regexp pattern strings that are matched ' + | |
- 'against all source file paths before transformation.', | |
- type: 'array' }, | |
+ 'against all source file paths before transformation.', | |
+ type: 'array', | |
+ }, | |
unmockedModulePathPatterns: { | |
description: 'An array of regexp pattern strings that are matched ' + | |
- 'against all modules before the module loader will automatically ' + | |
- 'return a mock for them.', | |
- type: 'array' }, | |
+ 'against all modules before the module loader will automatically ' + | |
+ 'return a mock for them.', | |
+ type: 'array', | |
+ }, | |
updateSnapshot: { | |
alias: 'u', | |
default: undefined, | |
description: 'Use this flag to re-record snapshots. ' + | |
- 'Can be used together with a test suite pattern or with ' + | |
- '`--testNamePattern` to re-record snapshot for test matching ' + | |
- 'the pattern', | |
- type: 'boolean' }, | |
+ 'Can be used together with a test suite pattern or with ' + | |
+ '`--testNamePattern` to re-record snapshot for test matching ' + | |
+ 'the pattern', | |
+ type: 'boolean', | |
+ }, | |
useStderr: { | |
default: undefined, | |
description: 'Divert all output to stderr.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
verbose: { | |
default: undefined, | |
description: 'Display individual test results with the test suite ' + | |
- 'hierarchy.', | |
- type: 'boolean' }, | |
+ 'hierarchy.', | |
+ type: 'boolean', | |
+ }, | |
version: { | |
alias: 'v', | |
default: undefined, | |
description: 'Print the version and exit', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
watch: { | |
default: undefined, | |
description: 'Watch files for changes and rerun tests related to ' + | |
- 'changed files. If you want to re-run all tests when a file has ' + | |
- 'changed, use the `--watchAll` option.', | |
- type: 'boolean' }, | |
+ 'changed files. If you want to re-run all tests when a file has ' + | |
+ 'changed, use the `--watchAll` option.', | |
+ type: 'boolean', | |
+ }, | |
watchAll: { | |
default: undefined, | |
description: 'Watch files for changes and rerun all tests. If you want ' + | |
- 'to re-run only the tests related to the changed files, use the ' + | |
- '`--watch` option.', | |
- type: 'boolean' }, | |
+ 'to re-run only the tests related to the changed files, use the ' + | |
+ '`--watch` option.', | |
+ type: 'boolean', | |
+ }, | |
watchman: { | |
default: undefined, | |
description: 'Whether to use watchman for file crawling. Disable using ' + | |
- '--no-watchman.', | |
- type: 'boolean' } }; | |
- | |
- | |
+ '--no-watchman.', | |
+ type: 'boolean', | |
+ }, | |
+}; | |
module.exports = { | |
check, | |
docs, | |
options, | |
- usage }; | |
\ No newline at end of file | |
+ usage, | |
+}; | |
diff --git i/packages/jest-cli/build/cli/getJest.js w/packages/jest-cli/build/cli/getJest.js | |
index 014727e2..2ac8de22 100644 | |
--- i/packages/jest-cli/build/cli/getJest.js | |
+++ w/packages/jest-cli/build/cli/getJest.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const chalk = require('chalk'); | |
const fs = require('graceful-fs'); | |
const path = require('path'); | |
@@ -31,21 +29,21 @@ function getJest(packageRoot) { | |
const dependencies = packageJSON.dependencies; | |
const devDependencies = packageJSON.devDependencies; | |
if ( | |
- dependencies && dependencies['jest-cli'] || | |
- devDependencies && devDependencies['jest-cli']) | |
- { | |
+ (dependencies && dependencies['jest-cli']) || | |
+ (devDependencies && devDependencies['jest-cli']) | |
+ ) { | |
process.on('exit', () => | |
- console.log( | |
- chalk.red( | |
- 'Please run `npm install` to use the version of Jest intended ' + | |
- 'for this project.'))); | |
- | |
- | |
- | |
+ console.log( | |
+ chalk.red( | |
+ 'Please run `npm install` to use the version of Jest intended ' + | |
+ 'for this project.' | |
+ ) | |
+ ) | |
+ ); | |
} | |
} | |
return jest; | |
} | |
} | |
-module.exports = getJest; | |
\ No newline at end of file | |
+module.exports = getJest; | |
diff --git i/packages/jest-cli/build/cli/index.js w/packages/jest-cli/build/cli/index.js | |
index 42f8ce5e..5a464057 100644 | |
--- i/packages/jest-cli/build/cli/index.js | |
+++ w/packages/jest-cli/build/cli/index.js | |
@@ -10,9 +10,6 @@ | |
'use strict'; | |
- | |
- | |
- | |
const args = require('./args'); | |
const getJest = require('./getJest'); | |
const runCLI = require('./runCLI'); | |
@@ -20,13 +17,13 @@ const validateCLIOptions = require('jest-util').validateCLIOptions; | |
const yargs = require('yargs'); | |
function run(argv, project) { | |
- argv = yargs(argv || process.argv.slice(2)). | |
- usage(args.usage). | |
- help(). | |
- alias('help', 'h'). | |
- options(args.options). | |
- epilogue(args.docs). | |
- check(args.check).argv; | |
+ argv = yargs(argv || process.argv.slice(2)) | |
+ .usage(args.usage) | |
+ .help() | |
+ .alias('help', 'h') | |
+ .options(args.options) | |
+ .epilogue(args.docs) | |
+ .check(args.check).argv; | |
validateCLIOptions(argv, args.options); | |
@@ -49,4 +46,4 @@ function run(argv, project) { | |
} | |
exports.run = run; | |
-exports.runCLI = runCLI; | |
\ No newline at end of file | |
+exports.runCLI = runCLI; | |
diff --git i/packages/jest-cli/build/cli/runCLI.js w/packages/jest-cli/build/cli/runCLI.js | |
index 29c558cc..1256e5ce 100644 | |
--- i/packages/jest-cli/build/cli/runCLI.js | |
+++ w/packages/jest-cli/build/cli/runCLI.js | |
@@ -7,17 +7,44 @@ | |
* | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | |
- | |
- | |
- | |
- | |
- | |
-const Runtime = require('jest-runtime');var _require = | |
- | |
-require('jest-util');const Console = _require.Console,clearLine = _require.clearLine;var _require2 = | |
-require('jest-util');const createDirectory = _require2.createDirectory;var _require3 = | |
-require('jest-config');const readConfig = _require3.readConfig; | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
+ | |
+const Runtime = require('jest-runtime'); | |
+var _require = require('jest-util'); | |
+const Console = _require.Console, clearLine = _require.clearLine; | |
+var _require2 = require('jest-util'); | |
+const createDirectory = _require2.createDirectory; | |
+var _require3 = require('jest-config'); | |
+const readConfig = _require3.readConfig; | |
const chalk = require('chalk'); | |
const createContext = require('../lib/createContext'); | |
const getMaxWorkers = require('../lib/getMaxWorkers'); | |
@@ -30,11 +57,8 @@ const watch = require('../watch'); | |
const VERSION = require('../../package.json').version; | |
-module.exports = (() => {var _ref = _asyncToGenerator(function* ( | |
- argv, | |
- projects, | |
- onComplete) | |
- { | |
+module.exports = (() => { | |
+ var _ref = _asyncToGenerator(function*(argv, projects, onComplete) { | |
const realFs = require('fs'); | |
const fs = require('graceful-fs'); | |
fs.gracefulify(realFs); | |
@@ -46,28 +70,49 @@ module.exports = (() => {var _ref = _asyncToGenerator(function* ( | |
return; | |
} | |
- const _run = (() => {var _ref2 = _asyncToGenerator(function* (globalConfig, configs) { | |
+ const _run = (() => { | |
+ var _ref2 = _asyncToGenerator(function*(globalConfig, configs) { | |
const hasteMapInstances = Array(configs.length); | |
const contexts = yield Promise.all( | |
- configs.map((() => {var _ref4 = _asyncToGenerator(function* (_ref3, index) {let config = _ref3.config; | |
- createDirectory(config.cacheDirectory); | |
- const hasteMapInstance = Runtime.createHasteMap(config, { | |
- console: new Console(pipe, pipe), | |
- maxWorkers: getMaxWorkers(argv), | |
- resetCache: !config.cache, | |
- watch: globalConfig.watch, | |
- watchman: globalConfig.watchman }); | |
- | |
- hasteMapInstances[index] = hasteMapInstance; | |
- return createContext(config, (yield hasteMapInstance.build())); | |
- });return function (_x6, _x7) {return _ref4.apply(this, arguments);};})())); | |
- | |
+ configs.map( | |
+ (() => { | |
+ var _ref4 = _asyncToGenerator(function*(_ref3, index) { | |
+ let config = _ref3.config; | |
+ createDirectory(config.cacheDirectory); | |
+ const hasteMapInstance = Runtime.createHasteMap(config, { | |
+ console: new Console(pipe, pipe), | |
+ maxWorkers: getMaxWorkers(argv), | |
+ resetCache: !config.cache, | |
+ watch: globalConfig.watch, | |
+ watchman: globalConfig.watchman, | |
+ }); | |
+ | |
+ hasteMapInstances[index] = hasteMapInstance; | |
+ return createContext(config, yield hasteMapInstance.build()); | |
+ }); | |
+ return function(_x6, _x7) { | |
+ return _ref4.apply(this, arguments); | |
+ }; | |
+ })() | |
+ ) | |
+ ); | |
if (argv.watch || argv.watchAll) { | |
- if (configs.some(function (_ref5) {let hasDeprecationWarnings = _ref5.hasDeprecationWarnings;return hasDeprecationWarnings;})) { | |
+ if ( | |
+ configs.some(function(_ref5) { | |
+ let hasDeprecationWarnings = _ref5.hasDeprecationWarnings; | |
+ return hasDeprecationWarnings; | |
+ }) | |
+ ) { | |
try { | |
yield handleDeprecationWarnings(pipe, process.stdin); | |
- return watch(globalConfig, contexts, argv, pipe, hasteMapInstances); | |
+ return watch( | |
+ globalConfig, | |
+ contexts, | |
+ argv, | |
+ pipe, | |
+ hasteMapInstances | |
+ ); | |
} catch (e) { | |
process.exit(0); | |
} | |
@@ -75,42 +120,49 @@ module.exports = (() => {var _ref = _asyncToGenerator(function* ( | |
return watch(globalConfig, contexts, argv, pipe, hasteMapInstances); | |
} else { | |
- const startRun = function () { | |
+ const startRun = function() { | |
if (!argv.listTests) { | |
preRunMessage.print(pipe); | |
} | |
runJest( | |
- globalConfig, | |
- contexts, | |
- argv, | |
- pipe, | |
- new TestWatcher({ isWatchMode: false }), | |
- startRun, | |
- onComplete); | |
- | |
+ globalConfig, | |
+ contexts, | |
+ argv, | |
+ pipe, | |
+ new TestWatcher({isWatchMode: false}), | |
+ startRun, | |
+ onComplete | |
+ ); | |
}; | |
return startRun(); | |
} | |
- });return function _run(_x4, _x5) {return _ref2.apply(this, arguments);};})(); | |
+ }); | |
+ return function _run(_x4, _x5) { | |
+ return _ref2.apply(this, arguments); | |
+ }; | |
+ })(); | |
try { | |
let globalConfig; | |
let hasDeprecationWarnings; | |
let configs = []; | |
let config; | |
- if (projects.length === 1) {var _readConfig = | |
- readConfig( | |
- argv, | |
- projects[0]);config = _readConfig.config;globalConfig = _readConfig.globalConfig;hasDeprecationWarnings = _readConfig.hasDeprecationWarnings; | |
+ if (projects.length === 1) { | |
+ var _readConfig = readConfig(argv, projects[0]); | |
+ config = _readConfig.config; | |
+ globalConfig = _readConfig.globalConfig; | |
+ hasDeprecationWarnings = _readConfig.hasDeprecationWarnings; | |
- configs = [{ config, globalConfig, hasDeprecationWarnings }]; | |
+ configs = [{config, globalConfig, hasDeprecationWarnings}]; | |
if (globalConfig.projects && globalConfig.projects.length) { | |
projects = globalConfig.projects; | |
} | |
} | |
if (projects.length > 1) { | |
- configs = projects.map(function (root) {return readConfig(argv, root);}); | |
+ configs = projects.map(function(root) { | |
+ return readConfig(argv, root); | |
+ }); | |
// If no config was passed initially, use the one from the first project | |
if (!globalConfig && !config) { | |
globalConfig = configs[0].globalConfig; | |
@@ -137,4 +189,8 @@ module.exports = (() => {var _ref = _asyncToGenerator(function* ( | |
console.error(chalk.red(error.stack)); | |
process.exit(1); | |
} | |
- });return function (_x, _x2, _x3) {return _ref.apply(this, arguments);};})(); | |
\ No newline at end of file | |
+ }); | |
+ return function(_x, _x2, _x3) { | |
+ return _ref.apply(this, arguments); | |
+ }; | |
+})(); | |
diff --git i/packages/jest-cli/build/constants.js w/packages/jest-cli/build/constants.js | |
index e52303b4..f0ac2e66 100644 | |
--- i/packages/jest-cli/build/constants.js | |
+++ w/packages/jest-cli/build/constants.js | |
@@ -32,13 +32,13 @@ const KEYS = { | |
QUESTION_MARK: '3f', | |
T: '74', | |
U: '75', | |
- W: '77' }; | |
- | |
+ W: '77', | |
+}; | |
const ICONS = { | |
failed: isWindows ? '\u00D7' : '\u2715', | |
pending: '\u25CB', | |
- success: isWindows ? '\u221A' : '\u2713' }; | |
- | |
+ success: isWindows ? '\u221A' : '\u2713', | |
+}; | |
-module.exports = { CLEAR, ICONS, KEYS }; | |
\ No newline at end of file | |
+module.exports = {CLEAR, ICONS, KEYS}; | |
diff --git i/packages/jest-cli/build/generateEmptyCoverage.js w/packages/jest-cli/build/generateEmptyCoverage.js | |
index d905e780..7bfb03b2 100644 | |
--- i/packages/jest-cli/build/generateEmptyCoverage.js | |
+++ w/packages/jest-cli/build/generateEmptyCoverage.js | |
@@ -10,40 +10,36 @@ | |
'use strict'; | |
+const IstanbulInstrument = require('istanbul-lib-instrument'); | |
+var _require = require('jest-runtime'); | |
+const ScriptTransformer = _require.ScriptTransformer, | |
+ shouldInstrument = _require.shouldInstrument; | |
- | |
-const IstanbulInstrument = require('istanbul-lib-instrument');var _require = | |
- | |
-require('jest-runtime');const ScriptTransformer = _require.ScriptTransformer,shouldInstrument = _require.shouldInstrument; | |
- | |
-module.exports = function ( | |
-source, | |
-filename, | |
-globalConfig, | |
-config) | |
-{ | |
+module.exports = function(source, filename, globalConfig, config) { | |
const coverageOptions = { | |
collectCoverage: globalConfig.collectCoverage, | |
collectCoverageFrom: globalConfig.collectCoverageFrom, | |
collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, | |
- mapCoverage: globalConfig.mapCoverage }; | |
+ mapCoverage: globalConfig.mapCoverage, | |
+ }; | |
if (shouldInstrument(filename, coverageOptions, config)) { | |
// Transform file without instrumentation first, to make sure produced | |
// source code is ES6 (no flowtypes etc.) and can be instrumented | |
const transformResult = new ScriptTransformer(config).transformSource( | |
- filename, | |
- source, | |
- false, | |
- globalConfig.mapCoverage); | |
+ filename, | |
+ source, | |
+ false, | |
+ globalConfig.mapCoverage | |
+ ); | |
const instrumenter = IstanbulInstrument.createInstrumenter(); | |
instrumenter.instrumentSync(transformResult.code, filename); | |
return { | |
coverage: instrumenter.fileCoverage, | |
- sourceMapPath: transformResult.sourceMapPath }; | |
- | |
+ sourceMapPath: transformResult.sourceMapPath, | |
+ }; | |
} else { | |
return null; | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/jest.js w/packages/jest-cli/build/jest.js | |
index e5cf41a8..bdad8b70 100644 | |
--- i/packages/jest-cli/build/jest.js | |
+++ w/packages/jest-cli/build/jest.js | |
@@ -11,9 +11,9 @@ | |
const SearchSource = require('./SearchSource'); | |
const TestRunner = require('./TestRunner'); | |
-const TestWatcher = require('./TestWatcher');var _require = | |
- | |
-require('./cli');const run = _require.run,runCLI = _require.runCLI; | |
+const TestWatcher = require('./TestWatcher'); | |
+var _require = require('./cli'); | |
+const run = _require.run, runCLI = _require.runCLI; | |
const VERSION = require('../package.json').version; | |
@@ -23,4 +23,5 @@ module.exports = { | |
TestWatcher, | |
getVersion: () => VERSION, | |
run, | |
- runCLI }; | |
\ No newline at end of file | |
+ runCLI, | |
+}; | |
diff --git i/packages/jest-cli/build/lib/BufferedConsole.js w/packages/jest-cli/build/lib/BufferedConsole.js | |
index 135b4c25..e8024c01 100644 | |
--- i/packages/jest-cli/build/lib/BufferedConsole.js | |
+++ w/packages/jest-cli/build/lib/BufferedConsole.js | |
@@ -9,31 +9,22 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
const Console = require('console').Console; | |
const callsites = require('callsites'); | |
const format = require('util').format; | |
class BufferedConsole extends Console { | |
- | |
- | |
constructor() { | |
const buffer = []; | |
- super({ write: message => BufferedConsole.write(buffer, 'log', message) }); | |
+ super({write: message => BufferedConsole.write(buffer, 'log', message)}); | |
this._buffer = buffer; | |
} | |
- static write( | |
- buffer, | |
- type, | |
- message, | |
- level) | |
- { | |
+ static write(buffer, type, message, level) { | |
const call = callsites()[level != null ? level : 2]; | |
const origin = call.getFileName() + ':' + call.getLineNumber(); | |
- buffer.push({ message, origin, type }); | |
+ buffer.push({message, origin, type}); | |
return buffer; | |
} | |
@@ -55,7 +46,7 @@ class BufferedConsole extends Console { | |
getBuffer() { | |
return this._buffer; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = BufferedConsole; | |
\ No newline at end of file | |
+module.exports = BufferedConsole; | |
diff --git i/packages/jest-cli/build/lib/Prompt.js w/packages/jest-cli/build/lib/Prompt.js | |
index f3da06c5..d2089229 100644 | |
--- i/packages/jest-cli/build/lib/Prompt.js | |
+++ w/packages/jest-cli/build/lib/Prompt.js | |
@@ -8,22 +8,11 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('../constants');const KEYS = _require.KEYS; | |
+'use strict'; | |
+var _require = require('../constants'); | |
+const KEYS = _require.KEYS; | |
class Prompt { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor() { | |
this._onResize = this._onResize.bind(this); | |
} | |
@@ -32,11 +21,7 @@ class Prompt { | |
this._onChange(this._value); | |
} | |
- enter( | |
- onChange, | |
- onSuccess, | |
- onCancel) | |
- { | |
+ enter(onChange, onSuccess, onCancel) { | |
this._entering = true; | |
this._value = ''; | |
this._onSuccess = onSuccess; | |
@@ -45,10 +30,10 @@ class Prompt { | |
this._typeaheadOffset = -1; | |
this._typeaheadLength = 0; | |
this._onChange = () => | |
- onChange(this._value, { | |
- max: 10, | |
- offset: this._typeaheadOffset }); | |
- | |
+ onChange(this._value, { | |
+ max: 10, | |
+ offset: this._typeaheadOffset, | |
+ }); | |
this._onChange(); | |
@@ -77,8 +62,9 @@ class Prompt { | |
break; | |
case KEYS.ARROW_DOWN: | |
this._typeaheadOffset = Math.min( | |
- this._typeaheadOffset + 1, | |
- this._typeaheadLength - 1); | |
+ this._typeaheadOffset + 1, | |
+ this._typeaheadLength - 1 | |
+ ); | |
this._onChange(); | |
break; | |
@@ -92,14 +78,14 @@ class Prompt { | |
default: | |
const char = new Buffer(key, 'hex').toString(); | |
- this._value = key === KEYS.BACKSPACE ? | |
- this._value.slice(0, -1) : | |
- this._value + char; | |
+ this._value = key === KEYS.BACKSPACE | |
+ ? this._value.slice(0, -1) | |
+ : this._value + char; | |
this._typeaheadOffset = -1; | |
this._typeaheadSelection = null; | |
this._onChange(); | |
- break;} | |
- | |
+ break; | |
+ } | |
} | |
abort() { | |
@@ -110,7 +96,7 @@ class Prompt { | |
isEntering() { | |
return this._entering; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = Prompt; | |
\ No newline at end of file | |
+module.exports = Prompt; | |
diff --git i/packages/jest-cli/build/lib/colorize.js w/packages/jest-cli/build/lib/colorize.js | |
index bc368111..99302691 100644 | |
--- i/packages/jest-cli/build/lib/colorize.js | |
+++ w/packages/jest-cli/build/lib/colorize.js | |
@@ -13,6 +13,6 @@ | |
const chalk = require('chalk'); | |
module.exports = (str, start, end) => | |
-chalk.dim(str.slice(0, start)) + | |
-chalk.reset(str.slice(start, end)) + | |
-chalk.dim(str.slice(end)); | |
\ No newline at end of file | |
+ chalk.dim(str.slice(0, start)) + | |
+ chalk.reset(str.slice(start, end)) + | |
+ chalk.dim(str.slice(end)); | |
diff --git i/packages/jest-cli/build/lib/createContext.js w/packages/jest-cli/build/lib/createContext.js | |
index 68d25617..c0dfaa11 100644 | |
--- i/packages/jest-cli/build/lib/createContext.js | |
+++ w/packages/jest-cli/build/lib/createContext.js | |
@@ -10,17 +10,14 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
const Runtime = require('jest-runtime'); | |
-module.exports = ( | |
-config, _ref) => {let | |
- hasteFS = _ref.hasteFS,moduleMap = _ref.moduleMap;return ( | |
- { | |
- config, | |
- hasteFS, | |
- moduleMap, | |
- resolver: Runtime.createResolver(config, moduleMap) });}; | |
\ No newline at end of file | |
+module.exports = (config, _ref) => { | |
+ let hasteFS = _ref.hasteFS, moduleMap = _ref.moduleMap; | |
+ return { | |
+ config, | |
+ hasteFS, | |
+ moduleMap, | |
+ resolver: Runtime.createResolver(config, moduleMap), | |
+ }; | |
+}; | |
diff --git i/packages/jest-cli/build/lib/formatTestNameByPattern.js w/packages/jest-cli/build/lib/formatTestNameByPattern.js | |
index 76ac5c7a..1f6be91c 100644 | |
--- i/packages/jest-cli/build/lib/formatTestNameByPattern.js | |
+++ w/packages/jest-cli/build/lib/formatTestNameByPattern.js | |
@@ -46,18 +46,18 @@ module.exports = (testName, pattern, width) => { | |
if (startPatternIndex < slicedTestName.length) { | |
if (endPatternIndex > slicedTestName.length) { | |
return colorize( | |
- slicedTestName + DOTS, | |
- startPatternIndex, | |
- slicedTestName.length + DOTS.length); | |
- | |
+ slicedTestName + DOTS, | |
+ startPatternIndex, | |
+ slicedTestName.length + DOTS.length | |
+ ); | |
} else { | |
return colorize( | |
- slicedTestName + DOTS, | |
- Math.min(startPatternIndex, slicedTestName.length), | |
- endPatternIndex); | |
- | |
+ slicedTestName + DOTS, | |
+ Math.min(startPatternIndex, slicedTestName.length), | |
+ endPatternIndex | |
+ ); | |
} | |
} | |
return `${chalk.dim(slicedTestName)}${chalk.reset(DOTS)}`; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/lib/getMaxWorkers.js w/packages/jest-cli/build/lib/getMaxWorkers.js | |
index 44155f77..e830ceea 100644 | |
--- i/packages/jest-cli/build/lib/getMaxWorkers.js | |
+++ w/packages/jest-cli/build/lib/getMaxWorkers.js | |
@@ -9,8 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
const os = require('os'); | |
const getMaxWorkers = argv => { | |
@@ -24,4 +22,4 @@ const getMaxWorkers = argv => { | |
} | |
}; | |
-module.exports = getMaxWorkers; | |
\ No newline at end of file | |
+module.exports = getMaxWorkers; | |
diff --git i/packages/jest-cli/build/lib/getTestPathPattern.js w/packages/jest-cli/build/lib/getTestPathPattern.js | |
index 710456d8..78492256 100644 | |
--- i/packages/jest-cli/build/lib/getTestPathPattern.js | |
+++ w/packages/jest-cli/build/lib/getTestPathPattern.js | |
@@ -7,31 +7,28 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
-require('jest-util');const clearLine = _require.clearLine; | |
+'use strict'; | |
+var _require = require('jest-util'); | |
+const clearLine = _require.clearLine; | |
const chalk = require('chalk'); | |
const validatePattern = require('./validatePattern'); | |
const DEFAULT_PATTERN_INFO = { | |
input: '', | |
shouldTreatInputAsPattern: false, | |
- testPathPattern: '' }; | |
- | |
+ testPathPattern: '', | |
+}; | |
const showTestPathPatternError = testPathPattern => { | |
clearLine(process.stdout); | |
// eslint-disable-next-line max-len | |
console.log( | |
- chalk.red( | |
- ` Invalid testPattern ${testPathPattern} supplied. ` + | |
- `Running all tests instead.`)); | |
- | |
- | |
+ chalk.red( | |
+ ` Invalid testPattern ${testPathPattern} supplied. ` + | |
+ `Running all tests instead.` | |
+ ) | |
+ ); | |
}; | |
module.exports = argv => { | |
@@ -40,8 +37,8 @@ module.exports = argv => { | |
input: '', | |
lastCommit: argv.lastCommit, | |
onlyChanged: true, | |
- watch: argv.watch }; | |
- | |
+ watch: argv.watch, | |
+ }; | |
} | |
if (argv.testPathPattern) { | |
@@ -49,8 +46,8 @@ module.exports = argv => { | |
return { | |
input: argv.testPathPattern, | |
shouldTreatInputAsPattern: true, | |
- testPathPattern: argv.testPathPattern }; | |
- | |
+ testPathPattern: argv.testPathPattern, | |
+ }; | |
} else { | |
showTestPathPatternError(argv.testPathPattern); | |
} | |
@@ -65,12 +62,12 @@ module.exports = argv => { | |
input: argv._.join(' '), | |
paths: argv._, | |
shouldTreatInputAsPattern: false, | |
- testPathPattern }; | |
- | |
+ testPathPattern, | |
+ }; | |
} else { | |
showTestPathPatternError(testPathPattern); | |
} | |
} | |
return DEFAULT_PATTERN_INFO; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/lib/handleDeprecationWarnings.js w/packages/jest-cli/build/lib/handleDeprecationWarnings.js | |
index 942b3e68..57d7b745 100644 | |
--- i/packages/jest-cli/build/lib/handleDeprecationWarnings.js | |
+++ w/packages/jest-cli/build/lib/handleDeprecationWarnings.js | |
@@ -9,20 +9,21 @@ | |
*/ | |
'use strict'; | |
-const chalk = require('chalk');var _require = | |
-require('../constants');const KEYS = _require.KEYS; | |
+const chalk = require('chalk'); | |
+var _require = require('../constants'); | |
+const KEYS = _require.KEYS; | |
-module.exports = function ( | |
-pipe) | |
- | |
-{let stdin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : process.stdin; | |
+module.exports = function(pipe) { | |
+ let stdin = arguments.length > 1 && arguments[1] !== undefined | |
+ ? arguments[1] | |
+ : process.stdin; | |
return new Promise((resolve, reject) => { | |
if (typeof stdin.setRawMode === 'function') { | |
const messages = [ | |
- chalk.red('There are deprecation warnings.\n'), | |
- chalk.dim(' \u203A Press ') + 'Enter' + chalk.dim(' to continue.'), | |
- chalk.dim(' \u203A Press ') + 'Esc' + chalk.dim(' to exit.')]; | |
- | |
+ chalk.red('There are deprecation warnings.\n'), | |
+ chalk.dim(' \u203A Press ') + 'Enter' + chalk.dim(' to continue.'), | |
+ chalk.dim(' \u203A Press ') + 'Esc' + chalk.dim(' to exit.'), | |
+ ]; | |
pipe.write(messages.join('\n')); | |
@@ -34,8 +35,8 @@ pipe) | |
if (key === KEYS.ENTER) { | |
resolve(); | |
} else if ( | |
- [KEYS.ESCAPE, KEYS.CONTROL_C, KEYS.CONTROL_D].indexOf(key) !== -1) | |
- { | |
+ [KEYS.ESCAPE, KEYS.CONTROL_C, KEYS.CONTROL_D].indexOf(key) !== -1 | |
+ ) { | |
reject(); | |
} | |
}); | |
@@ -43,4 +44,4 @@ pipe) | |
resolve(); | |
} | |
}); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/lib/highlight.js w/packages/jest-cli/build/lib/highlight.js | |
index 90ff7fe9..d270d6a8 100644 | |
--- i/packages/jest-cli/build/lib/highlight.js | |
+++ w/packages/jest-cli/build/lib/highlight.js | |
@@ -17,12 +17,7 @@ const colorize = require('./colorize'); | |
const trim = '...'; | |
const relativePathHead = './'; | |
-const highlight = ( | |
-rawPath, | |
-filePath, | |
-pattern, | |
-rootDir) => | |
-{ | |
+const highlight = (rawPath, filePath, pattern, rootDir) => { | |
let regexp; | |
try { | |
@@ -58,4 +53,4 @@ rootDir) => | |
return colorize(filePath, Math.max(start, 0), Math.max(end, trimLength)); | |
}; | |
-module.exports = highlight; | |
\ No newline at end of file | |
+module.exports = highlight; | |
diff --git i/packages/jest-cli/build/lib/isValidPath.js w/packages/jest-cli/build/lib/isValidPath.js | |
index da1ea639..2bdd1fc2 100644 | |
--- i/packages/jest-cli/build/lib/isValidPath.js | |
+++ w/packages/jest-cli/build/lib/isValidPath.js | |
@@ -9,24 +9,18 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
const path = require('path'); | |
const SNAPSHOT_EXTENSION = 'snap'; | |
-function isValidPath( | |
-globalConfig, | |
-config, | |
-filePath) | |
-{ | |
+function isValidPath(globalConfig, config, filePath) { | |
const coverageDirectory = | |
- globalConfig.coverageDirectory || path.resolve(config.rootDir, 'coverage'); | |
+ globalConfig.coverageDirectory || path.resolve(config.rootDir, 'coverage'); | |
return ( | |
!filePath.includes(coverageDirectory) && | |
- !filePath.endsWith(`.${SNAPSHOT_EXTENSION}`)); | |
- | |
+ !filePath.endsWith(`.${SNAPSHOT_EXTENSION}`) | |
+ ); | |
} | |
-module.exports = isValidPath; | |
\ No newline at end of file | |
+module.exports = isValidPath; | |
diff --git i/packages/jest-cli/build/lib/logDebugMessages.js w/packages/jest-cli/build/lib/logDebugMessages.js | |
index 7703893a..babb0cc7 100644 | |
--- i/packages/jest-cli/build/lib/logDebugMessages.js | |
+++ w/packages/jest-cli/build/lib/logDebugMessages.js | |
@@ -10,25 +10,19 @@ | |
'use strict'; | |
- | |
- | |
- | |
const VERSION = require('../../package.json').version; | |
-const logDebugMessages = ( | |
-globalConfig, | |
-config, | |
-pipe) => | |
-{ | |
+const logDebugMessages = (globalConfig, config, pipe) => { | |
/* $FlowFixMe */ | |
const testFramework = require(config.testRunner); | |
const output = { | |
config, | |
framework: testFramework.name, | |
globalConfig, | |
- version: VERSION }; | |
+ version: VERSION, | |
+ }; | |
pipe.write(JSON.stringify(output, null, ' ') + '\n'); | |
}; | |
-module.exports = logDebugMessages; | |
\ No newline at end of file | |
+module.exports = logDebugMessages; | |
diff --git i/packages/jest-cli/build/lib/patternModeHelpers.js w/packages/jest-cli/build/lib/patternModeHelpers.js | |
index c4f65462..2243c836 100644 | |
--- i/packages/jest-cli/build/lib/patternModeHelpers.js | |
+++ w/packages/jest-cli/build/lib/patternModeHelpers.js | |
@@ -15,27 +15,21 @@ const ansiEscapes = require('ansi-escapes'); | |
const stringLength = require('string-length'); | |
const Prompt = require('./Prompt'); | |
-const pluralize = (count, text) => | |
-count === 1 ? text : text + 's'; | |
+const pluralize = (count, text) => (count === 1 ? text : text + 's'); | |
-const printPatternMatches = function ( | |
-count, | |
-entity, | |
-pipe) | |
- | |
-{let extraText = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ''; | |
+const printPatternMatches = function(count, entity, pipe) { | |
+ let extraText = arguments.length > 3 && arguments[3] !== undefined | |
+ ? arguments[3] | |
+ : ''; | |
const pluralized = pluralize(count, entity); | |
- const result = count ? | |
- `\n\n Pattern matches ${count} ${pluralized}` : | |
- `\n\n Pattern matches no ${pluralized}`; | |
+ const result = count | |
+ ? `\n\n Pattern matches ${count} ${pluralized}` | |
+ : `\n\n Pattern matches no ${pluralized}`; | |
pipe.write(result + extraText); | |
}; | |
-const printPatternCaret = ( | |
-pattern, | |
-pipe) => | |
-{ | |
+const printPatternCaret = (pattern, pipe) => { | |
const inputText = `${chalk.dim(' pattern \u203A')} ${pattern}`; | |
pipe.write(ansiEscapes.eraseDown); | |
@@ -43,49 +37,32 @@ pipe) => | |
pipe.write(ansiEscapes.cursorSavePosition); | |
}; | |
-const printRestoredPatternCaret = ( | |
-pattern, | |
-currentUsageRows, | |
-pipe) => | |
-{ | |
+const printRestoredPatternCaret = (pattern, currentUsageRows, pipe) => { | |
const inputText = `${chalk.dim(' pattern \u203A')} ${pattern}`; | |
pipe.write( | |
- ansiEscapes.cursorTo(stringLength(inputText), currentUsageRows - 1)); | |
+ ansiEscapes.cursorTo(stringLength(inputText), currentUsageRows - 1) | |
+ ); | |
pipe.write(ansiEscapes.cursorRestorePosition); | |
}; | |
-const printStartTyping = ( | |
-entity, | |
-pipe) => | |
-{ | |
+const printStartTyping = (entity, pipe) => { | |
pipe.write( | |
- `\n\n ${chalk.italic.yellow(`Start typing to filter by a ${entity} regex pattern.`)}`); | |
- | |
+ `\n\n ${chalk.italic.yellow(`Start typing to filter by a ${entity} regex pattern.`)}` | |
+ ); | |
}; | |
-const printMore = ( | |
-entity, | |
-pipe, | |
-more) => | |
-{ | |
+const printMore = (entity, pipe, more) => { | |
pipe.write( | |
- `\n ${chalk.dim(`...and ${more} more ${pluralize(more, entity)}`)}`); | |
- | |
+ `\n ${chalk.dim(`...and ${more} more ${pluralize(more, entity)}`)}` | |
+ ); | |
}; | |
-const printTypeaheadItem = ( | |
-item, | |
-pipe) => | |
-pipe.write(`\n ${chalk.dim('\u203A')} ${item}`); | |
+const printTypeaheadItem = (item, pipe) => | |
+ pipe.write(`\n ${chalk.dim('\u203A')} ${item}`); | |
-const formatTypeaheadSelection = ( | |
-item, | |
-index, | |
-activeIndex, | |
-prompt) => | |
-{ | |
+const formatTypeaheadSelection = (item, index, activeIndex, prompt) => { | |
if (index === activeIndex) { | |
prompt.setTypheadheadSelection(chalk.stripColor(item)); | |
return chalk.black.bgYellow(chalk.stripColor(item)); | |
@@ -100,4 +77,5 @@ module.exports = { | |
printPatternMatches, | |
printRestoredPatternCaret, | |
printStartTyping, | |
- printTypeaheadItem }; | |
\ No newline at end of file | |
+ printTypeaheadItem, | |
+}; | |
diff --git i/packages/jest-cli/build/lib/scrollList.js w/packages/jest-cli/build/lib/scrollList.js | |
index c6065dfb..e20c5ae3 100644 | |
--- i/packages/jest-cli/build/lib/scrollList.js | |
+++ w/packages/jest-cli/build/lib/scrollList.js | |
@@ -10,12 +10,8 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
-const scroll = (size, _ref) => {let offset = _ref.offset,max = _ref.max; | |
+const scroll = (size, _ref) => { | |
+ let offset = _ref.offset, max = _ref.max; | |
let start = 0; | |
let index = Math.min(offset, size); | |
@@ -33,8 +29,8 @@ const scroll = (size, _ref) => {let offset = _ref.offset,max = _ref.max; | |
return { | |
end: Math.min(size, start + max), | |
index, | |
- start }; | |
- | |
+ start, | |
+ }; | |
}; | |
-module.exports = scroll; | |
\ No newline at end of file | |
+module.exports = scroll; | |
diff --git i/packages/jest-cli/build/lib/terminalUtils.js w/packages/jest-cli/build/lib/terminalUtils.js | |
index 4c83d54e..43b9a470 100644 | |
--- i/packages/jest-cli/build/lib/terminalUtils.js | |
+++ w/packages/jest-cli/build/lib/terminalUtils.js | |
@@ -14,4 +14,5 @@ | |
const getTerminalWidth = () => process.stdout.columns; | |
module.exports = { | |
- getTerminalWidth }; | |
\ No newline at end of file | |
+ getTerminalWidth, | |
+}; | |
diff --git i/packages/jest-cli/build/lib/updateArgv.js w/packages/jest-cli/build/lib/updateArgv.js | |
index 2369fea4..8c2e6c61 100644 | |
--- i/packages/jest-cli/build/lib/updateArgv.js | |
+++ w/packages/jest-cli/build/lib/updateArgv.js | |
@@ -9,16 +9,8 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
const getTestPathPattern = require('./getTestPathPattern'); | |
- | |
- | |
- | |
- | |
- | |
- | |
module.exports = (argv, mode, options) => { | |
if (mode === 'watch') { | |
argv.watch = true; | |
@@ -43,11 +35,11 @@ module.exports = (argv, mode, options) => { | |
argv.onlyChanged = false; | |
argv.onlyChanged = | |
- getTestPathPattern(argv).input === '' && | |
- !argv.watchAll && | |
- !argv.testNamePattern; | |
+ getTestPathPattern(argv).input === '' && | |
+ !argv.watchAll && | |
+ !argv.testNamePattern; | |
if (options.noSCM) { | |
argv.noSCM = true; | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/lib/validatePattern.js w/packages/jest-cli/build/lib/validatePattern.js | |
index 12b5abbb..6cc3da5d 100644 | |
--- i/packages/jest-cli/build/lib/validatePattern.js | |
+++ w/packages/jest-cli/build/lib/validatePattern.js | |
@@ -22,4 +22,4 @@ const validatePattern = pattern => { | |
return true; | |
}; | |
-module.exports = validatePattern; | |
\ No newline at end of file | |
+module.exports = validatePattern; | |
diff --git i/packages/jest-cli/build/preRunMessage.js w/packages/jest-cli/build/preRunMessage.js | |
index 77f18bca..560ba763 100644 | |
--- i/packages/jest-cli/build/preRunMessage.js | |
+++ w/packages/jest-cli/build/preRunMessage.js | |
@@ -8,9 +8,9 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('jest-util');const clearLine = _require.clearLine; | |
+'use strict'; | |
+var _require = require('jest-util'); | |
+const clearLine = _require.clearLine; | |
const chalk = require('chalk'); | |
const isCI = require('is-ci'); | |
@@ -28,4 +28,5 @@ const remove = stream => { | |
module.exports = { | |
print, | |
- remove }; | |
\ No newline at end of file | |
+ remove, | |
+}; | |
diff --git i/packages/jest-cli/build/reporters/BaseReporter.js w/packages/jest-cli/build/reporters/BaseReporter.js | |
index c4975c7a..54e54540 100644 | |
--- i/packages/jest-cli/build/reporters/BaseReporter.js | |
+++ w/packages/jest-cli/build/reporters/BaseReporter.js | |
@@ -9,16 +9,9 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
const preRunMessage = require('../preRunMessage'); | |
class BaseReporter { | |
- | |
- | |
log(message) { | |
process.stderr.write(message + '\n'); | |
} | |
@@ -31,10 +24,7 @@ class BaseReporter { | |
onTestStart(test) {} | |
- onRunComplete( | |
- contexts, | |
- aggregatedResults) | |
- {} | |
+ onRunComplete(contexts, aggregatedResults) {} | |
_setError(error) { | |
this._error = error; | |
@@ -44,7 +34,7 @@ class BaseReporter { | |
// define whether the test run was successful or failed. | |
getLastError() { | |
return this._error; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = BaseReporter; | |
\ No newline at end of file | |
+module.exports = BaseReporter; | |
diff --git i/packages/jest-cli/build/reporters/CoverageReporter.js w/packages/jest-cli/build/reporters/CoverageReporter.js | |
index 41163965..5f98387d 100644 | |
--- i/packages/jest-cli/build/reporters/CoverageReporter.js | |
+++ w/packages/jest-cli/build/reporters/CoverageReporter.js | |
@@ -7,26 +7,42 @@ | |
* | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-const BaseReporter = require('./BaseReporter');var _require = | |
- | |
-require('jest-util');const clearLine = _require.clearLine;var _require2 = | |
-require('istanbul-api');const createReporter = _require2.createReporter; | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
+ | |
+const BaseReporter = require('./BaseReporter'); | |
+var _require = require('jest-util'); | |
+const clearLine = _require.clearLine; | |
+var _require2 = require('istanbul-api'); | |
+const createReporter = _require2.createReporter; | |
const chalk = require('chalk'); | |
const isCI = require('is-ci'); | |
const istanbulCoverage = require('istanbul-lib-coverage'); | |
@@ -40,11 +56,6 @@ const RUNNING_TEST_COLOR = chalk.bold.dim; | |
const isInteractive = process.stdout.isTTY && !isCI; | |
class CoverageReporter extends BaseReporter { | |
- | |
- | |
- | |
- | |
- | |
constructor(globalConfig, options) { | |
super(globalConfig); | |
this._coverageMap = istanbulCoverage.createCoverageMap({}); | |
@@ -53,11 +64,7 @@ class CoverageReporter extends BaseReporter { | |
this._maxWorkers = options.maxWorkers; | |
} | |
- onTestResult( | |
- test, | |
- testResult, | |
- aggregatedResults) | |
- { | |
+ onTestResult(test, testResult, aggregatedResults) { | |
if (testResult.coverage) { | |
this._coverageMap.merge(testResult.coverage); | |
// Remove coverage data to free up some memory. | |
@@ -65,22 +72,25 @@ class CoverageReporter extends BaseReporter { | |
Object.keys(testResult.sourceMaps).forEach(sourcePath => { | |
this._sourceMapStore.registerURL( | |
- sourcePath, | |
- testResult.sourceMaps[sourcePath]); | |
- | |
+ sourcePath, | |
+ testResult.sourceMaps[sourcePath] | |
+ ); | |
}); | |
} | |
} | |
- onRunComplete( | |
- contexts, | |
- aggregatedResults) | |
- {var _this = this;return _asyncToGenerator(function* () { | |
+ onRunComplete(contexts, aggregatedResults) { | |
+ var _this = this; | |
+ return _asyncToGenerator(function*() { | |
yield _this._addUntestedFiles(_this._globalConfig, contexts); | |
let map = _this._coverageMap; | |
let sourceFinder; | |
- if (_this._globalConfig.mapCoverage) {var _sourceMapStore$trans = | |
- _this._sourceMapStore.transformCoverage(map);map = _sourceMapStore$trans.map;sourceFinder = _sourceMapStore$trans.sourceFinder; | |
+ if (_this._globalConfig.mapCoverage) { | |
+ var _sourceMapStore$trans = _this._sourceMapStore.transformCoverage( | |
+ map | |
+ ); | |
+ map = _sourceMapStore$trans.map; | |
+ sourceFinder = _sourceMapStore$trans.sourceFinder; | |
} | |
const reporter = createReporter(); | |
@@ -91,27 +101,28 @@ class CoverageReporter extends BaseReporter { | |
let coverageReporters = _this._globalConfig.coverageReporters || []; | |
if ( | |
- !_this._globalConfig.useStderr && | |
- coverageReporters.length && | |
- coverageReporters.indexOf('text') === -1) | |
- { | |
+ !_this._globalConfig.useStderr && | |
+ coverageReporters.length && | |
+ coverageReporters.indexOf('text') === -1 | |
+ ) { | |
coverageReporters = coverageReporters.concat(['text-summary']); | |
} | |
reporter.addAll(coverageReporters); | |
- reporter.write(map, sourceFinder && { sourceFinder }); | |
+ reporter.write(map, sourceFinder && {sourceFinder}); | |
aggregatedResults.coverageMap = map; | |
} catch (e) { | |
console.error( | |
- chalk.red(` | |
+ chalk.red(` | |
Failed to write coverage reports: | |
ERROR: ${e.toString()} | |
STACK: ${e.stack} | |
- `)); | |
- | |
+ `) | |
+ ); | |
} | |
- _this._checkThreshold(_this._globalConfig, map);})(); | |
+ _this._checkThreshold(_this._globalConfig, map); | |
+ })(); | |
} | |
_addUntestedFiles(globalConfig, contexts) { | |
@@ -119,17 +130,17 @@ class CoverageReporter extends BaseReporter { | |
contexts.forEach(context => { | |
const config = context.config; | |
if ( | |
- globalConfig.collectCoverageFrom && | |
- globalConfig.collectCoverageFrom.length) | |
- { | |
- context.hasteFS. | |
- matchFilesWithGlob(globalConfig.collectCoverageFrom, config.rootDir). | |
- forEach(filePath => | |
- files.push({ | |
- config, | |
- path: filePath })); | |
- | |
- | |
+ globalConfig.collectCoverageFrom && | |
+ globalConfig.collectCoverageFrom.length | |
+ ) { | |
+ context.hasteFS | |
+ .matchFilesWithGlob(globalConfig.collectCoverageFrom, config.rootDir) | |
+ .forEach(filePath => | |
+ files.push({ | |
+ config, | |
+ path: filePath, | |
+ }) | |
+ ); | |
} | |
}); | |
if (!files.length) { | |
@@ -138,8 +149,8 @@ class CoverageReporter extends BaseReporter { | |
if (isInteractive) { | |
process.stderr.write( | |
- RUNNING_TEST_COLOR('Running coverage on untested files...')); | |
- | |
+ RUNNING_TEST_COLOR('Running coverage on untested files...') | |
+ ); | |
} | |
let worker; | |
@@ -148,13 +159,14 @@ class CoverageReporter extends BaseReporter { | |
worker = pify(require('./CoverageWorker')); | |
} else { | |
farm = workerFarm( | |
- { | |
- autoStart: true, | |
- maxConcurrentCallsPerWorker: 1, | |
- maxConcurrentWorkers: this._maxWorkers, | |
- maxRetries: 2 }, | |
- | |
- require.resolve('./CoverageWorker')); | |
+ { | |
+ autoStart: true, | |
+ maxConcurrentCallsPerWorker: 1, | |
+ maxConcurrentWorkers: this._maxWorkers, | |
+ maxRetries: 2, | |
+ }, | |
+ require.resolve('./CoverageWorker') | |
+ ); | |
worker = pify(farm); | |
} | |
@@ -166,22 +178,22 @@ class CoverageReporter extends BaseReporter { | |
const promise = worker({ | |
config, | |
globalConfig, | |
- path: filename }). | |
- | |
- then(result => { | |
- if (result) { | |
- this._coverageMap.addFileCoverage(result.coverage); | |
- if (result.sourceMapPath) { | |
- this._sourceMapStore.registerURL( | |
- filename, | |
- result.sourceMapPath); | |
- | |
+ path: filename, | |
+ }) | |
+ .then(result => { | |
+ if (result) { | |
+ this._coverageMap.addFileCoverage(result.coverage); | |
+ if (result.sourceMapPath) { | |
+ this._sourceMapStore.registerURL( | |
+ filename, | |
+ result.sourceMapPath | |
+ ); | |
+ } | |
} | |
- } | |
- }). | |
- catch(error => { | |
- console.error(chalk.red(error.message)); | |
- }); | |
+ }) | |
+ .catch(error => { | |
+ console.error(chalk.red(error.message)); | |
+ }); | |
instrumentation.push(promise); | |
} | |
}); | |
@@ -204,11 +216,11 @@ class CoverageReporter extends BaseReporter { | |
function check(name, thresholds, actuals) { | |
return [ | |
- 'statements', | |
- 'branches', | |
- 'lines', | |
- 'functions']. | |
- reduce((errors, key) => { | |
+ 'statements', | |
+ 'branches', | |
+ 'lines', | |
+ 'functions', | |
+ ].reduce((errors, key) => { | |
const actual = actuals[key].pct; | |
const actualUncovered = actuals[key].total - actuals[key].covered; | |
const threshold = thresholds[key]; | |
@@ -217,25 +229,25 @@ class CoverageReporter extends BaseReporter { | |
if (threshold < 0) { | |
if (threshold * -1 < actualUncovered) { | |
errors.push( | |
- `Jest: Uncovered count for ${key} (${actualUncovered})` + | |
- `exceeds ${name} threshold (${-1 * threshold})`); | |
- | |
+ `Jest: Uncovered count for ${key} (${actualUncovered})` + | |
+ `exceeds ${name} threshold (${-1 * threshold})` | |
+ ); | |
} | |
} else if (actual < threshold) { | |
errors.push( | |
- `Jest: Coverage for ${key} (${actual}` + | |
- `%) does not meet ${name} threshold (${threshold}%)`); | |
- | |
+ `Jest: Coverage for ${key} (${actual}` + | |
+ `%) does not meet ${name} threshold (${threshold}%)` | |
+ ); | |
} | |
} | |
return errors; | |
}, []); | |
} | |
const errors = check( | |
- 'global', | |
- globalConfig.coverageThreshold.global, | |
- results); | |
- | |
+ 'global', | |
+ globalConfig.coverageThreshold.global, | |
+ results | |
+ ); | |
if (errors.length > 0) { | |
this.log(`${FAIL_COLOR(errors.join('\n'))}`); | |
@@ -247,7 +259,7 @@ class CoverageReporter extends BaseReporter { | |
// Only exposed for the internal runner. Should not be used | |
getCoverageMap() { | |
return this._coverageMap; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = CoverageReporter; | |
\ No newline at end of file | |
+module.exports = CoverageReporter; | |
diff --git i/packages/jest-cli/build/reporters/CoverageWorker.js w/packages/jest-cli/build/reporters/CoverageWorker.js | |
index 6bb4437a..15c8680d 100644 | |
--- i/packages/jest-cli/build/reporters/CoverageWorker.js | |
+++ w/packages/jest-cli/build/reporters/CoverageWorker.js | |
@@ -9,20 +9,9 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const fs = require('fs'); | |
const generateEmptyCoverage = require('../generateEmptyCoverage'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
function formatCoverageError(error, filename) { | |
const message = ` | |
Failed to collect coverage from ${filename} | |
@@ -33,8 +22,8 @@ function formatCoverageError(error, filename) { | |
return { | |
message, | |
stack: error.stack, | |
- type: 'ERROR' }; | |
- | |
+ type: 'ERROR', | |
+ }; | |
} | |
// Make sure uncaught errors are logged before we exit. | |
@@ -43,10 +32,8 @@ process.on('uncaughtException', err => { | |
process.exit(1); | |
}); | |
-module.exports = (_ref, | |
- | |
-callback) => | |
-{let config = _ref.config,globalConfig = _ref.globalConfig,path = _ref.path; | |
+module.exports = (_ref, callback) => { | |
+ let config = _ref.config, globalConfig = _ref.globalConfig, path = _ref.path; | |
try { | |
const source = fs.readFileSync(path, 'utf8'); | |
const result = generateEmptyCoverage(source, path, globalConfig, config); | |
@@ -54,4 +41,4 @@ callback) => | |
} catch (error) { | |
callback(formatCoverageError(error, path), undefined); | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/reporters/DefaultReporter.js w/packages/jest-cli/build/reporters/DefaultReporter.js | |
index 8948f271..d58138f3 100644 | |
--- i/packages/jest-cli/build/reporters/DefaultReporter.js | |
+++ w/packages/jest-cli/build/reporters/DefaultReporter.js | |
@@ -12,22 +12,15 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
const BaseReporter = require('./BaseReporter'); | |
-const Status = require('./Status');var _require = | |
- | |
-require('jest-util');const clearLine = _require.clearLine; | |
+const Status = require('./Status'); | |
+var _require = require('jest-util'); | |
+const clearLine = _require.clearLine; | |
const chalk = require('chalk'); | |
const getConsoleOutput = require('./getConsoleOutput'); | |
const getResultHeader = require('./getResultHeader'); | |
const isCI = require('is-ci'); | |
- | |
- | |
const TITLE_BULLET = chalk.bold('\u25cf '); | |
const isInteractive = process.stdin.isTTY && !isCI; | |
@@ -35,10 +28,6 @@ const isInteractive = process.stdin.isTTY && !isCI; | |
class DefaultReporter extends BaseReporter { | |
// ANSI clear sequence for the last printed status | |
- | |
- | |
- | |
- | |
constructor(globalConfig) { | |
super(); | |
this._globalConfig = globalConfig; | |
@@ -99,18 +88,16 @@ class DefaultReporter extends BaseReporter { | |
} | |
} | |
- _printStatus() {var _status$get = | |
- this._status.get();const content = _status$get.content,clear = _status$get.clear; | |
+ _printStatus() { | |
+ var _status$get = this._status.get(); | |
+ const content = _status$get.content, clear = _status$get.clear; | |
this._clear = clear; | |
if (isInteractive) { | |
this._out(content); | |
} | |
} | |
- onRunStart( | |
- aggregatedResults, | |
- options) | |
- { | |
+ onRunStart(aggregatedResults, options) { | |
this._status.runStarted(aggregatedResults, options); | |
} | |
@@ -127,50 +114,43 @@ class DefaultReporter extends BaseReporter { | |
clearLine(process.stderr); | |
} | |
- onTestResult( | |
- test, | |
- testResult, | |
- aggregatedResults) | |
- { | |
+ onTestResult(test, testResult, aggregatedResults) { | |
this._status.testFinished( | |
- test.context.config, | |
- testResult, | |
- aggregatedResults); | |
+ test.context.config, | |
+ testResult, | |
+ aggregatedResults | |
+ ); | |
this._printTestFileSummary( | |
- testResult.testFilePath, | |
- test.context.config, | |
- testResult); | |
- | |
+ testResult.testFilePath, | |
+ test.context.config, | |
+ testResult | |
+ ); | |
} | |
- _printTestFileSummary( | |
- testPath, | |
- config, | |
- result) | |
- { | |
+ _printTestFileSummary(testPath, config, result) { | |
if (!result.skipped) { | |
this.log(getResultHeader(result, config)); | |
const consoleBuffer = result.console; | |
if (consoleBuffer && consoleBuffer.length) { | |
this.log( | |
- ' ' + | |
- TITLE_BULLET + | |
- 'Console\n\n' + | |
- getConsoleOutput( | |
- config.rootDir, | |
- !!this._globalConfig.verbose, | |
- consoleBuffer)); | |
- | |
- | |
+ ' ' + | |
+ TITLE_BULLET + | |
+ 'Console\n\n' + | |
+ getConsoleOutput( | |
+ config.rootDir, | |
+ !!this._globalConfig.verbose, | |
+ consoleBuffer | |
+ ) | |
+ ); | |
} | |
if (result.failureMessage) { | |
this.log(result.failureMessage); | |
} | |
} | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = DefaultReporter; | |
\ No newline at end of file | |
+module.exports = DefaultReporter; | |
diff --git i/packages/jest-cli/build/reporters/NotifyReporter.js w/packages/jest-cli/build/reporters/NotifyReporter.js | |
index b3dc22d7..1d6861a3 100644 | |
--- i/packages/jest-cli/build/reporters/NotifyReporter.js | |
+++ w/packages/jest-cli/build/reporters/NotifyReporter.js | |
@@ -9,9 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const BaseReporter = require('./BaseReporter'); | |
const notifier = require('node-notifier'); | |
const path = require('path'); | |
@@ -22,8 +19,6 @@ const isDarwin = process.platform === 'darwin'; | |
const icon = path.resolve(__dirname, '../assets/jest_logo.png'); | |
class NotifyReporter extends BaseReporter { | |
- | |
- | |
constructor(startRun) { | |
super(); | |
this._startRun = startRun; | |
@@ -31,54 +26,55 @@ class NotifyReporter extends BaseReporter { | |
onRunComplete(contexts, result) { | |
const success = | |
- result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0; | |
+ result.numFailedTests === 0 && result.numRuntimeErrorTestSuites === 0; | |
if (success) { | |
const title = util.format('%d%% Passed', 100); | |
const message = util.format( | |
- (isDarwin ? '\u2705 ' : '') + '%d tests passed', | |
- result.numPassedTests); | |
- | |
+ (isDarwin ? '\u2705 ' : '') + '%d tests passed', | |
+ result.numPassedTests | |
+ ); | |
- notifier.notify({ icon, message, title }); | |
+ notifier.notify({icon, message, title}); | |
} else { | |
const failed = result.numFailedTests / result.numTotalTests; | |
const title = util.format( | |
- '%d%% Failed', | |
- Math.ceil(Number.isNaN(failed) ? 0 : failed * 100)); | |
+ '%d%% Failed', | |
+ Math.ceil(Number.isNaN(failed) ? 0 : failed * 100) | |
+ ); | |
const message = util.format( | |
- (isDarwin ? '\u26D4\uFE0F ' : '') + '%d of %d tests failed', | |
- result.numFailedTests, | |
- result.numTotalTests); | |
- | |
+ (isDarwin ? '\u26D4\uFE0F ' : '') + '%d of %d tests failed', | |
+ result.numFailedTests, | |
+ result.numTotalTests | |
+ ); | |
const restartAnswer = 'Run again'; | |
const quitAnswer = 'Exit tests'; | |
notifier.notify( | |
- { | |
- actions: [restartAnswer, quitAnswer], | |
- closeLabel: 'Close', | |
- icon, | |
- message, | |
- title }, | |
- | |
- (err, _, metadata) => { | |
- if (err || !metadata) { | |
- return; | |
- } | |
- if (metadata.activationValue === quitAnswer) { | |
- process.exit(0); | |
- return; | |
- } | |
- if (metadata.activationValue === restartAnswer) { | |
- this._startRun(); | |
+ { | |
+ actions: [restartAnswer, quitAnswer], | |
+ closeLabel: 'Close', | |
+ icon, | |
+ message, | |
+ title, | |
+ }, | |
+ (err, _, metadata) => { | |
+ if (err || !metadata) { | |
+ return; | |
+ } | |
+ if (metadata.activationValue === quitAnswer) { | |
+ process.exit(0); | |
+ return; | |
+ } | |
+ if (metadata.activationValue === restartAnswer) { | |
+ this._startRun(); | |
+ } | |
} | |
- }); | |
- | |
+ ); | |
} | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = NotifyReporter; | |
\ No newline at end of file | |
+module.exports = NotifyReporter; | |
diff --git i/packages/jest-cli/build/reporters/Status.js w/packages/jest-cli/build/reporters/Status.js | |
index 5d2b91bc..f1f0de65 100644 | |
--- i/packages/jest-cli/build/reporters/Status.js | |
+++ w/packages/jest-cli/build/reporters/Status.js | |
@@ -8,13 +8,11 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
-require('./utils');const getSummary = _require.getSummary,trimAndFormatPath = _require.trimAndFormatPath,wrapAnsiString = _require.wrapAnsiString; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const getSummary = _require.getSummary, | |
+ trimAndFormatPath = _require.trimAndFormatPath, | |
+ wrapAnsiString = _require.wrapAnsiString; | |
const chalk = require('chalk'); | |
const RUNNING_TEXT = ' RUNS '; | |
@@ -26,15 +24,13 @@ const RUNNING = chalk.reset.inverse.yellow.bold(RUNNING_TEXT) + ' '; | |
* shifting the whole list. | |
*/ | |
class CurrentTestList { | |
- | |
- | |
constructor() { | |
this._array = []; | |
} | |
add(testPath, config) { | |
const index = this._array.indexOf(null); | |
- const record = { config, testPath }; | |
+ const record = {config, testPath}; | |
if (index !== -1) { | |
this._array[index] = record; | |
} else { | |
@@ -44,15 +40,16 @@ class CurrentTestList { | |
delete(testPath) { | |
const record = this._array.find( | |
- record => record && record.testPath === testPath); | |
+ record => record && record.testPath === testPath | |
+ ); | |
this._array[this._array.indexOf(record || null)] = null; | |
} | |
get() { | |
return this._array; | |
- }} | |
- | |
+ } | |
+} | |
/** | |
* A class that generates the CLI status of currently running tests | |
@@ -60,18 +57,6 @@ class CurrentTestList { | |
* from the terminal. | |
*/ | |
class Status { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor() { | |
this._cache = null; | |
this._currentTests = new CurrentTestList(); | |
@@ -86,11 +71,8 @@ class Status { | |
this._callback = callback; | |
} | |
- runStarted( | |
- aggregatedResults, | |
- options) | |
- { | |
- this._estimatedTime = options && options.estimatedTime || 0; | |
+ runStarted(aggregatedResults, options) { | |
+ this._estimatedTime = (options && options.estimatedTime) || 0; | |
this._showStatus = options && options.showStatus; | |
this._interval = setInterval(() => this._tick(), 1000); | |
this._aggregatedResults = aggregatedResults; | |
@@ -112,12 +94,8 @@ class Status { | |
} | |
} | |
- testFinished( | |
- config, | |
- testResult, | |
- aggregatedResults) | |
- {const | |
- testFilePath = testResult.testFilePath; | |
+ testFinished(config, testResult, aggregatedResults) { | |
+ const testFilePath = testResult.testFilePath; | |
this._aggregatedResults = aggregatedResults; | |
this._currentTests.delete(testFilePath); | |
this._debouncedEmit(); | |
@@ -129,37 +107,37 @@ class Status { | |
} | |
if (this._done) { | |
- return { clear: '', content: '' }; | |
+ return {clear: '', content: ''}; | |
} | |
// $FlowFixMe | |
const width = process.stdout.columns; | |
let content = '\n'; | |
this._currentTests.get().forEach(record => { | |
- if (record) {const | |
- config = record.config,testPath = record.testPath; | |
+ if (record) { | |
+ const config = record.config, testPath = record.testPath; | |
content += | |
- wrapAnsiString( | |
- RUNNING + | |
- trimAndFormatPath( | |
- RUNNING_TEXT.length + 1, | |
- config, | |
- testPath, | |
- width), | |
- | |
- width) + | |
- '\n'; | |
+ wrapAnsiString( | |
+ RUNNING + | |
+ trimAndFormatPath( | |
+ RUNNING_TEXT.length + 1, | |
+ config, | |
+ testPath, | |
+ width | |
+ ), | |
+ width | |
+ ) + '\n'; | |
} | |
}); | |
if (this._showStatus && this._aggregatedResults) { | |
content += | |
- '\n' + | |
- getSummary(this._aggregatedResults, { | |
- estimatedTime: this._estimatedTime, | |
- roundTime: true, | |
- width }); | |
- | |
+ '\n' + | |
+ getSummary(this._aggregatedResults, { | |
+ estimatedTime: this._estimatedTime, | |
+ roundTime: true, | |
+ width, | |
+ }); | |
} | |
let height = 0; | |
@@ -171,7 +149,7 @@ class Status { | |
} | |
const clear = '\r\x1B[K\r\x1B[1A'.repeat(height); | |
- return this._cache = { clear, content }; | |
+ return (this._cache = {clear, content}); | |
} | |
_emit() { | |
@@ -194,7 +172,7 @@ class Status { | |
_tick() { | |
this._debouncedEmit(); | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = Status; | |
\ No newline at end of file | |
+module.exports = Status; | |
diff --git i/packages/jest-cli/build/reporters/SummaryReporter.js w/packages/jest-cli/build/reporters/SummaryReporter.js | |
index dedee816..f148508b 100644 | |
--- i/packages/jest-cli/build/reporters/SummaryReporter.js | |
+++ w/packages/jest-cli/build/reporters/SummaryReporter.js | |
@@ -9,21 +9,9 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-const BaseReporter = require('./BaseReporter');var _require = | |
- | |
-require('./utils');const getSummary = _require.getSummary,pluralize = _require.pluralize; | |
+const BaseReporter = require('./BaseReporter'); | |
+var _require = require('./utils'); | |
+const getSummary = _require.getSummary, pluralize = _require.pluralize; | |
const chalk = require('chalk'); | |
const getResultHeader = require('./getResultHeader'); | |
@@ -37,37 +25,33 @@ const SNAPSHOT_UPDATED = chalk.bold.green; | |
const TEST_SUMMARY_THRESHOLD = 20; | |
const NPM_EVENTS = new Set([ | |
-'prepublish', | |
-'publish', | |
-'postpublish', | |
-'preinstall', | |
-'install', | |
-'postinstall', | |
-'preuninstall', | |
-'uninstall', | |
-'postuninstall', | |
-'preversion', | |
-'version', | |
-'postversion', | |
-'pretest', | |
-'test', | |
-'posttest', | |
-'prestop', | |
-'stop', | |
-'poststop', | |
-'prestart', | |
-'start', | |
-'poststart', | |
-'prerestart', | |
-'restart', | |
-'postrestart']); | |
- | |
+ 'prepublish', | |
+ 'publish', | |
+ 'postpublish', | |
+ 'preinstall', | |
+ 'install', | |
+ 'postinstall', | |
+ 'preuninstall', | |
+ 'uninstall', | |
+ 'postuninstall', | |
+ 'preversion', | |
+ 'version', | |
+ 'postversion', | |
+ 'pretest', | |
+ 'test', | |
+ 'posttest', | |
+ 'prestop', | |
+ 'stop', | |
+ 'poststop', | |
+ 'prestart', | |
+ 'start', | |
+ 'poststart', | |
+ 'prerestart', | |
+ 'restart', | |
+ 'postrestart', | |
+]); | |
class SummaryReporter extends BaseReporter { | |
- | |
- | |
- | |
- | |
constructor(globalConfig, options) { | |
super(globalConfig); | |
this._globalConfig = globalConfig; | |
@@ -86,73 +70,70 @@ class SummaryReporter extends BaseReporter { | |
} | |
} | |
- onRunStart( | |
- aggregatedResults, | |
- options) | |
- { | |
+ onRunStart(aggregatedResults, options) { | |
super.onRunStart(aggregatedResults, options); | |
this._estimatedTime = options.estimatedTime; | |
} | |
- onRunComplete(contexts, aggregatedResults) {const | |
- numTotalTestSuites = aggregatedResults.numTotalTestSuites,testResults = aggregatedResults.testResults,wasInterrupted = aggregatedResults.wasInterrupted; | |
+ onRunComplete(contexts, aggregatedResults) { | |
+ const numTotalTestSuites = aggregatedResults.numTotalTestSuites, | |
+ testResults = aggregatedResults.testResults, | |
+ wasInterrupted = aggregatedResults.wasInterrupted; | |
if (numTotalTestSuites) { | |
const lastResult = testResults[testResults.length - 1]; | |
// Print a newline if the last test did not fail to line up newlines | |
// similar to when an error would have been thrown in the test. | |
if ( | |
- !this._globalConfig.verbose && | |
- lastResult && | |
- !lastResult.numFailingTests && | |
- !lastResult.testExecError) | |
- { | |
+ !this._globalConfig.verbose && | |
+ lastResult && | |
+ !lastResult.numFailingTests && | |
+ !lastResult.testExecError | |
+ ) { | |
this.log(''); | |
} | |
this._printSummary(aggregatedResults, this._globalConfig); | |
this._printSnapshotSummary( | |
- aggregatedResults.snapshot, | |
- this._globalConfig); | |
- | |
+ aggregatedResults.snapshot, | |
+ this._globalConfig | |
+ ); | |
if (numTotalTestSuites) { | |
- const testSummary = wasInterrupted ? | |
- chalk.bold.red('Test run was interrupted.') : | |
- this._getTestSummary( | |
- contexts, | |
- this._options.pattern, | |
- this._options.testNamePattern, | |
- this._options.testPathPattern); | |
+ const testSummary = wasInterrupted | |
+ ? chalk.bold.red('Test run was interrupted.') | |
+ : this._getTestSummary( | |
+ contexts, | |
+ this._options.pattern, | |
+ this._options.testNamePattern, | |
+ this._options.testPathPattern | |
+ ); | |
this.log( | |
- getSummary(aggregatedResults, { | |
- estimatedTime: this._estimatedTime }) + | |
- | |
- '\n' + | |
- testSummary); | |
- | |
+ getSummary(aggregatedResults, { | |
+ estimatedTime: this._estimatedTime, | |
+ }) + | |
+ '\n' + | |
+ testSummary | |
+ ); | |
} | |
} | |
} | |
- _printSnapshotSummary( | |
- snapshots, | |
- globalConfig) | |
- { | |
+ _printSnapshotSummary(snapshots, globalConfig) { | |
if ( | |
- snapshots.added || | |
- snapshots.filesRemoved || | |
- snapshots.unchecked || | |
- snapshots.unmatched || | |
- snapshots.updated) | |
- { | |
+ snapshots.added || | |
+ snapshots.filesRemoved || | |
+ snapshots.unchecked || | |
+ snapshots.unmatched || | |
+ snapshots.updated | |
+ ) { | |
let updateCommand; | |
const event = process.env.npm_lifecycle_event; | |
const prefix = NPM_EVENTS.has(event) ? '' : 'run '; | |
const client = typeof process.env.npm_config_user_agent === 'string' && | |
- process.env.npm_config_user_agent.match('yarn') !== null ? | |
- 'yarn' : | |
- 'npm'; | |
+ process.env.npm_config_user_agent.match('yarn') !== null | |
+ ? 'yarn' | |
+ : 'npm'; | |
if (globalConfig.watch) { | |
updateCommand = 'press `u`'; | |
} else if (event) { | |
@@ -164,119 +145,111 @@ class SummaryReporter extends BaseReporter { | |
this.log(SNAPSHOT_SUMMARY('Snapshot Summary')); | |
if (snapshots.added) { | |
this.log( | |
- SNAPSHOT_ADDED(ARROW + pluralize('snapshot', snapshots.added)) + | |
- ` written in ${pluralize('test suite', snapshots.filesAdded)}.`); | |
- | |
+ SNAPSHOT_ADDED(ARROW + pluralize('snapshot', snapshots.added)) + | |
+ ` written in ${pluralize('test suite', snapshots.filesAdded)}.` | |
+ ); | |
} | |
if (snapshots.unmatched) { | |
this.log( | |
- FAIL_COLOR(ARROW + pluralize('snapshot test', snapshots.unmatched)) + | |
- ` failed in ` + | |
- `${pluralize('test suite', snapshots.filesUnmatched)}. ` + | |
- SNAPSHOT_NOTE( | |
- 'Inspect your code changes or ' + | |
- updateCommand + | |
- ' to update them.')); | |
- | |
- | |
+ FAIL_COLOR(ARROW + pluralize('snapshot test', snapshots.unmatched)) + | |
+ ` failed in ` + | |
+ `${pluralize('test suite', snapshots.filesUnmatched)}. ` + | |
+ SNAPSHOT_NOTE( | |
+ 'Inspect your code changes or ' + | |
+ updateCommand + | |
+ ' to update them.' | |
+ ) | |
+ ); | |
} | |
if (snapshots.updated) { | |
this.log( | |
- SNAPSHOT_UPDATED(ARROW + pluralize('snapshot', snapshots.updated)) + | |
- ` updated in ${pluralize('test suite', snapshots.filesUpdated)}.`); | |
- | |
+ SNAPSHOT_UPDATED(ARROW + pluralize('snapshot', snapshots.updated)) + | |
+ ` updated in ${pluralize('test suite', snapshots.filesUpdated)}.` | |
+ ); | |
} | |
if (snapshots.filesRemoved) { | |
this.log( | |
- SNAPSHOT_REMOVED( | |
- ARROW + pluralize('obsolete snapshot file', snapshots.filesRemoved)) + ( | |
- | |
- snapshots.didUpdate ? | |
- ' removed.' : | |
- ' found, ' + | |
- updateCommand + | |
- ' to remove ' + ( | |
- snapshots.filesRemoved === 1 ? 'it' : 'them.') + | |
- '.')); | |
- | |
+ SNAPSHOT_REMOVED( | |
+ ARROW + pluralize('obsolete snapshot file', snapshots.filesRemoved) | |
+ ) + | |
+ (snapshots.didUpdate | |
+ ? ' removed.' | |
+ : ' found, ' + | |
+ updateCommand + | |
+ ' to remove ' + | |
+ (snapshots.filesRemoved === 1 ? 'it' : 'them.') + | |
+ '.') | |
+ ); | |
} | |
if (snapshots.unchecked) { | |
this.log( | |
- FAIL_COLOR( | |
- ARROW + pluralize('obsolete snapshot', snapshots.unchecked)) + ( | |
- | |
- snapshots.didUpdate ? | |
- ' removed.' : | |
- ' found, ' + | |
- updateCommand + | |
- ' to remove ' + ( | |
- snapshots.filesRemoved === 1 ? 'it' : 'them') + | |
- '.')); | |
- | |
+ FAIL_COLOR( | |
+ ARROW + pluralize('obsolete snapshot', snapshots.unchecked) | |
+ ) + | |
+ (snapshots.didUpdate | |
+ ? ' removed.' | |
+ : ' found, ' + | |
+ updateCommand + | |
+ ' to remove ' + | |
+ (snapshots.filesRemoved === 1 ? 'it' : 'them') + | |
+ '.') | |
+ ); | |
} | |
this.log(''); // print empty line | |
} | |
} | |
- _printSummary( | |
- aggregatedResults, | |
- globalConfig) | |
- { | |
+ _printSummary(aggregatedResults, globalConfig) { | |
// If there were any failing tests and there was a large number of tests | |
// executed, re-print the failing results at the end of execution output. | |
const failedTests = aggregatedResults.numFailedTests; | |
const runtimeErrors = aggregatedResults.numRuntimeErrorTestSuites; | |
if ( | |
- failedTests + runtimeErrors > 0 && | |
- aggregatedResults.numTotalTestSuites > TEST_SUMMARY_THRESHOLD) | |
- { | |
+ failedTests + runtimeErrors > 0 && | |
+ aggregatedResults.numTotalTestSuites > TEST_SUMMARY_THRESHOLD | |
+ ) { | |
this.log(chalk.bold('Summary of all failing tests')); | |
- aggregatedResults.testResults.forEach(testResult => {const | |
- failureMessage = testResult.failureMessage; | |
+ aggregatedResults.testResults.forEach(testResult => { | |
+ const failureMessage = testResult.failureMessage; | |
if (failureMessage) { | |
this._write( | |
- getResultHeader(testResult, globalConfig) + | |
- '\n' + | |
- failureMessage + | |
- '\n'); | |
- | |
+ getResultHeader(testResult, globalConfig) + | |
+ '\n' + | |
+ failureMessage + | |
+ '\n' | |
+ ); | |
} | |
}); | |
this.log(''); // print empty line | |
} | |
} | |
- _getTestSummary( | |
- contexts, | |
- pattern, | |
- testNamePattern, | |
- testPathPattern) | |
- { | |
- const testInfo = pattern.onlyChanged ? | |
- chalk.dim(' related to changed files') : | |
- pattern.input !== '' ? chalk.dim(' matching ') + testPathPattern : ''; | |
+ _getTestSummary(contexts, pattern, testNamePattern, testPathPattern) { | |
+ const testInfo = pattern.onlyChanged | |
+ ? chalk.dim(' related to changed files') | |
+ : pattern.input !== '' ? chalk.dim(' matching ') + testPathPattern : ''; | |
- const nameInfo = testNamePattern ? | |
- chalk.dim(' with tests matching ') + `"${testNamePattern}"` : | |
- ''; | |
+ const nameInfo = testNamePattern | |
+ ? chalk.dim(' with tests matching ') + `"${testNamePattern}"` | |
+ : ''; | |
- const contextInfo = contexts.size > 1 ? | |
- chalk.dim(' in ') + contexts.size + chalk.dim(' projects') : | |
- ''; | |
+ const contextInfo = contexts.size > 1 | |
+ ? chalk.dim(' in ') + contexts.size + chalk.dim(' projects') | |
+ : ''; | |
return ( | |
chalk.dim('Ran all test suites') + | |
testInfo + | |
nameInfo + | |
contextInfo + | |
- chalk.dim('.')); | |
- | |
- }} | |
- | |
+ chalk.dim('.') | |
+ ); | |
+ } | |
+} | |
-module.exports = SummaryReporter; | |
\ No newline at end of file | |
+module.exports = SummaryReporter; | |
diff --git i/packages/jest-cli/build/reporters/VerboseReporter.js w/packages/jest-cli/build/reporters/VerboseReporter.js | |
index 4ccf3bee..cb918a54 100644 | |
--- i/packages/jest-cli/build/reporters/VerboseReporter.js | |
+++ w/packages/jest-cli/build/reporters/VerboseReporter.js | |
@@ -9,33 +9,26 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const DefaultReporter = require('./DefaultReporter'); | |
-const chalk = require('chalk');var _require = | |
-require('../constants');const ICONS = _require.ICONS; | |
+const chalk = require('chalk'); | |
+var _require = require('../constants'); | |
+const ICONS = _require.ICONS; | |
class VerboseReporter extends DefaultReporter { | |
- | |
- | |
constructor(globalConfig) { | |
super(globalConfig); | |
this._globalConfig = globalConfig; | |
} | |
static filterTestResults(testResults) { | |
- return testResults.filter((_ref) => {let status = _ref.status;return status !== 'pending';}); | |
+ return testResults.filter(_ref => { | |
+ let status = _ref.status; | |
+ return status !== 'pending'; | |
+ }); | |
} | |
static groupTestsBySuites(testResults) { | |
- const root = { suites: [], tests: [], title: '' }; | |
+ const root = {suites: [], tests: [], title: ''}; | |
testResults.forEach(testResult => { | |
let targetSuite = root; | |
@@ -44,7 +37,7 @@ class VerboseReporter extends DefaultReporter { | |
for (const title of testResult.ancestorTitles) { | |
let matchingSuite = targetSuite.suites.find(s => s.title === title); | |
if (!matchingSuite) { | |
- matchingSuite = { suites: [], tests: [], title }; | |
+ matchingSuite = {suites: [], tests: [], title}; | |
targetSuite.suites.push(matchingSuite); | |
} | |
targetSuite = matchingSuite; | |
@@ -55,11 +48,7 @@ class VerboseReporter extends DefaultReporter { | |
return root; | |
} | |
- onTestResult( | |
- test, | |
- result, | |
- aggregatedResults) | |
- { | |
+ onTestResult(test, result, aggregatedResults) { | |
super.onTestResult(test, result, aggregatedResults); | |
if (!result.testExecError && !result.skipped) { | |
this._logTestResults(result.testResults); | |
@@ -127,7 +116,7 @@ class VerboseReporter extends DefaultReporter { | |
_logLine(str, indentLevel) { | |
const indentation = ' '.repeat(indentLevel || 0); | |
this.log(indentation + (str || '')); | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = VerboseReporter; | |
\ No newline at end of file | |
+module.exports = VerboseReporter; | |
diff --git i/packages/jest-cli/build/reporters/getConsoleOutput.js w/packages/jest-cli/build/reporters/getConsoleOutput.js | |
index 243ed2e9..1a5034c7 100644 | |
--- i/packages/jest-cli/build/reporters/getConsoleOutput.js | |
+++ w/packages/jest-cli/build/reporters/getConsoleOutput.js | |
@@ -9,8 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
const chalk = require('chalk'); | |
const path = require('path'); | |
@@ -18,7 +16,8 @@ module.exports = (root, verbose, buffer) => { | |
const TITLE_INDENT = verbose ? ' ' : ' '; | |
const CONSOLE_INDENT = TITLE_INDENT + ' '; | |
- return buffer.reduce((output, _ref) => {let type = _ref.type,message = _ref.message,origin = _ref.origin; | |
+ return buffer.reduce((output, _ref) => { | |
+ let type = _ref.type, message = _ref.message, origin = _ref.origin; | |
origin = path.relative(root, origin); | |
message = message.split(/\n/).map(line => CONSOLE_INDENT + line).join('\n'); | |
@@ -39,7 +38,7 @@ module.exports = (root, verbose, buffer) => { | |
chalk.dim(origin) + | |
'\n' + | |
message + | |
- '\n'); | |
- | |
+ '\n' | |
+ ); | |
}, ''); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-cli/build/reporters/getResultHeader.js w/packages/jest-cli/build/reporters/getResultHeader.js | |
index a923eac6..011a78d9 100644 | |
--- i/packages/jest-cli/build/reporters/getResultHeader.js | |
+++ w/packages/jest-cli/build/reporters/getResultHeader.js | |
@@ -7,12 +7,9 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
-require('./utils');const formatTestPath = _require.formatTestPath; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const formatTestPath = _require.formatTestPath; | |
const chalk = require('chalk'); | |
const LONG_TEST_COLOR = chalk.reset.bold.bgRed; | |
@@ -23,13 +20,13 @@ const PASS = chalk.reset.inverse.bold.green(' PASS '); | |
module.exports = (result, config) => { | |
const testPath = result.testFilePath; | |
- const status = result.numFailingTests > 0 || result.testExecError ? | |
- FAIL : | |
- PASS; | |
+ const status = result.numFailingTests > 0 || result.testExecError | |
+ ? FAIL | |
+ : PASS; | |
- const runTime = result.perfStats ? | |
- (result.perfStats.end - result.perfStats.start) / 1000 : | |
- null; | |
+ const runTime = result.perfStats | |
+ ? (result.perfStats.end - result.perfStats.start) / 1000 | |
+ : null; | |
const testDetail = []; | |
if (runTime !== null && runTime > 5) { | |
@@ -42,7 +39,7 @@ module.exports = (result, config) => { | |
} | |
return ( | |
- `${status} ${formatTestPath(config, testPath)}` + ( | |
- testDetail.length ? ` (${testDetail.join(', ')})` : '')); | |
- | |
-}; | |
\ No newline at end of file | |
+ `${status} ${formatTestPath(config, testPath)}` + | |
+ (testDetail.length ? ` (${testDetail.join(', ')})` : '') | |
+ ); | |
+}; | |
diff --git i/packages/jest-cli/build/reporters/utils.js w/packages/jest-cli/build/reporters/utils.js | |
index 5f188ae6..c45c39d2 100644 | |
--- i/packages/jest-cli/build/reporters/utils.js | |
+++ w/packages/jest-cli/build/reporters/utils.js | |
@@ -8,33 +8,58 @@ | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | |
- | |
- | |
- | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
const chalk = require('chalk'); | |
const path = require('path'); | |
const slash = require('slash'); | |
- | |
- | |
- | |
- | |
- | |
- | |
const PROGRESS_BAR_WIDTH = 40; | |
-const trimAndFormatPath = ( | |
-pad, | |
-config, | |
-testPath, | |
-columns) => | |
-{ | |
+const trimAndFormatPath = (pad, config, testPath, columns) => { | |
const maxLength = columns - pad; | |
- const relative = relativePath(config, testPath);const | |
- basename = relative.basename;let | |
- dirname = relative.dirname; | |
+ const relative = relativePath(config, testPath); | |
+ const basename = relative.basename; | |
+ let dirname = relative.dirname; | |
// length is ok | |
if ((dirname + path.sep + basename).length <= maxLength) { | |
@@ -46,7 +71,7 @@ columns) => | |
if (basenameLength + 4 < maxLength) { | |
const dirnameLength = maxLength - 4 - basenameLength; | |
dirname = | |
- '...' + dirname.slice(dirname.length - dirnameLength, dirname.length); | |
+ '...' + dirname.slice(dirname.length - dirnameLength, dirname.length); | |
return slash(chalk.dim(dirname + path.sep) + chalk.bold(basename)); | |
} | |
@@ -56,14 +81,15 @@ columns) => | |
// can't fit dirname, but can fit trimmed basename | |
return slash( | |
- chalk.bold( | |
- '...' + basename.slice(basename.length - maxLength - 4, basename.length))); | |
- | |
- | |
+ chalk.bold( | |
+ '...' + basename.slice(basename.length - maxLength - 4, basename.length) | |
+ ) | |
+ ); | |
}; | |
-const formatTestPath = (config, testPath) => {var _relativePath = | |
- relativePath(config, testPath);const dirname = _relativePath.dirname,basename = _relativePath.basename; | |
+const formatTestPath = (config, testPath) => { | |
+ var _relativePath = relativePath(config, testPath); | |
+ const dirname = _relativePath.dirname, basename = _relativePath.basename; | |
return chalk.dim(dirname + path.sep) + chalk.bold(basename); | |
}; | |
@@ -71,22 +97,18 @@ const relativePath = (config, testPath) => { | |
testPath = path.relative(config.rootDir, testPath); | |
const dirname = path.dirname(testPath); | |
const basename = path.basename(testPath); | |
- return { basename, dirname }; | |
+ return {basename, dirname}; | |
}; | |
-const pluralize = (word, count) => | |
-`${count} ${word}${count === 1 ? '' : 's'}`; | |
+const pluralize = (word, count) => `${count} ${word}${count === 1 ? '' : 's'}`; | |
-const getSummary = ( | |
-aggregatedResults, | |
-options) => | |
-{ | |
+const getSummary = (aggregatedResults, options) => { | |
let runTime = (Date.now() - aggregatedResults.startTime) / 1000; | |
if (options && options.roundTime) { | |
runTime = Math.floor(runTime); | |
} | |
- const estimatedTime = options && options.estimatedTime || 0; | |
+ const estimatedTime = (options && options.estimatedTime) || 0; | |
const snapshotResults = aggregatedResults.snapshot; | |
const snapshotsAdded = snapshotResults.added; | |
const snapshotsFailed = snapshotResults.unmatched; | |
@@ -102,40 +124,40 @@ options) => | |
const testsPassed = aggregatedResults.numPassedTests; | |
const testsPending = aggregatedResults.numPendingTests; | |
const testsTotal = aggregatedResults.numTotalTests; | |
- const width = options && options.width || 0; | |
+ const width = (options && options.width) || 0; | |
const suites = | |
- chalk.bold('Test Suites: ') + ( | |
- suitesFailed ? chalk.bold.red(`${suitesFailed} failed`) + ', ' : '') + ( | |
- suitesPending ? | |
- chalk.bold.yellow(`${suitesPending} skipped`) + ', ' : | |
- '') + ( | |
- suitesPassed ? chalk.bold.green(`${suitesPassed} passed`) + ', ' : '') + ( | |
- suitesRun !== suitesTotal ? | |
- suitesRun + ' of ' + suitesTotal : | |
- suitesTotal) + | |
- ` total`; | |
+ chalk.bold('Test Suites: ') + | |
+ (suitesFailed ? chalk.bold.red(`${suitesFailed} failed`) + ', ' : '') + | |
+ (suitesPending | |
+ ? chalk.bold.yellow(`${suitesPending} skipped`) + ', ' | |
+ : '') + | |
+ (suitesPassed ? chalk.bold.green(`${suitesPassed} passed`) + ', ' : '') + | |
+ (suitesRun !== suitesTotal | |
+ ? suitesRun + ' of ' + suitesTotal | |
+ : suitesTotal) + | |
+ ` total`; | |
const tests = | |
- chalk.bold('Tests: ') + ( | |
- testsFailed ? chalk.bold.red(`${testsFailed} failed`) + ', ' : '') + ( | |
- testsPending ? chalk.bold.yellow(`${testsPending} skipped`) + ', ' : '') + ( | |
- testsPassed ? chalk.bold.green(`${testsPassed} passed`) + ', ' : '') + | |
- `${testsTotal} total`; | |
+ chalk.bold('Tests: ') + | |
+ (testsFailed ? chalk.bold.red(`${testsFailed} failed`) + ', ' : '') + | |
+ (testsPending ? chalk.bold.yellow(`${testsPending} skipped`) + ', ' : '') + | |
+ (testsPassed ? chalk.bold.green(`${testsPassed} passed`) + ', ' : '') + | |
+ `${testsTotal} total`; | |
const snapshots = | |
- chalk.bold('Snapshots: ') + ( | |
- snapshotsFailed ? | |
- chalk.bold.red(`${snapshotsFailed} failed`) + ', ' : | |
- '') + ( | |
- snapshotsUpdated ? | |
- chalk.bold.green(`${snapshotsUpdated} updated`) + ', ' : | |
- '') + ( | |
- snapshotsAdded ? chalk.bold.green(`${snapshotsAdded} added`) + ', ' : '') + ( | |
- snapshotsPassed ? | |
- chalk.bold.green(`${snapshotsPassed} passed`) + ', ' : | |
- '') + | |
- `${snapshotsTotal} total`; | |
+ chalk.bold('Snapshots: ') + | |
+ (snapshotsFailed | |
+ ? chalk.bold.red(`${snapshotsFailed} failed`) + ', ' | |
+ : '') + | |
+ (snapshotsUpdated | |
+ ? chalk.bold.green(`${snapshotsUpdated} updated`) + ', ' | |
+ : '') + | |
+ (snapshotsAdded ? chalk.bold.green(`${snapshotsAdded} added`) + ', ' : '') + | |
+ (snapshotsPassed | |
+ ? chalk.bold.green(`${snapshotsPassed} passed`) + ', ' | |
+ : '') + | |
+ `${snapshotsTotal} total`; | |
const time = renderTime(runTime, estimatedTime, width); | |
return [suites, tests, snapshots, time].join('\n'); | |
@@ -143,9 +165,9 @@ options) => | |
const renderTime = (runTime, estimatedTime, width) => { | |
// If we are more than one second over the estimated time, highlight it. | |
- const renderedTime = estimatedTime && runTime >= estimatedTime + 1 ? | |
- chalk.bold.yellow(runTime + 's') : | |
- runTime + 's'; | |
+ const renderedTime = estimatedTime && runTime >= estimatedTime + 1 | |
+ ? chalk.bold.yellow(runTime + 's') | |
+ : runTime + 's'; | |
let time = chalk.bold(`Time:`) + ` ${renderedTime}`; | |
if (runTime < estimatedTime) { | |
time += `, estimated ${estimatedTime}s`; | |
@@ -156,14 +178,15 @@ const renderTime = (runTime, estimatedTime, width) => { | |
if (estimatedTime > 2 && runTime < estimatedTime && width) { | |
const availableWidth = Math.min(PROGRESS_BAR_WIDTH, width); | |
const length = Math.min( | |
- Math.floor(runTime / estimatedTime * availableWidth), | |
- availableWidth); | |
+ Math.floor(runTime / estimatedTime * availableWidth), | |
+ availableWidth | |
+ ); | |
if (availableWidth >= 2) { | |
time += | |
- '\n' + | |
- chalk.green.inverse(' ').repeat(length) + | |
- chalk.white.inverse(' ').repeat(availableWidth - length); | |
+ '\n' + | |
+ chalk.green.inverse(' ').repeat(length) + | |
+ chalk.white.inverse(' ').repeat(availableWidth - length); | |
} | |
} | |
return time; | |
@@ -182,7 +205,7 @@ const wrapAnsiString = (string, terminalWidth) => { | |
let lastIndex = 0; | |
let match; | |
- while (match = ANSI_REGEXP.exec(string)) { | |
+ while ((match = ANSI_REGEXP.exec(string))) { | |
const ansi = match[0]; | |
const index = match['index']; | |
if (index != lastIndex) { | |
@@ -198,38 +221,41 @@ const wrapAnsiString = (string, terminalWidth) => { | |
let lastLineLength = 0; | |
- return tokens. | |
- reduce( | |
- (lines, _ref) => {var _ref2 = _slicedToArray(_ref, 2);let kind = _ref2[0],token = _ref2[1]; | |
- if (kind === 'string') { | |
- if (lastLineLength + token.length > terminalWidth) { | |
- while (token.length) { | |
- const chunk = token.slice(0, terminalWidth - lastLineLength); | |
- const remaining = token.slice( | |
- terminalWidth - lastLineLength, | |
- token.length); | |
- | |
- lines[lines.length - 1] += chunk; | |
- lastLineLength += chunk.length; | |
- token = remaining; | |
- if (token.length) { | |
- lines.push(''); | |
- lastLineLength = 0; | |
+ return tokens | |
+ .reduce( | |
+ (lines, _ref) => { | |
+ var _ref2 = _slicedToArray(_ref, 2); | |
+ let kind = _ref2[0], token = _ref2[1]; | |
+ if (kind === 'string') { | |
+ if (lastLineLength + token.length > terminalWidth) { | |
+ while (token.length) { | |
+ const chunk = token.slice(0, terminalWidth - lastLineLength); | |
+ const remaining = token.slice( | |
+ terminalWidth - lastLineLength, | |
+ token.length | |
+ ); | |
+ | |
+ lines[lines.length - 1] += chunk; | |
+ lastLineLength += chunk.length; | |
+ token = remaining; | |
+ if (token.length) { | |
+ lines.push(''); | |
+ lastLineLength = 0; | |
+ } | |
+ } | |
+ } else { | |
+ lines[lines.length - 1] += token; | |
+ lastLineLength += token.length; | |
} | |
+ } else { | |
+ lines[lines.length - 1] += token; | |
} | |
- } else { | |
- lines[lines.length - 1] += token; | |
- lastLineLength += token.length; | |
- } | |
- } else { | |
- lines[lines.length - 1] += token; | |
- } | |
- return lines; | |
- }, | |
- ['']). | |
- | |
- join('\n'); | |
+ return lines; | |
+ }, | |
+ [''] | |
+ ) | |
+ .join('\n'); | |
}; | |
module.exports = { | |
@@ -238,4 +264,5 @@ module.exports = { | |
pluralize, | |
relativePath, | |
trimAndFormatPath, | |
- wrapAnsiString }; | |
\ No newline at end of file | |
+ wrapAnsiString, | |
+}; | |
diff --git i/packages/jest-cli/build/runJest.js w/packages/jest-cli/build/runJest.js | |
index 25577a97..f61d1894 100644 | |
--- i/packages/jest-cli/build/runJest.js | |
+++ w/packages/jest-cli/build/runJest.js | |
@@ -7,14 +7,39 @@ | |
* | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};}var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-util');const Console = _require.Console,formatTestResults = _require.formatTestResults; | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
+var _require = require('jest-util'); | |
+const Console = _require.Console, | |
+ formatTestResults = _require.formatTestResults; | |
const chalk = require('chalk'); | |
const fs = require('graceful-fs'); | |
const getMaxWorkers = require('./lib/getMaxWorkers'); | |
@@ -26,20 +51,20 @@ const TestRunner = require('./TestRunner'); | |
const TestSequencer = require('./TestSequencer'); | |
const setConfig = (contexts, newConfig) => | |
-contexts.forEach( | |
-context => | |
-context.config = Object.freeze( | |
-Object.assign({}, context.config, newConfig))); | |
- | |
- | |
+ contexts.forEach( | |
+ context => | |
+ (context.config = Object.freeze( | |
+ Object.assign({}, context.config, newConfig) | |
+ )) | |
+ ); | |
const formatTestPathPattern = pattern => { | |
const testPattern = pattern.testPathPattern; | |
const input = pattern.input; | |
const formattedPattern = `/${testPattern || ''}/`; | |
- const formattedInput = pattern.shouldTreatInputAsPattern ? | |
- `/${input || ''}/` : | |
- `"${input || ''}"`; | |
+ const formattedInput = pattern.shouldTreatInputAsPattern | |
+ ? `/${input || ''}/` | |
+ : `"${input || ''}"`; | |
return input === testPattern ? formattedInput : formattedPattern; | |
}; | |
@@ -47,79 +72,90 @@ const getNoTestsFoundMessage = (testRunData, pattern) => { | |
if (pattern.onlyChanged) { | |
return ( | |
chalk.bold( | |
- 'No tests found related to files changed since last commit.\n') + | |
- | |
+ 'No tests found related to files changed since last commit.\n' | |
+ ) + | |
chalk.dim( | |
- pattern.watch ? | |
- 'Press `a` to run all tests, or run Jest with `--watchAll`.' : | |
- 'Run Jest without `-o` to run all tests.')); | |
- | |
- | |
+ pattern.watch | |
+ ? 'Press `a` to run all tests, or run Jest with `--watchAll`.' | |
+ : 'Run Jest without `-o` to run all tests.' | |
+ ) | |
+ ); | |
} | |
const pluralize = (word, count, ending) => | |
- `${count} ${word}${count === 1 ? '' : ending}`; | |
+ `${count} ${word}${count === 1 ? '' : ending}`; | |
const testPathPattern = formatTestPathPattern(pattern); | |
const individualResults = testRunData.map(testRun => { | |
const stats = testRun.matches.stats || {}; | |
const config = testRun.context.config; | |
- const statsMessage = Object.keys(stats). | |
- map(key => { | |
- if (key === 'roots' && config.roots.length === 1) { | |
+ const statsMessage = Object.keys(stats) | |
+ .map(key => { | |
+ if (key === 'roots' && config.roots.length === 1) { | |
+ return null; | |
+ } | |
+ const value = config[key]; | |
+ if (value) { | |
+ const matches = pluralize('match', stats[key], 'es'); | |
+ return ` ${key}: ${chalk.yellow(value)} - ${matches}`; | |
+ } | |
return null; | |
- } | |
- const value = config[key]; | |
- if (value) { | |
- const matches = pluralize('match', stats[key], 'es'); | |
- return ` ${key}: ${chalk.yellow(value)} - ${matches}`; | |
- } | |
- return null; | |
- }). | |
- filter(line => line). | |
- join('\n'); | |
- | |
- return testRun.matches.total ? | |
- `In ${chalk.bold(config.rootDir)}\n` + | |
- ` ${pluralize('file', testRun.matches.total || 0, 's')} checked.\n` + | |
- statsMessage : | |
- `No files found in ${config.rootDir}.\n` + | |
- `Make sure Jest's configuration does not exclude this directory.` + | |
- `\nTo set up Jest, make sure a package.json file exists.\n` + | |
- `Jest Documentation: ` + | |
- `facebook.github.io/jest/docs/configuration.html`; | |
+ }) | |
+ .filter(line => line) | |
+ .join('\n'); | |
+ | |
+ return testRun.matches.total | |
+ ? `In ${chalk.bold(config.rootDir)}\n` + | |
+ ` ${pluralize('file', testRun.matches.total || 0, 's')} checked.\n` + | |
+ statsMessage | |
+ : `No files found in ${config.rootDir}.\n` + | |
+ `Make sure Jest's configuration does not exclude this directory.` + | |
+ `\nTo set up Jest, make sure a package.json file exists.\n` + | |
+ `Jest Documentation: ` + | |
+ `facebook.github.io/jest/docs/configuration.html`; | |
}); | |
return ( | |
chalk.bold('No tests found') + | |
'\n' + | |
individualResults.join('\n') + | |
'\n' + | |
- `Pattern: ${chalk.yellow(testPathPattern)} - 0 matches`); | |
- | |
+ `Pattern: ${chalk.yellow(testPathPattern)} - 0 matches` | |
+ ); | |
}; | |
-const getTestPaths = (() => {var _ref = _asyncToGenerator(function* (globalConfig, context, pattern, argv, pipe) { | |
+const getTestPaths = (() => { | |
+ var _ref = _asyncToGenerator(function*( | |
+ globalConfig, | |
+ context, | |
+ pattern, | |
+ argv, | |
+ pipe | |
+ ) { | |
const source = new SearchSource(context); | |
let data = yield source.getTestPaths(pattern); | |
if (!data.tests.length) { | |
if (pattern.onlyChanged && data.noSCM) { | |
if (globalConfig.watch) { | |
// Run all the tests | |
- updateArgv(argv, 'watchAll', { noSCM: true }); | |
+ updateArgv(argv, 'watchAll', {noSCM: true}); | |
pattern = getTestPathPattern(argv); | |
data = yield source.getTestPaths(pattern); | |
} else { | |
new Console(pipe, pipe).log( | |
- 'Jest can only find uncommitted changed files in a git or hg ' + | |
- 'repository. If you make your project a git or hg ' + | |
- 'repository (`git init` or `hg init`), Jest will be able ' + | |
- 'to only run tests related to files changed since the last ' + | |
- 'commit.'); | |
- | |
+ 'Jest can only find uncommitted changed files in a git or hg ' + | |
+ 'repository. If you make your project a git or hg ' + | |
+ 'repository (`git init` or `hg init`), Jest will be able ' + | |
+ 'to only run tests related to files changed since the last ' + | |
+ 'commit.' | |
+ ); | |
} | |
} | |
} | |
return data; | |
- });return function getTestPaths(_x, _x2, _x3, _x4, _x5) {return _ref.apply(this, arguments);};})(); | |
+ }); | |
+ return function getTestPaths(_x, _x2, _x3, _x4, _x5) { | |
+ return _ref.apply(this, arguments); | |
+ }; | |
+})(); | |
const processResults = (runResults, options) => { | |
if (options.testResultsProcessor) { | |
@@ -131,13 +167,14 @@ const processResults = (runResults, options) => { | |
const outputFile = path.resolve(process.cwd(), options.outputFile); | |
fs.writeFileSync( | |
- outputFile, | |
- JSON.stringify(formatTestResults(runResults))); | |
+ outputFile, | |
+ JSON.stringify(formatTestResults(runResults)) | |
+ ); | |
process.stdout.write( | |
- `Test results written to: ` + | |
- `${path.relative(process.cwd(), outputFile)}\n`); | |
- | |
+ `Test results written to: ` + | |
+ `${path.relative(process.cwd(), outputFile)}\n` | |
+ ); | |
} else { | |
process.stdout.write(JSON.stringify(formatTestResults(runResults))); | |
} | |
@@ -145,67 +182,82 @@ const processResults = (runResults, options) => { | |
return options.onComplete && options.onComplete(runResults); | |
}; | |
-const runJest = (() => {var _ref2 = _asyncToGenerator(function* ( | |
- globalConfig, | |
- contexts, | |
- argv, | |
- pipe, | |
- testWatcher, | |
- startRun, | |
- onComplete) | |
- { | |
+const runJest = (() => { | |
+ var _ref2 = _asyncToGenerator(function*( | |
+ globalConfig, | |
+ contexts, | |
+ argv, | |
+ pipe, | |
+ testWatcher, | |
+ startRun, | |
+ onComplete | |
+ ) { | |
const maxWorkers = getMaxWorkers(argv); | |
const pattern = getTestPathPattern(argv); | |
const sequencer = new TestSequencer(); | |
let allTests = []; | |
const testRunData = yield Promise.all( | |
- contexts.map((() => {var _ref3 = _asyncToGenerator(function* (context) { | |
- const matches = yield getTestPaths( | |
- globalConfig, | |
- context, | |
- pattern, | |
- argv, | |
- pipe); | |
- | |
- allTests = allTests.concat(matches.tests); | |
- return { context, matches }; | |
- });return function (_x13) {return _ref3.apply(this, arguments);};})())); | |
- | |
+ contexts.map( | |
+ (() => { | |
+ var _ref3 = _asyncToGenerator(function*(context) { | |
+ const matches = yield getTestPaths( | |
+ globalConfig, | |
+ context, | |
+ pattern, | |
+ argv, | |
+ pipe | |
+ ); | |
+ | |
+ allTests = allTests.concat(matches.tests); | |
+ return {context, matches}; | |
+ }); | |
+ return function(_x13) { | |
+ return _ref3.apply(this, arguments); | |
+ }; | |
+ })() | |
+ ) | |
+ ); | |
allTests = sequencer.sort(allTests); | |
if (argv.listTests) { | |
- console.log(JSON.stringify(allTests.map(function (test) {return test.path;}))); | |
- onComplete && onComplete({ success: true }); | |
+ console.log( | |
+ JSON.stringify( | |
+ allTests.map(function(test) { | |
+ return test.path; | |
+ }) | |
+ ) | |
+ ); | |
+ onComplete && onComplete({success: true}); | |
return null; | |
} | |
if (!allTests.length) { | |
new Console(pipe, pipe).log(getNoTestsFoundMessage(testRunData, pattern)); | |
} else if ( | |
- allTests.length === 1 && | |
- globalConfig.silent !== true && | |
- globalConfig.verbose !== false) | |
- { | |
+ allTests.length === 1 && | |
+ globalConfig.silent !== true && | |
+ globalConfig.verbose !== false | |
+ ) { | |
// $FlowFixMe | |
globalConfig = Object.freeze( | |
- Object.assign({}, globalConfig, { verbose: true })); | |
- | |
+ Object.assign({}, globalConfig, {verbose: true}) | |
+ ); | |
} | |
// When using more than one context, make all printed paths relative to the | |
// current cwd. rootDir is only used as a token during normalization and | |
// has no special meaning afterwards except for printing information to the | |
// CLI. | |
- setConfig(contexts, { rootDir: process.cwd() }); | |
+ setConfig(contexts, {rootDir: process.cwd()}); | |
const results = yield new TestRunner(globalConfig, { | |
maxWorkers, | |
pattern, | |
startRun, | |
testNamePattern: argv.testNamePattern, | |
- testPathPattern: formatTestPathPattern(pattern) }). | |
- runTests(allTests, testWatcher); | |
+ testPathPattern: formatTestPathPattern(pattern), | |
+ }).runTests(allTests, testWatcher); | |
sequencer.cacheResults(allTests, results); | |
@@ -213,8 +265,12 @@ const runJest = (() => {var _ref2 = _asyncToGenerator(function* ( | |
isJSON: argv.json, | |
onComplete, | |
outputFile: argv.outputFile, | |
- testResultsProcessor: globalConfig.testResultsProcessor }); | |
- | |
- });return function runJest(_x6, _x7, _x8, _x9, _x10, _x11, _x12) {return _ref2.apply(this, arguments);};})(); | |
+ testResultsProcessor: globalConfig.testResultsProcessor, | |
+ }); | |
+ }); | |
+ return function runJest(_x6, _x7, _x8, _x9, _x10, _x11, _x12) { | |
+ return _ref2.apply(this, arguments); | |
+ }; | |
+})(); | |
-module.exports = runJest; | |
\ No newline at end of file | |
+module.exports = runJest; | |
diff --git i/packages/jest-cli/build/runTest.js w/packages/jest-cli/build/runTest.js | |
index 5c08d8d1..04dd5261 100644 | |
--- i/packages/jest-cli/build/runTest.js | |
+++ w/packages/jest-cli/build/runTest.js | |
@@ -9,27 +9,18 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-const BufferedConsole = require('./lib/BufferedConsole');var _require = | |
-require('jest-util');const Console = _require.Console,NullConsole = _require.NullConsole,setGlobal = _require.setGlobal;var _require2 = | |
- | |
-require('jest-config');const getTestEnvironment = _require2.getTestEnvironment; | |
+const BufferedConsole = require('./lib/BufferedConsole'); | |
+var _require = require('jest-util'); | |
+const Console = _require.Console, | |
+ NullConsole = _require.NullConsole, | |
+ setGlobal = _require.setGlobal; | |
+var _require2 = require('jest-config'); | |
+const getTestEnvironment = _require2.getTestEnvironment; | |
const fs = require('fs'); | |
const docblock = require('jest-docblock'); | |
const getConsoleOutput = require('./reporters/getConsoleOutput'); | |
-function runTest( | |
-path, | |
-globalConfig, | |
-config, | |
-resolver) | |
-{ | |
+function runTest(path, globalConfig, config, resolver) { | |
let testSource; | |
try { | |
@@ -44,10 +35,10 @@ resolver) | |
if (customEnvironment) { | |
testEnvironment = getTestEnvironment( | |
- Object.assign({}, config, { | |
- testEnvironment: customEnvironment })); | |
- | |
- | |
+ Object.assign({}, config, { | |
+ testEnvironment: customEnvironment, | |
+ }) | |
+ ); | |
} | |
/* $FlowFixMe */ | |
@@ -57,66 +48,66 @@ resolver) | |
/* $FlowFixMe */ | |
const Runtime = require(config.moduleLoader || 'jest-runtime'); | |
- | |
- | |
const environment = new TestEnvironment(config); | |
- const TestConsole = globalConfig.verbose ? | |
- Console : | |
- globalConfig.silent ? NullConsole : BufferedConsole; | |
+ const TestConsole = globalConfig.verbose | |
+ ? Console | |
+ : globalConfig.silent ? NullConsole : BufferedConsole; | |
const testConsole = new TestConsole( | |
- globalConfig.useStderr ? process.stderr : process.stdout, | |
- process.stderr, | |
- (type, message) => | |
- getConsoleOutput( | |
- config.rootDir, | |
- !!globalConfig.verbose, | |
- // 4 = the console call is buried 4 stack frames deep | |
- BufferedConsole.write([], type, message, 4))); | |
- | |
- | |
- const cacheFS = { [path]: testSource }; | |
+ globalConfig.useStderr ? process.stderr : process.stdout, | |
+ process.stderr, | |
+ (type, message) => | |
+ getConsoleOutput( | |
+ config.rootDir, | |
+ !!globalConfig.verbose, | |
+ // 4 = the console call is buried 4 stack frames deep | |
+ BufferedConsole.write([], type, message, 4) | |
+ ) | |
+ ); | |
+ | |
+ const cacheFS = {[path]: testSource}; | |
setGlobal(environment.global, 'console', testConsole); | |
const runtime = new Runtime(config, environment, resolver, cacheFS, { | |
collectCoverage: globalConfig.collectCoverage, | |
collectCoverageFrom: globalConfig.collectCoverageFrom, | |
collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, | |
- mapCoverage: globalConfig.mapCoverage }); | |
+ mapCoverage: globalConfig.mapCoverage, | |
+ }); | |
const start = Date.now(); | |
- return testFramework(globalConfig, config, environment, runtime, path). | |
- then(result => { | |
- const testCount = | |
- result.numPassingTests + | |
- result.numFailingTests + | |
- result.numPendingTests; | |
- result.perfStats = { end: Date.now(), start }; | |
- result.testFilePath = path; | |
- result.coverage = runtime.getAllCoverageInfo(); | |
- result.sourceMaps = runtime.getSourceMapInfo(); | |
- result.console = testConsole.getBuffer(); | |
- result.skipped = testCount === result.numPendingTests; | |
- return result; | |
- }). | |
- then( | |
- result => | |
- Promise.resolve().then(() => { | |
- environment.dispose(); | |
- if (config.logHeapUsage) { | |
- if (global.gc) { | |
- global.gc(); | |
- } | |
- result.memoryUsage = process.memoryUsage().heapUsed; | |
- } | |
- | |
- // Delay the resolution to allow log messages to be output. | |
- return new Promise(resolve => setImmediate(() => resolve(result))); | |
- }), | |
- err => | |
- Promise.resolve().then(() => { | |
- environment.dispose(); | |
- throw err; | |
- })); | |
- | |
+ return testFramework(globalConfig, config, environment, runtime, path) | |
+ .then(result => { | |
+ const testCount = | |
+ result.numPassingTests + | |
+ result.numFailingTests + | |
+ result.numPendingTests; | |
+ result.perfStats = {end: Date.now(), start}; | |
+ result.testFilePath = path; | |
+ result.coverage = runtime.getAllCoverageInfo(); | |
+ result.sourceMaps = runtime.getSourceMapInfo(); | |
+ result.console = testConsole.getBuffer(); | |
+ result.skipped = testCount === result.numPendingTests; | |
+ return result; | |
+ }) | |
+ .then( | |
+ result => | |
+ Promise.resolve().then(() => { | |
+ environment.dispose(); | |
+ if (config.logHeapUsage) { | |
+ if (global.gc) { | |
+ global.gc(); | |
+ } | |
+ result.memoryUsage = process.memoryUsage().heapUsed; | |
+ } | |
+ | |
+ // Delay the resolution to allow log messages to be output. | |
+ return new Promise(resolve => setImmediate(() => resolve(result))); | |
+ }), | |
+ err => | |
+ Promise.resolve().then(() => { | |
+ environment.dispose(); | |
+ throw err; | |
+ }) | |
+ ); | |
} | |
-module.exports = runTest; | |
\ No newline at end of file | |
+module.exports = runTest; | |
diff --git i/packages/jest-cli/build/watch.js w/packages/jest-cli/build/watch.js | |
index 9a64023d..2f490972 100644 | |
--- i/packages/jest-cli/build/watch.js | |
+++ w/packages/jest-cli/build/watch.js | |
@@ -9,10 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
const ansiEscapes = require('ansi-escapes'); | |
const chalk = require('chalk'); | |
const createContext = require('./lib/createContext'); | |
@@ -27,30 +23,34 @@ const SearchSource = require('./SearchSource'); | |
const TestWatcher = require('./TestWatcher'); | |
const Prompt = require('./lib/Prompt'); | |
const TestPathPatternPrompt = require('./TestPathPatternPrompt'); | |
-const TestNamePatternPrompt = require('./TestNamePatternPrompt');var _require = | |
-require('./constants');const KEYS = _require.KEYS,CLEAR = _require.CLEAR; | |
+const TestNamePatternPrompt = require('./TestNamePatternPrompt'); | |
+var _require = require('./constants'); | |
+const KEYS = _require.KEYS, CLEAR = _require.CLEAR; | |
let hasExitListener = false; | |
-const watch = function ( | |
-initialGlobalConfig, | |
-contexts, | |
-argv, | |
-pipe, | |
-hasteMapInstances) | |
- | |
-{let stdin = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : process.stdin; | |
+const watch = function( | |
+ initialGlobalConfig, | |
+ contexts, | |
+ argv, | |
+ pipe, | |
+ hasteMapInstances | |
+) { | |
+ let stdin = arguments.length > 5 && arguments[5] !== undefined | |
+ ? arguments[5] | |
+ : process.stdin; | |
updateArgv(argv, argv.watch ? 'watch' : 'watchAll', { | |
testNamePattern: argv.testNamePattern, | |
- testPathPattern: argv.testPathPattern || (argv._ || []).join('|') }); | |
- | |
+ testPathPattern: argv.testPathPattern || (argv._ || []).join('|'), | |
+ }); | |
const prompt = new Prompt(); | |
const testPathPatternPrompt = new TestPathPatternPrompt(pipe, prompt); | |
const testNamePatternPrompt = new TestNamePatternPrompt(pipe, prompt); | |
let searchSources = contexts.map(context => ({ | |
context, | |
- searchSource: new SearchSource(context) })); | |
+ searchSource: new SearchSource(context), | |
+ })); | |
let hasSnapshotFailure = false; | |
let isRunning = false; | |
@@ -61,28 +61,34 @@ hasteMapInstances) | |
testPathPatternPrompt.updateSearchSources(searchSources); | |
hasteMapInstances.forEach((hasteMapInstance, index) => { | |
- hasteMapInstance.on('change', (_ref) => {let eventsQueue = _ref.eventsQueue,hasteFS = _ref.hasteFS,moduleMap = _ref.moduleMap; | |
- const validPaths = eventsQueue.filter((_ref2) => {let filePath = _ref2.filePath; | |
+ hasteMapInstance.on('change', _ref => { | |
+ let eventsQueue = _ref.eventsQueue, | |
+ hasteFS = _ref.hasteFS, | |
+ moduleMap = _ref.moduleMap; | |
+ const validPaths = eventsQueue.filter(_ref2 => { | |
+ let filePath = _ref2.filePath; | |
return isValidPath( | |
- initialGlobalConfig, | |
- contexts[index].config, | |
- filePath); | |
- | |
+ initialGlobalConfig, | |
+ contexts[index].config, | |
+ filePath | |
+ ); | |
}); | |
if (validPaths.length) { | |
- const context = contexts[index] = createContext( | |
- contexts[index].config, | |
- { | |
- hasteFS, | |
- moduleMap }); | |
- | |
+ const context = (contexts[index] = createContext( | |
+ contexts[index].config, | |
+ { | |
+ hasteFS, | |
+ moduleMap, | |
+ } | |
+ )); | |
prompt.abort(); | |
searchSources = searchSources.slice(); | |
searchSources[index] = { | |
context, | |
- searchSource: new SearchSource(context) }; | |
+ searchSource: new SearchSource(context), | |
+ }; | |
testPathPatternPrompt.updateSearchSources(searchSources); | |
startRun(); | |
@@ -100,49 +106,53 @@ hasteMapInstances) | |
}); | |
} | |
- const startRun = function () {let overrideConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | |
+ const startRun = function() { | |
+ let overrideConfig = arguments.length > 0 && arguments[0] !== undefined | |
+ ? arguments[0] | |
+ : {}; | |
if (isRunning) { | |
return null; | |
} | |
- testWatcher = new TestWatcher({ isWatchMode: true }); | |
+ testWatcher = new TestWatcher({isWatchMode: true}); | |
isInteractive && pipe.write(CLEAR); | |
preRunMessage.print(pipe); | |
isRunning = true; | |
const globalConfig = Object.freeze( | |
- Object.assign({}, initialGlobalConfig, overrideConfig, { | |
- testNamePattern: argv.testNamePattern, | |
- testPathPattern: argv.testPathPattern })); | |
- | |
+ Object.assign({}, initialGlobalConfig, overrideConfig, { | |
+ testNamePattern: argv.testNamePattern, | |
+ testPathPattern: argv.testPathPattern, | |
+ }) | |
+ ); | |
return runJest( | |
- // $FlowFixMe | |
- globalConfig, | |
- contexts, | |
- argv, | |
- pipe, | |
- testWatcher, | |
- startRun, | |
- results => { | |
- isRunning = false; | |
- hasSnapshotFailure = !!results.snapshot.failure; | |
- // Create a new testWatcher instance so that re-runs won't be blocked. | |
- // The old instance that was passed to Jest will still be interrupted | |
- // and prevent test runs from the previous run. | |
- testWatcher = new TestWatcher({ isWatchMode: true }); | |
- if (shouldDisplayWatchUsage) { | |
- pipe.write(usage(argv, hasSnapshotFailure)); | |
- shouldDisplayWatchUsage = false; // hide Watch Usage after first run | |
- isWatchUsageDisplayed = true; | |
- } else { | |
- pipe.write(showToggleUsagePrompt()); | |
- shouldDisplayWatchUsage = false; | |
- isWatchUsageDisplayed = false; | |
- } | |
+ // $FlowFixMe | |
+ globalConfig, | |
+ contexts, | |
+ argv, | |
+ pipe, | |
+ testWatcher, | |
+ startRun, | |
+ results => { | |
+ isRunning = false; | |
+ hasSnapshotFailure = !!results.snapshot.failure; | |
+ // Create a new testWatcher instance so that re-runs won't be blocked. | |
+ // The old instance that was passed to Jest will still be interrupted | |
+ // and prevent test runs from the previous run. | |
+ testWatcher = new TestWatcher({isWatchMode: true}); | |
+ if (shouldDisplayWatchUsage) { | |
+ pipe.write(usage(argv, hasSnapshotFailure)); | |
+ shouldDisplayWatchUsage = false; // hide Watch Usage after first run | |
+ isWatchUsageDisplayed = true; | |
+ } else { | |
+ pipe.write(showToggleUsagePrompt()); | |
+ shouldDisplayWatchUsage = false; | |
+ isWatchUsageDisplayed = false; | |
+ } | |
- testNamePatternPrompt.updateCachedTestResults(results.testResults); | |
- }). | |
- catch(error => console.error(chalk.red(error.stack))); | |
+ testNamePatternPrompt.updateCachedTestResults(results.testResults); | |
+ } | |
+ ).catch(error => console.error(chalk.red(error.stack))); | |
}; | |
const onKeypress = key => { | |
@@ -158,11 +168,11 @@ hasteMapInstances) | |
// Abort test run | |
if ( | |
- isRunning && | |
- testWatcher && | |
- [KEYS.Q, KEYS.ENTER, KEYS.A, KEYS.O, KEYS.P, KEYS.T].indexOf(key) !== -1) | |
- { | |
- testWatcher.setState({ interrupted: true }); | |
+ isRunning && | |
+ testWatcher && | |
+ [KEYS.Q, KEYS.ENTER, KEYS.A, KEYS.O, KEYS.P, KEYS.T].indexOf(key) !== -1 | |
+ ) { | |
+ testWatcher.setState({interrupted: true}); | |
return; | |
} | |
@@ -174,55 +184,60 @@ hasteMapInstances) | |
startRun(); | |
break; | |
case KEYS.U: | |
- startRun({ updateSnapshot: 'all' }); | |
+ startRun({updateSnapshot: 'all'}); | |
break; | |
case KEYS.A: | |
updateArgv(argv, 'watchAll', { | |
testNamePattern: '', | |
- testPathPattern: '' }); | |
+ testPathPattern: '', | |
+ }); | |
startRun(); | |
break; | |
case KEYS.C: | |
updateArgv(argv, 'watch', { | |
testNamePattern: '', | |
- testPathPattern: '' }); | |
+ testPathPattern: '', | |
+ }); | |
startRun(); | |
break; | |
case KEYS.O: | |
updateArgv(argv, 'watch', { | |
testNamePattern: '', | |
- testPathPattern: '' }); | |
+ testPathPattern: '', | |
+ }); | |
startRun(); | |
break; | |
case KEYS.P: | |
testPathPatternPrompt.run( | |
- testPathPattern => { | |
- updateArgv(argv, 'watch', { | |
- testNamePattern: '', | |
- testPathPattern }); | |
- | |
- | |
- startRun(); | |
- }, | |
- onCancelPatternPrompt, | |
- { header: activeFilters(argv) }); | |
+ testPathPattern => { | |
+ updateArgv(argv, 'watch', { | |
+ testNamePattern: '', | |
+ testPathPattern, | |
+ }); | |
+ | |
+ startRun(); | |
+ }, | |
+ onCancelPatternPrompt, | |
+ {header: activeFilters(argv)} | |
+ ); | |
break; | |
case KEYS.T: | |
testNamePatternPrompt.run( | |
- testNamePattern => { | |
- updateArgv(argv, 'watch', { | |
- testNamePattern, | |
- testPathPattern: argv.testPathPattern }); | |
- | |
- | |
- startRun(); | |
- }, | |
- onCancelPatternPrompt, | |
- { header: activeFilters(argv) }); | |
+ testNamePattern => { | |
+ updateArgv(argv, 'watch', { | |
+ testNamePattern, | |
+ testPathPattern: argv.testPathPattern, | |
+ }); | |
+ | |
+ startRun(); | |
+ }, | |
+ onCancelPatternPrompt, | |
+ {header: activeFilters(argv)} | |
+ ); | |
break; | |
case KEYS.QUESTION_MARK: | |
@@ -235,8 +250,8 @@ hasteMapInstances) | |
isWatchUsageDisplayed = true; | |
shouldDisplayWatchUsage = false; | |
} | |
- break;} | |
- | |
+ break; | |
+ } | |
}; | |
const onCancelPatternPrompt = () => { | |
@@ -257,19 +272,23 @@ hasteMapInstances) | |
return Promise.resolve(); | |
}; | |
-const activeFilters = function (argv) {let delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '\n';const | |
- testNamePattern = argv.testNamePattern,testPathPattern = argv.testPathPattern; | |
+const activeFilters = function(argv) { | |
+ let delimiter = arguments.length > 1 && arguments[1] !== undefined | |
+ ? arguments[1] | |
+ : '\n'; | |
+ const testNamePattern = argv.testNamePattern, | |
+ testPathPattern = argv.testPathPattern; | |
if (testNamePattern || testPathPattern) { | |
const filters = [ | |
- testPathPattern ? | |
- chalk.dim('filename ') + chalk.yellow('/' + testPathPattern + '/') : | |
- null, | |
- testNamePattern ? | |
- chalk.dim('test name ') + chalk.yellow('/' + testNamePattern + '/') : | |
- null]. | |
- | |
- filter(f => !!f). | |
- join(', '); | |
+ testPathPattern | |
+ ? chalk.dim('filename ') + chalk.yellow('/' + testPathPattern + '/') | |
+ : null, | |
+ testNamePattern | |
+ ? chalk.dim('test name ') + chalk.yellow('/' + testNamePattern + '/') | |
+ : null, | |
+ ] | |
+ .filter(f => !!f) | |
+ .join(', '); | |
const messages = ['\n' + chalk.bold('Active Filters: ') + filters]; | |
@@ -279,47 +298,50 @@ const activeFilters = function (argv) {let delimiter = arguments.length > 1 && a | |
return ''; | |
}; | |
-const usage = function (argv, snapshotFailure) {let delimiter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '\n'; | |
+const usage = function(argv, snapshotFailure) { | |
+ let delimiter = arguments.length > 2 && arguments[2] !== undefined | |
+ ? arguments[2] | |
+ : '\n'; | |
const messages = [ | |
- activeFilters(argv), | |
- argv.testPathPattern || argv.testNamePattern ? | |
- chalk.dim(' \u203A Press ') + 'c' + chalk.dim(' to clear filters.') : | |
- null, | |
- '\n' + chalk.bold('Watch Usage'), | |
- argv.watch ? | |
- chalk.dim(' \u203A Press ') + 'a' + chalk.dim(' to run all tests.') : | |
- null, | |
- (argv.watchAll || argv.testPathPattern || argv.testNamePattern) && | |
- !argv.noSCM ? | |
- chalk.dim(' \u203A Press ') + | |
- 'o' + | |
- chalk.dim(' to only run tests related to changed files.') : | |
- null, | |
- snapshotFailure ? | |
- chalk.dim(' \u203A Press ') + | |
- 'u' + | |
- chalk.dim(' to update failing snapshots.') : | |
- null, | |
- chalk.dim(' \u203A Press ') + | |
- 'p' + | |
- chalk.dim(' to filter by a filename regex pattern.'), | |
- chalk.dim(' \u203A Press ') + | |
- 't' + | |
- chalk.dim(' to filter by a test name regex pattern.'), | |
- chalk.dim(' \u203A Press ') + 'q' + chalk.dim(' to quit watch mode.'), | |
- chalk.dim(' \u203A Press ') + | |
- 'Enter' + | |
- chalk.dim(' to trigger a test run.')]; | |
- | |
+ activeFilters(argv), | |
+ argv.testPathPattern || argv.testNamePattern | |
+ ? chalk.dim(' \u203A Press ') + 'c' + chalk.dim(' to clear filters.') | |
+ : null, | |
+ '\n' + chalk.bold('Watch Usage'), | |
+ argv.watch | |
+ ? chalk.dim(' \u203A Press ') + 'a' + chalk.dim(' to run all tests.') | |
+ : null, | |
+ (argv.watchAll || argv.testPathPattern || argv.testNamePattern) && | |
+ !argv.noSCM | |
+ ? chalk.dim(' \u203A Press ') + | |
+ 'o' + | |
+ chalk.dim(' to only run tests related to changed files.') | |
+ : null, | |
+ snapshotFailure | |
+ ? chalk.dim(' \u203A Press ') + | |
+ 'u' + | |
+ chalk.dim(' to update failing snapshots.') | |
+ : null, | |
+ chalk.dim(' \u203A Press ') + | |
+ 'p' + | |
+ chalk.dim(' to filter by a filename regex pattern.'), | |
+ chalk.dim(' \u203A Press ') + | |
+ 't' + | |
+ chalk.dim(' to filter by a test name regex pattern.'), | |
+ chalk.dim(' \u203A Press ') + 'q' + chalk.dim(' to quit watch mode.'), | |
+ chalk.dim(' \u203A Press ') + | |
+ 'Enter' + | |
+ chalk.dim(' to trigger a test run.'), | |
+ ]; | |
return messages.filter(message => !!message).join(delimiter) + '\n'; | |
}; | |
const showToggleUsagePrompt = () => | |
-'\n' + | |
-chalk.bold('Watch Usage: ') + | |
-chalk.dim('Press ') + | |
-'w' + | |
-chalk.dim(' to show more.'); | |
+ '\n' + | |
+ chalk.bold('Watch Usage: ') + | |
+ chalk.dim('Press ') + | |
+ 'w' + | |
+ chalk.dim(' to show more.'); | |
-module.exports = watch; | |
\ No newline at end of file | |
+module.exports = watch; | |
diff --git i/packages/jest-config/build/__mocks__/fs.js w/packages/jest-config/build/__mocks__/fs.js | |
index c11fb6ce..f68faca3 100644 | |
--- i/packages/jest-config/build/__mocks__/fs.js | |
+++ w/packages/jest-config/build/__mocks__/fs.js | |
@@ -21,4 +21,4 @@ function __setMockFiles(newMockFiles) { | |
fs.__setMockFiles = __setMockFiles; | |
fs.readFileSync = jest.fn(file => mockFiles.get(file)); | |
-module.exports = fs; | |
\ No newline at end of file | |
+module.exports = fs; | |
diff --git i/packages/jest-config/build/__mocks__/read-pkg.js w/packages/jest-config/build/__mocks__/read-pkg.js | |
index ba32b1e8..4236d98f 100644 | |
--- i/packages/jest-config/build/__mocks__/read-pkg.js | |
+++ w/packages/jest-config/build/__mocks__/read-pkg.js | |
@@ -27,4 +27,4 @@ function readPkg(file) { | |
} | |
module.exports = readPkg; | |
-module.exports.__setMockFiles = __setMockFiles; | |
\ No newline at end of file | |
+module.exports.__setMockFiles = __setMockFiles; | |
diff --git i/packages/jest-config/build/constants.js w/packages/jest-config/build/constants.js | |
index 52a636b3..80ad9dae 100644 | |
--- i/packages/jest-config/build/constants.js | |
+++ w/packages/jest-config/build/constants.js | |
@@ -14,4 +14,4 @@ const path = require('path'); | |
exports.NODE_MODULES = path.sep + 'node_modules' + path.sep; | |
exports.DEFAULT_JS_PATTERN = '^.+\\.jsx?$'; | |
-exports.DEFAULT_REPORTER_LABEL = 'default'; | |
\ No newline at end of file | |
+exports.DEFAULT_REPORTER_LABEL = 'default'; | |
diff --git i/packages/jest-config/build/defaults.js w/packages/jest-config/build/defaults.js | |
index 234dbc71..7d2886a9 100644 | |
--- i/packages/jest-config/build/defaults.js | |
+++ w/packages/jest-config/build/defaults.js | |
@@ -10,17 +10,17 @@ | |
'use strict'; | |
- | |
- | |
const constants = require('./constants'); | |
const os = require('os'); | |
-const path = require('path');var _require = | |
-require('jest-regex-util');const replacePathSepForRegex = _require.replacePathSepForRegex; | |
+const path = require('path'); | |
+var _require = require('jest-regex-util'); | |
+const replacePathSepForRegex = _require.replacePathSepForRegex; | |
const NODE_MODULES_REGEXP = replacePathSepForRegex(constants.NODE_MODULES); | |
-const cacheDirectory = (() => {var _process = | |
- process;const getuid = _process.getuid; | |
+const cacheDirectory = (() => { | |
+ var _process = process; | |
+ const getuid = _process.getuid; | |
if (getuid == null) { | |
return path.join(os.tmpdir(), 'jest'); | |
} | |
@@ -42,7 +42,8 @@ module.exports = { | |
expand: false, | |
globals: {}, | |
haste: { | |
- providesModuleNodeModules: [] }, | |
+ providesModuleNodeModules: [], | |
+ }, | |
mapCoverage: false, | |
moduleDirectories: ['node_modules'], | |
@@ -66,4 +67,5 @@ module.exports = { | |
useStderr: false, | |
verbose: null, | |
watch: false, | |
- watchman: true }; | |
\ No newline at end of file | |
+ watchman: true, | |
+}; | |
diff --git i/packages/jest-config/build/deprecated.js w/packages/jest-config/build/deprecated.js | |
index d769fcf4..409ef32f 100644 | |
--- i/packages/jest-config/build/deprecated.js | |
+++ w/packages/jest-config/build/deprecated.js | |
@@ -11,12 +11,11 @@ | |
'use strict'; | |
const chalk = require('chalk'); | |
-const format = value => require('pretty-format')(value, { min: true }); | |
+const format = value => require('pretty-format')(value, {min: true}); | |
const deprecatedOptions = { | |
preprocessorIgnorePatterns: options => | |
- | |
- ` Option ${chalk.bold('"preprocessorIgnorePatterns"')} was replaced by ${chalk.bold('"transformIgnorePatterns"')}, which support multiple preprocessors. | |
+ ` Option ${chalk.bold('"preprocessorIgnorePatterns"')} was replaced by ${chalk.bold('"transformIgnorePatterns"')}, which support multiple preprocessors. | |
Jest now treats your current configuration as: | |
{ | |
@@ -26,8 +25,7 @@ const deprecatedOptions = { | |
Please update your configuration.`, | |
scriptPreprocessor: options => | |
- | |
- ` Option ${chalk.bold('"scriptPreprocessor"')} was replaced by ${chalk.bold('"transform"')}, which support multiple preprocessors. | |
+ ` Option ${chalk.bold('"scriptPreprocessor"')} was replaced by ${chalk.bold('"transform"')}, which support multiple preprocessors. | |
Jest now treats your current configuration as: | |
{ | |
@@ -37,8 +35,7 @@ const deprecatedOptions = { | |
Please update your configuration.`, | |
testPathDirs: options => | |
- | |
- ` Option ${chalk.bold('"testPathDirs"')} was replaced by ${chalk.bold('"roots"')}. | |
+ ` Option ${chalk.bold('"testPathDirs"')} was replaced by ${chalk.bold('"roots"')}. | |
Jest now treats your current configuration as: | |
{ | |
@@ -46,7 +43,7 @@ const deprecatedOptions = { | |
} | |
Please update your configuration. | |
- ` }; | |
- | |
+ `, | |
+}; | |
-module.exports = deprecatedOptions; | |
\ No newline at end of file | |
+module.exports = deprecatedOptions; | |
diff --git i/packages/jest-config/build/findConfig.js w/packages/jest-config/build/findConfig.js | |
index 15dbb9db..424a9b46 100644 | |
--- i/packages/jest-config/build/findConfig.js | |
+++ w/packages/jest-config/build/findConfig.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const fs = require('fs'); | |
const jsonlint = require('./vendor/jsonlint'); | |
const path = require('path'); | |
@@ -20,7 +18,7 @@ const JEST_CONFIG = 'jest.config.js'; | |
const PACKAGE_JSON = 'package.json'; | |
const isFile = filePath => | |
-fs.existsSync(filePath) && !fs.lstatSync(filePath).isDirectory(); | |
+ fs.existsSync(filePath) && !fs.lstatSync(filePath).isDirectory(); | |
const findConfig = root => { | |
// $FlowFixMe | |
@@ -39,9 +37,9 @@ const findConfig = root => { | |
pkg = require(filePath); | |
} catch (error) { | |
throw new Error( | |
- `Jest: Failed to parse config file ${filePath}\n` + | |
- ` ${jsonlint.errors(fs.readFileSync(filePath, 'utf8'))}`); | |
- | |
+ `Jest: Failed to parse config file ${filePath}\n` + | |
+ ` ${jsonlint.errors(fs.readFileSync(filePath, 'utf8'))}` | |
+ ); | |
} | |
if (directory.endsWith(PACKAGE_JSON)) { | |
options = pkg.jest || options; | |
@@ -49,9 +47,9 @@ const findConfig = root => { | |
options = pkg; | |
} | |
} | |
- options.rootDir = options.rootDir ? | |
- path.resolve(path.dirname(directory), options.rootDir) : | |
- path.dirname(directory); | |
+ options.rootDir = options.rootDir | |
+ ? path.resolve(path.dirname(directory), options.rootDir) | |
+ : path.dirname(directory); | |
return options; | |
} | |
@@ -64,7 +62,8 @@ const findConfig = root => { | |
} | |
const packageJsonFilePath = path.resolve( | |
- path.join(directory, PACKAGE_JSON)); | |
+ path.join(directory, PACKAGE_JSON) | |
+ ); | |
if (isFile(packageJsonFilePath)) { | |
// $FlowFixMe | |
@@ -78,11 +77,11 @@ const findConfig = root => { | |
} | |
} while (directory !== (directory = path.dirname(directory))); | |
- options.rootDir = options.rootDir ? | |
- path.resolve(root, options.rootDir) : | |
- path.resolve(directory); | |
+ options.rootDir = options.rootDir | |
+ ? path.resolve(root, options.rootDir) | |
+ : path.resolve(directory); | |
return options; | |
}; | |
-module.exports = findConfig; | |
\ No newline at end of file | |
+module.exports = findConfig; | |
diff --git i/packages/jest-config/build/index.js w/packages/jest-config/build/index.js | |
index 5b17f3c6..71c71d3e 100644 | |
--- i/packages/jest-config/build/index.js | |
+++ w/packages/jest-config/build/index.js | |
@@ -8,36 +8,31 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
-require('./utils');const getTestEnvironment = _require.getTestEnvironment,isJSONString = _require.isJSONString; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const getTestEnvironment = _require.getTestEnvironment, | |
+ isJSONString = _require.isJSONString; | |
const findConfig = require('./findConfig'); | |
const normalize = require('./normalize'); | |
const path = require('path'); | |
-function readConfig( | |
-argv, | |
-packageRoot) | |
- | |
- | |
- | |
- | |
-{ | |
- const rawOptions = readOptions(argv, packageRoot);var _normalize = | |
- normalize(rawOptions, argv);const options = _normalize.options,hasDeprecationWarnings = _normalize.hasDeprecationWarnings;var _getConfigs = | |
- getConfigs(options);const globalConfig = _getConfigs.globalConfig,projectConfig = _getConfigs.projectConfig; | |
+function readConfig(argv, packageRoot) { | |
+ const rawOptions = readOptions(argv, packageRoot); | |
+ var _normalize = normalize(rawOptions, argv); | |
+ const options = _normalize.options, | |
+ hasDeprecationWarnings = _normalize.hasDeprecationWarnings; | |
+ var _getConfigs = getConfigs(options); | |
+ const globalConfig = _getConfigs.globalConfig, | |
+ projectConfig = _getConfigs.projectConfig; | |
return { | |
config: projectConfig, | |
globalConfig, | |
- hasDeprecationWarnings }; | |
- | |
+ hasDeprecationWarnings, | |
+ }; | |
} | |
const parseConfig = argv => | |
-isJSONString(argv.config) ? JSON.parse(argv.config) : argv.config; | |
+ isJSONString(argv.config) ? JSON.parse(argv.config) : argv.config; | |
const readOptions = (argv, root) => { | |
const rawOptions = parseConfig(argv); | |
@@ -55,9 +50,7 @@ const readOptions = (argv, root) => { | |
return findConfig(root); | |
}; | |
-const getConfigs = | |
-options => | |
-{ | |
+const getConfigs = options => { | |
return { | |
globalConfig: Object.freeze({ | |
bail: options.bail, | |
@@ -85,7 +78,8 @@ options => | |
useStderr: options.useStderr, | |
verbose: options.verbose, | |
watch: options.watch, | |
- watchman: options.watchman }), | |
+ watchman: options.watchman, | |
+ }), | |
projectConfig: Object.freeze({ | |
automock: options.automock, | |
@@ -120,12 +114,13 @@ options => | |
timers: options.timers, | |
transform: options.transform, | |
transformIgnorePatterns: options.transformIgnorePatterns, | |
- unmockedModulePathPatterns: options.unmockedModulePathPatterns }) }; | |
- | |
- | |
+ unmockedModulePathPatterns: options.unmockedModulePathPatterns, | |
+ }), | |
+ }; | |
}; | |
module.exports = { | |
getTestEnvironment, | |
normalize, | |
- readConfig }; | |
\ No newline at end of file | |
+ readConfig, | |
+}; | |
diff --git i/packages/jest-config/build/normalize.js w/packages/jest-config/build/normalize.js | |
index 66a4159b..f2103401 100644 | |
--- i/packages/jest-config/build/normalize.js | |
+++ w/packages/jest-config/build/normalize.js | |
@@ -8,26 +8,23 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./utils');const BULLET = _require.BULLET,DOCUMENTATION_NOTE = _require.DOCUMENTATION_NOTE,_replaceRootDirInPath = _require._replaceRootDirInPath,_replaceRootDirTags = _require._replaceRootDirTags,getTestEnvironment = _require.getTestEnvironment,resolve = _require.resolve;var _require2 = | |
- | |
- | |
- | |
- | |
-require('./constants');const NODE_MODULES = _require2.NODE_MODULES,DEFAULT_JS_PATTERN = _require2.DEFAULT_JS_PATTERN,DEFAULT_REPORTER_LABEL = _require2.DEFAULT_REPORTER_LABEL;var _require3 = | |
-require('./reporterValidationErrors');const validateReporters = _require3.validateReporters;var _require4 = | |
-require('jest-validate');const ValidationError = _require4.ValidationError,validate = _require4.validate; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const BULLET = _require.BULLET, | |
+ DOCUMENTATION_NOTE = _require.DOCUMENTATION_NOTE, | |
+ _replaceRootDirInPath = _require._replaceRootDirInPath, | |
+ _replaceRootDirTags = _require._replaceRootDirTags, | |
+ getTestEnvironment = _require.getTestEnvironment, | |
+ resolve = _require.resolve; | |
+var _require2 = require('./constants'); | |
+const NODE_MODULES = _require2.NODE_MODULES, | |
+ DEFAULT_JS_PATTERN = _require2.DEFAULT_JS_PATTERN, | |
+ DEFAULT_REPORTER_LABEL = _require2.DEFAULT_REPORTER_LABEL; | |
+var _require3 = require('./reporterValidationErrors'); | |
+const validateReporters = _require3.validateReporters; | |
+var _require4 = require('jest-validate'); | |
+const ValidationError = _require4.ValidationError, | |
+ validate = _require4.validate; | |
const chalk = require('chalk'); | |
const crypto = require('crypto'); | |
const DEFAULT_CONFIG = require('./defaults'); | |
@@ -43,22 +40,19 @@ const utils = require('jest-regex-util'); | |
const VALID_CONFIG = require('./validConfig'); | |
const createConfigError = message => | |
-new ValidationError(ERROR, message, DOCUMENTATION_NOTE); | |
+ new ValidationError(ERROR, message, DOCUMENTATION_NOTE); | |
-const setupPreset = ( | |
-options, | |
-optionsPreset) => | |
-{ | |
+const setupPreset = (options, optionsPreset) => { | |
let preset; | |
const presetPath = _replaceRootDirInPath(options.rootDir, optionsPreset); | |
const presetModule = Resolver.findNodeModule( | |
- presetPath.endsWith(JSON_EXTENSION) ? | |
- presetPath : | |
- path.join(presetPath, PRESET_NAME), | |
- { | |
- basedir: options.rootDir }); | |
- | |
- | |
+ presetPath.endsWith(JSON_EXTENSION) | |
+ ? presetPath | |
+ : path.join(presetPath, PRESET_NAME), | |
+ { | |
+ basedir: options.rootDir, | |
+ } | |
+ ); | |
try { | |
// $FlowFixMe | |
@@ -72,15 +66,15 @@ optionsPreset) => | |
} | |
if (options.modulePathIgnorePatterns && preset.modulePathIgnorePatterns) { | |
options.modulePathIgnorePatterns = preset.modulePathIgnorePatterns.concat( | |
- options.modulePathIgnorePatterns); | |
- | |
+ options.modulePathIgnorePatterns | |
+ ); | |
} | |
if (options.moduleNameMapper && preset.moduleNameMapper) { | |
options.moduleNameMapper = Object.assign( | |
- {}, | |
- preset.moduleNameMapper, | |
- options.moduleNameMapper); | |
- | |
+ {}, | |
+ preset.moduleNameMapper, | |
+ options.moduleNameMapper | |
+ ); | |
} | |
// $FlowFixMe | |
@@ -99,39 +93,38 @@ const setupBabelJest = options => { | |
if (customJSPattern) { | |
const jsTransformer = Resolver.findNodeModule( | |
- transform[customJSPattern], | |
- { basedir }); | |
+ transform[customJSPattern], | |
+ {basedir} | |
+ ); | |
if ( | |
- jsTransformer && | |
- jsTransformer.includes(NODE_MODULES + 'babel-jest')) | |
- { | |
+ jsTransformer && | |
+ jsTransformer.includes(NODE_MODULES + 'babel-jest') | |
+ ) { | |
babelJest = jsTransformer; | |
} | |
} | |
} else { | |
- babelJest = Resolver.findNodeModule('babel-jest', { basedir }); | |
+ babelJest = Resolver.findNodeModule('babel-jest', {basedir}); | |
if (babelJest) { | |
options.transform = { | |
- [DEFAULT_JS_PATTERN]: 'babel-jest' }; | |
- | |
+ [DEFAULT_JS_PATTERN]: 'babel-jest', | |
+ }; | |
} | |
} | |
return babelJest; | |
}; | |
-const normalizeCollectCoverageOnlyFrom = ( | |
-options, | |
-key) => | |
-{ | |
- const collectCoverageOnlyFrom = Array.isArray(options[key]) ? | |
- options[key] // passed from argv | |
- : Object.keys(options[key]); // passed from options | |
+const normalizeCollectCoverageOnlyFrom = (options, key) => { | |
+ const collectCoverageOnlyFrom = Array.isArray(options[key]) | |
+ ? options[key] // passed from argv | |
+ : Object.keys(options[key]); // passed from options | |
return collectCoverageOnlyFrom.reduce((map, filePath) => { | |
filePath = path.resolve( | |
- options.rootDir, | |
- _replaceRootDirInPath(options.rootDir, filePath)); | |
+ options.rootDir, | |
+ _replaceRootDirInPath(options.rootDir, filePath) | |
+ ); | |
map[filePath] = true; | |
return map; | |
@@ -157,10 +150,7 @@ const normalizeCollectCoverageFrom = (options, key) => { | |
return value; | |
}; | |
-const normalizeUnmockedModulePathPatterns = ( | |
-options, | |
-key) => | |
-{ | |
+const normalizeUnmockedModulePathPatterns = (options, key) => { | |
// _replaceRootDirTags is specifically well-suited for substituting | |
// <rootDir> in paths (it deals with properly interpreting relative path | |
// separators, etc). | |
@@ -168,33 +158,31 @@ key) => | |
// For patterns, direct global substitution is far more ideal, so we | |
// special case substitutions for patterns here. | |
return options[key].map(pattern => | |
- utils.replacePathSepForRegex( | |
- pattern.replace(/<rootDir>/g, options.rootDir))); | |
- | |
- | |
+ utils.replacePathSepForRegex(pattern.replace(/<rootDir>/g, options.rootDir)) | |
+ ); | |
}; | |
const normalizePreprocessor = options => { | |
/* eslint-disable max-len */ | |
if (options.scriptPreprocessor && options.transform) { | |
throw createConfigError( | |
- ` Options: ${chalk.bold('scriptPreprocessor')} and ${chalk.bold('transform')} cannot be used together. | |
- Please change your configuration to only use ${chalk.bold('transform')}.`); | |
- | |
+ ` Options: ${chalk.bold('scriptPreprocessor')} and ${chalk.bold('transform')} cannot be used together. | |
+ Please change your configuration to only use ${chalk.bold('transform')}.` | |
+ ); | |
} | |
if (options.preprocessorIgnorePatterns && options.transformIgnorePatterns) { | |
throw createConfigError( | |
- ` Options ${chalk.bold('preprocessorIgnorePatterns')} and ${chalk.bold('transformIgnorePatterns')} cannot be used together. | |
- Please change your configuration to only use ${chalk.bold('transformIgnorePatterns')}.`); | |
- | |
+ ` Options ${chalk.bold('preprocessorIgnorePatterns')} and ${chalk.bold('transformIgnorePatterns')} cannot be used together. | |
+ Please change your configuration to only use ${chalk.bold('transformIgnorePatterns')}.` | |
+ ); | |
} | |
/* eslint-enable max-len */ | |
if (options.scriptPreprocessor) { | |
options.transform = { | |
- '.*': options.scriptPreprocessor }; | |
- | |
+ '.*': options.scriptPreprocessor, | |
+ }; | |
} | |
if (options.preprocessorIgnorePatterns) { | |
@@ -208,10 +196,10 @@ const normalizePreprocessor = options => { | |
const normalizeMissingOptions = options => { | |
if (!options.name) { | |
- options.name = crypto. | |
- createHash('md5'). | |
- update(options.rootDir). | |
- digest('hex'); | |
+ options.name = crypto | |
+ .createHash('md5') | |
+ .update(options.rootDir) | |
+ .digest('hex'); | |
} | |
if (!options.setupFiles) { | |
@@ -225,8 +213,8 @@ const normalizeRootDir = options => { | |
// Assert that there *is* a rootDir | |
if (!options.hasOwnProperty('rootDir')) { | |
throw createConfigError( | |
- ` Configuration option ${chalk.bold('rootDir')} must be specified.`); | |
- | |
+ ` Configuration option ${chalk.bold('rootDir')} must be specified.` | |
+ ); | |
} | |
options.rootDir = path.normalize(options.rootDir); | |
return options; | |
@@ -240,28 +228,28 @@ const normalizeReporters = (options, basedir) => { | |
validateReporters(reporters); | |
options.reporters = reporters.map(reporterConfig => { | |
- const normalizedReporterConfig = typeof reporterConfig === | |
- 'string' ? | |
- // if reporter config is a string, we wrap it in an array | |
- // and pass an empty object for options argument, to normalize | |
- // the shape. | |
- [reporterConfig, {}] : | |
- reporterConfig; | |
+ const normalizedReporterConfig = typeof reporterConfig === 'string' | |
+ ? // if reporter config is a string, we wrap it in an array | |
+ // and pass an empty object for options argument, to normalize | |
+ // the shape. | |
+ [reporterConfig, {}] | |
+ : reporterConfig; | |
const reporterPath = _replaceRootDirInPath( | |
- options.rootDir, | |
- normalizedReporterConfig[0]); | |
- | |
+ options.rootDir, | |
+ normalizedReporterConfig[0] | |
+ ); | |
if (reporterPath !== DEFAULT_REPORTER_LABEL) { | |
const reporter = Resolver.findNodeModule(reporterPath, { | |
- basedir: options.rootDir }); | |
+ basedir: options.rootDir, | |
+ }); | |
if (!reporter) { | |
throw new Error( | |
- `Could not resolve a module for a custom reporter.\n` + | |
- ` Module name: ${reporterPath}`); | |
- | |
+ `Could not resolve a module for a custom reporter.\n` + | |
+ ` Module name: ${reporterPath}` | |
+ ); | |
} | |
normalizedReporterConfig[0] = reporter; | |
} | |
@@ -271,18 +259,19 @@ const normalizeReporters = (options, basedir) => { | |
return options; | |
}; | |
-function normalize(options, argv) {var _validate = | |
- validate(options, { | |
+function normalize(options, argv) { | |
+ var _validate = validate(options, { | |
comment: DOCUMENTATION_NOTE, | |
deprecatedConfig: DEPRECATED_CONFIG, | |
- exampleConfig: VALID_CONFIG });const hasDeprecationWarnings = _validate.hasDeprecationWarnings; | |
- | |
+ exampleConfig: VALID_CONFIG, | |
+ }); | |
+ const hasDeprecationWarnings = _validate.hasDeprecationWarnings; | |
options = normalizePreprocessor( | |
- normalizeReporters( | |
- normalizeMissingOptions(normalizeRootDir(setFromArgv(options, argv))))); | |
- | |
- | |
+ normalizeReporters( | |
+ normalizeMissingOptions(normalizeRootDir(setFromArgv(options, argv))) | |
+ ) | |
+ ); | |
if (options.preset) { | |
options = setupPreset(options, options.preset); | |
@@ -317,18 +306,19 @@ function normalize(options, argv) {var _validate = | |
case 'setupFiles': | |
case 'snapshotSerializers': | |
value = | |
- options[key] && | |
- options[key].map(resolve.bind(null, options.rootDir, key)); | |
+ options[key] && | |
+ options[key].map(resolve.bind(null, options.rootDir, key)); | |
break; | |
case 'modulePaths': | |
case 'roots': | |
value = | |
- options[key] && | |
- options[key].map(filePath => | |
- path.resolve( | |
- options.rootDir, | |
- _replaceRootDirInPath(options.rootDir, filePath))); | |
- | |
+ options[key] && | |
+ options[key].map(filePath => | |
+ path.resolve( | |
+ options.rootDir, | |
+ _replaceRootDirInPath(options.rootDir, filePath) | |
+ ) | |
+ ); | |
break; | |
case 'collectCoverageFrom': | |
@@ -337,10 +327,11 @@ function normalize(options, argv) {var _validate = | |
case 'cacheDirectory': | |
case 'coverageDirectory': | |
value = | |
- options[key] && | |
- path.resolve( | |
- options.rootDir, | |
- _replaceRootDirInPath(options.rootDir, options[key])); | |
+ options[key] && | |
+ path.resolve( | |
+ options.rootDir, | |
+ _replaceRootDirInPath(options.rootDir, options[key]) | |
+ ); | |
break; | |
case 'moduleLoader': | |
@@ -353,19 +344,20 @@ function normalize(options, argv) {var _validate = | |
case 'moduleNameMapper': | |
const moduleNameMapper = options[key]; | |
value = | |
- moduleNameMapper && | |
- Object.keys(moduleNameMapper).map(regex => { | |
- const item = moduleNameMapper && moduleNameMapper[regex]; | |
- return item && [regex, _replaceRootDirTags(options.rootDir, item)]; | |
- }); | |
+ moduleNameMapper && | |
+ Object.keys(moduleNameMapper).map(regex => { | |
+ const item = moduleNameMapper && moduleNameMapper[regex]; | |
+ return item && [regex, _replaceRootDirTags(options.rootDir, item)]; | |
+ }); | |
break; | |
case 'transform': | |
const transform = options[key]; | |
value = | |
- transform && | |
- Object.keys(transform).map(regex => [ | |
- regex, | |
- resolve(options.rootDir, key, transform[regex])]); | |
+ transform && | |
+ Object.keys(transform).map(regex => [ | |
+ regex, | |
+ resolve(options.rootDir, key, transform[regex]), | |
+ ]); | |
break; | |
case 'coveragePathIgnorePatterns': | |
@@ -379,21 +371,22 @@ function normalize(options, argv) {var _validate = | |
value = Object.assign({}, options[key]); | |
if (value.hasteImplModulePath != null) { | |
value.hasteImplModulePath = resolve( | |
- options.rootDir, | |
- 'haste.hasteImplModulePath', | |
- _replaceRootDirInPath(options.rootDir, value.hasteImplModulePath)); | |
- | |
+ options.rootDir, | |
+ 'haste.hasteImplModulePath', | |
+ _replaceRootDirInPath(options.rootDir, value.hasteImplModulePath) | |
+ ); | |
} | |
break; | |
case 'projects': | |
const projects = options[key]; | |
let list = []; | |
projects && | |
- projects.forEach( | |
- filePath => | |
- list = list.concat( | |
- glob.sync(_replaceRootDirInPath(options.rootDir, filePath)))); | |
- | |
+ projects.forEach( | |
+ filePath => | |
+ (list = list.concat( | |
+ glob.sync(_replaceRootDirInPath(options.rootDir, filePath)) | |
+ )) | |
+ ); | |
value = list; | |
break; | |
@@ -431,21 +424,22 @@ function normalize(options, argv) {var _validate = | |
case 'watch': | |
case 'watchman': | |
value = options[key]; | |
- break;} | |
+ break; | |
+ } | |
newOptions[key] = value; | |
return newOptions; | |
}, newOptions); | |
- newOptions.updateSnapshot = argv.ci && !argv.updateSnapshot ? | |
- 'none' : | |
- argv.updateSnapshot ? 'all' : 'new'; | |
+ newOptions.updateSnapshot = argv.ci && !argv.updateSnapshot | |
+ ? 'none' | |
+ : argv.updateSnapshot ? 'all' : 'new'; | |
if (babelJest) { | |
const regeneratorRuntimePath = Resolver.findNodeModule( | |
- 'regenerator-runtime/runtime', | |
- { basedir: options.rootDir }); | |
- | |
+ 'regenerator-runtime/runtime', | |
+ {basedir: options.rootDir} | |
+ ); | |
if (regeneratorRuntimePath) { | |
newOptions.setupFiles.unshift(regeneratorRuntimePath); | |
@@ -454,9 +448,9 @@ function normalize(options, argv) {var _validate = | |
if (options.testRegex && options.testMatch) { | |
throw createConfigError( | |
- ` Configuration options ${chalk.bold('testMatch')} and` + | |
- ` ${chalk.bold('testRegex')} cannot be used together.`); | |
- | |
+ ` Configuration options ${chalk.bold('testMatch')} and` + | |
+ ` ${chalk.bold('testRegex')} cannot be used together.` | |
+ ); | |
} | |
if (options.testRegex && !options.testMatch) { | |
@@ -467,14 +461,14 @@ function normalize(options, argv) {var _validate = | |
// If argv.json is set, coverageReporters shouldn't print a text report. | |
if (argv.json) { | |
- newOptions.coverageReporters = (newOptions.coverageReporters || []). | |
- filter(reporter => reporter !== 'text'); | |
+ newOptions.coverageReporters = (newOptions.coverageReporters || []) | |
+ .filter(reporter => reporter !== 'text'); | |
} | |
return { | |
hasDeprecationWarnings, | |
- options: newOptions }; | |
- | |
+ options: newOptions, | |
+ }; | |
} | |
-module.exports = normalize; | |
\ No newline at end of file | |
+module.exports = normalize; | |
diff --git i/packages/jest-config/build/reporterValidationErrors.js w/packages/jest-config/build/reporterValidationErrors.js | |
index 75b9e31e..00a8e6e4 100644 | |
--- i/packages/jest-config/build/reporterValidationErrors.js | |
+++ w/packages/jest-config/build/reporterValidationErrors.js | |
@@ -7,15 +7,55 @@ | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _require = | |
- | |
- | |
- | |
-require('jest-validate');const ValidationError = _require.ValidationError;var _require2 = | |
-require('./utils');const DOCUMENTATION_NOTE = _require2.DOCUMENTATION_NOTE,BULLET = _require2.BULLET; | |
- | |
-const chalk = require('chalk');var _require3 = | |
-require('jest-matcher-utils');const getType = _require3.getType; | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
+var _require = require('jest-validate'); | |
+const ValidationError = _require.ValidationError; | |
+var _require2 = require('./utils'); | |
+const DOCUMENTATION_NOTE = _require2.DOCUMENTATION_NOTE, | |
+ BULLET = _require2.BULLET; | |
+ | |
+const chalk = require('chalk'); | |
+var _require3 = require('jest-matcher-utils'); | |
+const getType = _require3.getType; | |
const validReporterTypes = ['array', 'string']; | |
const ERROR = `${BULLET} Reporter Validation Error`; | |
@@ -28,45 +68,40 @@ const ERROR = `${BULLET} Reporter Validation Error`; | |
* merged with jest-validate. Till then, we can make use of it. It works | |
* and that's what counts most at this time. | |
*/ | |
-function createReporterError( | |
-reporterIndex, | |
-reporterValue) | |
-{ | |
+function createReporterError(reporterIndex, reporterValue) { | |
const errorMessage = | |
- `Reporter at index ${reporterIndex} must be of type:\n` + | |
- ` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` + | |
- ` but instead received:\n` + | |
- ` ${chalk.bold.red(getType(reporterValue))}`; | |
+ `Reporter at index ${reporterIndex} must be of type:\n` + | |
+ ` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` + | |
+ ` but instead received:\n` + | |
+ ` ${chalk.bold.red(getType(reporterValue))}`; | |
return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); | |
} | |
function createArrayReporterError( | |
-arrayReporter, | |
-reporterIndex, | |
-valueIndex, | |
-value, | |
-expectedType, | |
-valueName) | |
-{ | |
+ arrayReporter, | |
+ reporterIndex, | |
+ valueIndex, | |
+ value, | |
+ expectedType, | |
+ valueName | |
+) { | |
const errorMessage = | |
- `Unexpected value for ${valueName} ` + | |
- `at index ${valueIndex} of reporter at index ${reporterIndex}\n` + | |
- ' Expected:\n' + | |
- ` ${chalk.bold.red(expectedType)}\n` + | |
- ' Got:\n' + | |
- ` ${chalk.bold.green(getType(value))}\n` + | |
- ` Reporter configuration:\n` + | |
- ` ${chalk.bold.green(JSON.stringify(arrayReporter, null, 2). | |
- split('\n'). | |
- join('\n '))}`; | |
+ `Unexpected value for ${valueName} ` + | |
+ `at index ${valueIndex} of reporter at index ${reporterIndex}\n` + | |
+ ' Expected:\n' + | |
+ ` ${chalk.bold.red(expectedType)}\n` + | |
+ ' Got:\n' + | |
+ ` ${chalk.bold.green(getType(value))}\n` + | |
+ ` Reporter configuration:\n` + | |
+ ` ${chalk.bold.green(JSON.stringify(arrayReporter, null, 2) | |
+ .split('\n') | |
+ .join('\n '))}`; | |
return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE); | |
} | |
-function validateReporters( | |
-reporterConfig) | |
-{ | |
+function validateReporters(reporterConfig) { | |
return reporterConfig.every((reporter, index) => { | |
if (Array.isArray(reporter)) { | |
validateArrayReporter(reporter, index); | |
@@ -78,33 +113,32 @@ reporterConfig) | |
}); | |
} | |
-function validateArrayReporter( | |
-arrayReporter, | |
-reporterIndex) | |
-{var _arrayReporter = _slicedToArray( | |
- arrayReporter, 2);const path = _arrayReporter[0],options = _arrayReporter[1]; | |
+function validateArrayReporter(arrayReporter, reporterIndex) { | |
+ var _arrayReporter = _slicedToArray(arrayReporter, 2); | |
+ const path = _arrayReporter[0], options = _arrayReporter[1]; | |
if (typeof path !== 'string') { | |
throw createArrayReporterError( | |
- arrayReporter, | |
- reporterIndex, | |
- 0, | |
- path, | |
- 'string', | |
- 'Path'); | |
- | |
+ arrayReporter, | |
+ reporterIndex, | |
+ 0, | |
+ path, | |
+ 'string', | |
+ 'Path' | |
+ ); | |
} else if (typeof options !== 'object') { | |
throw createArrayReporterError( | |
- arrayReporter, | |
- reporterIndex, | |
- 1, | |
- options, | |
- 'object', | |
- 'Reporter Configuration'); | |
- | |
+ arrayReporter, | |
+ reporterIndex, | |
+ 1, | |
+ options, | |
+ 'object', | |
+ 'Reporter Configuration' | |
+ ); | |
} | |
} | |
module.exports = { | |
createArrayReporterError, | |
createReporterError, | |
- validateReporters }; | |
\ No newline at end of file | |
+ validateReporters, | |
+}; | |
diff --git i/packages/jest-config/build/setFromArgv.js w/packages/jest-config/build/setFromArgv.js | |
index a473d73c..76d6e9be 100644 | |
--- i/packages/jest-config/build/setFromArgv.js | |
+++ w/packages/jest-config/build/setFromArgv.js | |
@@ -10,52 +10,51 @@ | |
'use strict'; | |
- | |
- | |
- | |
-const specialArgs = ['_', '$0', 'h', 'help', 'config'];var _require = | |
-require('./utils');const isJSONString = _require.isJSONString; | |
+const specialArgs = ['_', '$0', 'h', 'help', 'config']; | |
+var _require = require('./utils'); | |
+const isJSONString = _require.isJSONString; | |
function setFromArgv(options, argv) { | |
- const argvToOptions = Object.keys(argv). | |
- filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1). | |
- reduce((options, key) => { | |
- switch (key) { | |
- case 'coverage': | |
- options.collectCoverage = argv[key]; | |
- break; | |
- case 'json': | |
- options.useStderr = argv[key]; | |
- break; | |
- case 'watchAll': | |
- options.watch = argv[key]; | |
- break; | |
- case 'env': | |
- options.testEnvironment = argv[key]; | |
- break; | |
- case 'config': | |
- break; | |
- case 'coverageThreshold': | |
- case 'globals': | |
- case 'moduleNameMapper': | |
- case 'transform': | |
- case 'haste': | |
- if (isJSONString(argv[key])) { | |
- options[key] = JSON.parse(argv[key]); | |
- } | |
- break; | |
- default: | |
- options[key] = argv[key];} | |
- | |
- return options; | |
- }, {}); | |
+ const argvToOptions = Object.keys(argv) | |
+ .filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1) | |
+ .reduce((options, key) => { | |
+ switch (key) { | |
+ case 'coverage': | |
+ options.collectCoverage = argv[key]; | |
+ break; | |
+ case 'json': | |
+ options.useStderr = argv[key]; | |
+ break; | |
+ case 'watchAll': | |
+ options.watch = argv[key]; | |
+ break; | |
+ case 'env': | |
+ options.testEnvironment = argv[key]; | |
+ break; | |
+ case 'config': | |
+ break; | |
+ case 'coverageThreshold': | |
+ case 'globals': | |
+ case 'moduleNameMapper': | |
+ case 'transform': | |
+ case 'haste': | |
+ if (isJSONString(argv[key])) { | |
+ options[key] = JSON.parse(argv[key]); | |
+ } | |
+ break; | |
+ default: | |
+ options[key] = argv[key]; | |
+ } | |
+ | |
+ return options; | |
+ }, {}); | |
return Object.assign( | |
- {}, | |
- options, | |
- isJSONString(argv.config) ? JSON.parse(argv.config) : null, | |
- argvToOptions); | |
- | |
+ {}, | |
+ options, | |
+ isJSONString(argv.config) ? JSON.parse(argv.config) : null, | |
+ argvToOptions | |
+ ); | |
} | |
-module.exports = setFromArgv; | |
\ No newline at end of file | |
+module.exports = setFromArgv; | |
diff --git i/packages/jest-config/build/utils.js w/packages/jest-config/build/utils.js | |
index 52a13f43..11cd6fbf 100644 | |
--- i/packages/jest-config/build/utils.js | |
+++ w/packages/jest-config/build/utils.js | |
@@ -8,11 +8,9 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('jest-validate');const ValidationError = _require.ValidationError; | |
+'use strict'; | |
+var _require = require('jest-validate'); | |
+const ValidationError = _require.ValidationError; | |
const Resolver = require('jest-resolve'); | |
const path = require('path'); | |
const chalk = require('chalk'); | |
@@ -23,24 +21,25 @@ const DOCUMENTATION_NOTE = ` ${chalk.bold('Configuration Documentation:')} | |
const createValidationError = message => { | |
return new ValidationError( | |
- `${BULLET}Validation Error`, | |
- message, | |
- DOCUMENTATION_NOTE); | |
- | |
+ `${BULLET}Validation Error`, | |
+ message, | |
+ DOCUMENTATION_NOTE | |
+ ); | |
}; | |
const resolve = (rootDir, key, filePath) => { | |
const module = Resolver.findNodeModule( | |
- _replaceRootDirInPath(rootDir, filePath), | |
- { | |
- basedir: rootDir }); | |
- | |
- | |
+ _replaceRootDirInPath(rootDir, filePath), | |
+ { | |
+ basedir: rootDir, | |
+ } | |
+ ); | |
if (!module) { | |
/* eslint-disable max-len */ | |
throw createValidationError( | |
- ` Module ${chalk.bold(filePath)} in the ${chalk.bold(key)} option was not found.`); | |
+ ` Module ${chalk.bold(filePath)} in the ${chalk.bold(key)} option was not found.` | |
+ ); | |
/* eslint-disable max-len */ | |
} | |
@@ -54,18 +53,18 @@ const _replaceRootDirInPath = (rootDir, filePath) => { | |
} | |
return path.resolve( | |
- rootDir, | |
- path.normalize('./' + filePath.substr('<rootDir>'.length))); | |
- | |
+ rootDir, | |
+ path.normalize('./' + filePath.substr('<rootDir>'.length)) | |
+ ); | |
}; | |
const _replaceRootDirInObject = (rootDir, config) => { | |
if (config !== null) { | |
const newConfig = {}; | |
for (const configKey in config) { | |
- newConfig[configKey] = configKey === 'rootDir' ? | |
- config[configKey] : | |
- _replaceRootDirTags(rootDir, config[configKey]); | |
+ newConfig[configKey] = configKey === 'rootDir' | |
+ ? config[configKey] | |
+ : _replaceRootDirTags(rootDir, config[configKey]); | |
} | |
return newConfig; | |
} | |
@@ -83,7 +82,8 @@ const _replaceRootDirTags = (rootDir, config) => { | |
} | |
return _replaceRootDirInObject(rootDir, config); | |
case 'string': | |
- return _replaceRootDirInPath(rootDir, config);} | |
+ return _replaceRootDirInPath(rootDir, config); | |
+ } | |
return config; | |
}; | |
@@ -99,7 +99,8 @@ const _replaceRootDirTags = (rootDir, config) => { | |
const getTestEnvironment = config => { | |
const env = config.testEnvironment; | |
let module = Resolver.findNodeModule(`jest-environment-${env}`, { | |
- basedir: config.rootDir }); | |
+ basedir: config.rootDir, | |
+ }); | |
if (module) { | |
return module; | |
@@ -109,7 +110,7 @@ const getTestEnvironment = config => { | |
return require.resolve(`jest-environment-${env}`); | |
} catch (e) {} | |
- module = Resolver.findNodeModule(env, { basedir: config.rootDir }); | |
+ module = Resolver.findNodeModule(env, {basedir: config.rootDir}); | |
if (module) { | |
return module; | |
} | |
@@ -120,16 +121,17 @@ const getTestEnvironment = config => { | |
/* eslint-disable max-len */ | |
throw createValidationError( | |
- ` Test environment ${chalk.bold(env)} cannot be found. Make sure the ${chalk.bold('testEnvironment')} configuration option points to an existing node module.`); | |
+ ` Test environment ${chalk.bold(env)} cannot be found. Make sure the ${chalk.bold('testEnvironment')} configuration option points to an existing node module.` | |
+ ); | |
/* eslint-disable max-len */ | |
}; | |
const isJSONString = text => | |
-text && | |
-typeof text === 'string' && | |
-text.startsWith('{') && | |
-text.endsWith('}'); | |
+ text && | |
+ typeof text === 'string' && | |
+ text.startsWith('{') && | |
+ text.endsWith('}'); | |
module.exports = { | |
BULLET, | |
@@ -138,4 +140,5 @@ module.exports = { | |
_replaceRootDirTags, | |
getTestEnvironment, | |
isJSONString, | |
- resolve }; | |
\ No newline at end of file | |
+ resolve, | |
+}; | |
diff --git i/packages/jest-config/build/validConfig.js w/packages/jest-config/build/validConfig.js | |
index 39b262a2..70959987 100644 | |
--- i/packages/jest-config/build/validConfig.js | |
+++ w/packages/jest-config/build/validConfig.js | |
@@ -10,10 +10,9 @@ | |
'use strict'; | |
- | |
- | |
-const constants = require('./constants');var _require = | |
-require('jest-regex-util');const replacePathSepForRegex = _require.replacePathSepForRegex; | |
+const constants = require('./constants'); | |
+var _require = require('jest-regex-util'); | |
+const replacePathSepForRegex = _require.replacePathSepForRegex; | |
const NODE_MODULES_REGEXP = replacePathSepForRegex(constants.NODE_MODULES); | |
@@ -27,21 +26,24 @@ module.exports = { | |
collectCoverage: true, | |
collectCoverageFrom: ['src', '!public'], | |
collectCoverageOnlyFrom: { | |
- '<rootDir>/this-directory-is-covered/covered.js': true }, | |
+ '<rootDir>/this-directory-is-covered/covered.js': true, | |
+ }, | |
coverageDirectory: 'coverage', | |
coveragePathIgnorePatterns: [NODE_MODULES_REGEXP], | |
coverageReporters: ['json', 'text', 'lcov', 'clover'], | |
coverageThreshold: { | |
global: { | |
- branches: 50 } }, | |
- | |
+ branches: 50, | |
+ }, | |
+ }, | |
expand: false, | |
forceExit: false, | |
globals: {}, | |
haste: { | |
- providesModuleNodeModules: ['react', 'react-native'] }, | |
+ providesModuleNodeModules: ['react', 'react-native'], | |
+ }, | |
logHeapUsage: true, | |
mapCoverage: false, | |
@@ -49,7 +51,8 @@ module.exports = { | |
moduleFileExtensions: ['js', 'json', 'jsx', 'node'], | |
moduleLoader: '<rootDir>', | |
moduleNameMapper: { | |
- '^React$': '<rootDir>/node_modules/react' }, | |
+ '^React$': '<rootDir>/node_modules/react', | |
+ }, | |
modulePathIgnorePatterns: ['<rootDir>/build/'], | |
modulePaths: ['/shared/vendor/modules'], | |
@@ -59,9 +62,10 @@ module.exports = { | |
preset: 'react-native', | |
projects: ['project-a', 'project-b/'], | |
reporters: [ | |
- 'default', | |
- 'custom-reporter-1', | |
- ['custom-reporter-2', { configValue: true }]], | |
+ 'default', | |
+ 'custom-reporter-1', | |
+ ['custom-reporter-2', {configValue: true}], | |
+ ], | |
resetMocks: false, | |
resetModules: false, | |
@@ -82,7 +86,8 @@ module.exports = { | |
testURL: 'about:blank', | |
timers: 'real', | |
transform: { | |
- '^.+\\.js$': '<rootDir>/preprocessor.js' }, | |
+ '^.+\\.js$': '<rootDir>/preprocessor.js', | |
+ }, | |
transformIgnorePatterns: [NODE_MODULES_REGEXP], | |
unmockedModulePathPatterns: ['mock'], | |
@@ -90,4 +95,5 @@ module.exports = { | |
useStderr: false, | |
verbose: false, | |
watch: false, | |
- watchman: true }; | |
\ No newline at end of file | |
+ watchman: true, | |
+}; | |
diff --git i/packages/jest-config/build/vendor/jsonlint.js w/packages/jest-config/build/vendor/jsonlint.js | |
index 3546a1bc..75b01677 100644 | |
--- i/packages/jest-config/build/vendor/jsonlint.js | |
+++ w/packages/jest-config/build/vendor/jsonlint.js | |
@@ -1,7 +1,7 @@ | |
// From: https://github.com/zaach/jsonlint | |
// Vendored in Jest to avoid jsonlint's transitive dependencies. | |
/* eslint-disable */ | |
-var jsonlint = function () { | |
+var jsonlint = (function() { | |
var parser = { | |
trace: function trace() {}, | |
yy: {}, | |
@@ -31,7 +31,8 @@ var jsonlint = function () { | |
']': 24, | |
JSONElementList: 25, | |
$accept: 0, | |
- $end: 1 }, | |
+ $end: 1, | |
+ }, | |
terminals_: { | |
2: 'error', | |
@@ -46,52 +47,54 @@ var jsonlint = function () { | |
21: ':', | |
22: ',', | |
23: '[', | |
- 24: ']' }, | |
+ 24: ']', | |
+ }, | |
productions_: [ | |
- 0, | |
- [3, 1], | |
- [5, 1], | |
- [7, 1], | |
- [9, 1], | |
- [9, 1], | |
- [12, 2], | |
- [13, 1], | |
- [13, 1], | |
- [13, 1], | |
- [13, 1], | |
- [13, 1], | |
- [13, 1], | |
- [15, 2], | |
- [15, 3], | |
- [20, 3], | |
- [19, 1], | |
- [19, 3], | |
- [16, 2], | |
- [16, 3], | |
- [25, 1], | |
- [25, 3]], | |
+ 0, | |
+ [3, 1], | |
+ [5, 1], | |
+ [7, 1], | |
+ [9, 1], | |
+ [9, 1], | |
+ [12, 2], | |
+ [13, 1], | |
+ [13, 1], | |
+ [13, 1], | |
+ [13, 1], | |
+ [13, 1], | |
+ [13, 1], | |
+ [15, 2], | |
+ [15, 3], | |
+ [20, 3], | |
+ [19, 1], | |
+ [19, 3], | |
+ [16, 2], | |
+ [16, 3], | |
+ [25, 1], | |
+ [25, 3], | |
+ ], | |
performAction: function anonymous( | |
- yytext, | |
- yyleng, | |
- yylineno, | |
- yy, | |
- yystate, | |
- $$, | |
- _$) | |
- { | |
+ yytext, | |
+ yyleng, | |
+ yylineno, | |
+ yy, | |
+ yystate, | |
+ $$, | |
+ _$ | |
+ ) { | |
var $0 = $$.length - 1; | |
switch (yystate) { | |
case 1: // replace escaped characters with actual character | |
- this.$ = yytext. | |
- replace(/\\(\\|")/g, '$' + '1'). | |
- replace(/\\n/g, '\n'). | |
- replace(/\\r/g, '\r'). | |
- replace(/\\t/g, '\t'). | |
- replace(/\\v/g, '\v'). | |
- replace(/\\f/g, '\f'). | |
- replace(/\\b/g, '\b'); | |
+ this.$ = yytext | |
+ .replace(/\\(\\|")/g, '$' + '1') | |
+ .replace(/\\n/g, '\n') | |
+ .replace(/\\r/g, '\r') | |
+ .replace(/\\t/g, '\t') | |
+ .replace(/\\v/g, '\v') | |
+ .replace(/\\f/g, '\f') | |
+ .replace(/\\b/g, '\b'); | |
break; | |
case 2: | |
@@ -107,7 +110,7 @@ var jsonlint = function () { | |
this.$ = false; | |
break; | |
case 6: | |
- return this.$ = $$[$0 - 1]; | |
+ return (this.$ = $$[$0 - 1]); | |
break; | |
case 13: | |
this.$ = {}; | |
@@ -138,122 +141,127 @@ var jsonlint = function () { | |
case 21: | |
this.$ = $$[$0 - 2]; | |
$$[$0 - 2].push($$[$0]); | |
- break;} | |
- | |
+ break; | |
+ } | |
}, | |
table: [ | |
- { | |
- 3: 5, | |
- 4: [1, 12], | |
- 5: 6, | |
- 6: [1, 13], | |
- 7: 3, | |
- 8: [1, 9], | |
- 9: 4, | |
- 10: [1, 10], | |
- 11: [1, 11], | |
- 12: 1, | |
- 13: 2, | |
- 15: 7, | |
- 16: 8, | |
- 17: [1, 14], | |
- 23: [1, 15] }, | |
- | |
- { 1: [3] }, | |
- { 14: [1, 16] }, | |
- { 14: [2, 7], 18: [2, 7], 22: [2, 7], 24: [2, 7] }, | |
- { 14: [2, 8], 18: [2, 8], 22: [2, 8], 24: [2, 8] }, | |
- { 14: [2, 9], 18: [2, 9], 22: [2, 9], 24: [2, 9] }, | |
- { 14: [2, 10], 18: [2, 10], 22: [2, 10], 24: [2, 10] }, | |
- { 14: [2, 11], 18: [2, 11], 22: [2, 11], 24: [2, 11] }, | |
- { 14: [2, 12], 18: [2, 12], 22: [2, 12], 24: [2, 12] }, | |
- { 14: [2, 3], 18: [2, 3], 22: [2, 3], 24: [2, 3] }, | |
- { 14: [2, 4], 18: [2, 4], 22: [2, 4], 24: [2, 4] }, | |
- { 14: [2, 5], 18: [2, 5], 22: [2, 5], 24: [2, 5] }, | |
- { 14: [2, 1], 18: [2, 1], 21: [2, 1], 22: [2, 1], 24: [2, 1] }, | |
- { 14: [2, 2], 18: [2, 2], 22: [2, 2], 24: [2, 2] }, | |
- { 3: 20, 4: [1, 12], 18: [1, 17], 19: 18, 20: 19 }, | |
- { | |
- 3: 5, | |
- 4: [1, 12], | |
- 5: 6, | |
- 6: [1, 13], | |
- 7: 3, | |
- 8: [1, 9], | |
- 9: 4, | |
- 10: [1, 10], | |
- 11: [1, 11], | |
- 13: 23, | |
- 15: 7, | |
- 16: 8, | |
- 17: [1, 14], | |
- 23: [1, 15], | |
- 24: [1, 21], | |
- 25: 22 }, | |
- | |
- { 1: [2, 6] }, | |
- { 14: [2, 13], 18: [2, 13], 22: [2, 13], 24: [2, 13] }, | |
- { 18: [1, 24], 22: [1, 25] }, | |
- { 18: [2, 16], 22: [2, 16] }, | |
- { 21: [1, 26] }, | |
- { 14: [2, 18], 18: [2, 18], 22: [2, 18], 24: [2, 18] }, | |
- { 22: [1, 28], 24: [1, 27] }, | |
- { 22: [2, 20], 24: [2, 20] }, | |
- { 14: [2, 14], 18: [2, 14], 22: [2, 14], 24: [2, 14] }, | |
- { 3: 20, 4: [1, 12], 20: 29 }, | |
- { | |
- 3: 5, | |
- 4: [1, 12], | |
- 5: 6, | |
- 6: [1, 13], | |
- 7: 3, | |
- 8: [1, 9], | |
- 9: 4, | |
- 10: [1, 10], | |
- 11: [1, 11], | |
- 13: 30, | |
- 15: 7, | |
- 16: 8, | |
- 17: [1, 14], | |
- 23: [1, 15] }, | |
- | |
- { 14: [2, 19], 18: [2, 19], 22: [2, 19], 24: [2, 19] }, | |
- { | |
- 3: 5, | |
- 4: [1, 12], | |
- 5: 6, | |
- 6: [1, 13], | |
- 7: 3, | |
- 8: [1, 9], | |
- 9: 4, | |
- 10: [1, 10], | |
- 11: [1, 11], | |
- 13: 31, | |
- 15: 7, | |
- 16: 8, | |
- 17: [1, 14], | |
- 23: [1, 15] }, | |
- | |
- { 18: [2, 17], 22: [2, 17] }, | |
- { 18: [2, 15], 22: [2, 15] }, | |
- { 22: [2, 21], 24: [2, 21] }], | |
- | |
- defaultActions: { 16: [2, 6] }, | |
+ { | |
+ 3: 5, | |
+ 4: [1, 12], | |
+ 5: 6, | |
+ 6: [1, 13], | |
+ 7: 3, | |
+ 8: [1, 9], | |
+ 9: 4, | |
+ 10: [1, 10], | |
+ 11: [1, 11], | |
+ 12: 1, | |
+ 13: 2, | |
+ 15: 7, | |
+ 16: 8, | |
+ 17: [1, 14], | |
+ 23: [1, 15], | |
+ }, | |
+ | |
+ {1: [3]}, | |
+ {14: [1, 16]}, | |
+ {14: [2, 7], 18: [2, 7], 22: [2, 7], 24: [2, 7]}, | |
+ {14: [2, 8], 18: [2, 8], 22: [2, 8], 24: [2, 8]}, | |
+ {14: [2, 9], 18: [2, 9], 22: [2, 9], 24: [2, 9]}, | |
+ {14: [2, 10], 18: [2, 10], 22: [2, 10], 24: [2, 10]}, | |
+ {14: [2, 11], 18: [2, 11], 22: [2, 11], 24: [2, 11]}, | |
+ {14: [2, 12], 18: [2, 12], 22: [2, 12], 24: [2, 12]}, | |
+ {14: [2, 3], 18: [2, 3], 22: [2, 3], 24: [2, 3]}, | |
+ {14: [2, 4], 18: [2, 4], 22: [2, 4], 24: [2, 4]}, | |
+ {14: [2, 5], 18: [2, 5], 22: [2, 5], 24: [2, 5]}, | |
+ {14: [2, 1], 18: [2, 1], 21: [2, 1], 22: [2, 1], 24: [2, 1]}, | |
+ {14: [2, 2], 18: [2, 2], 22: [2, 2], 24: [2, 2]}, | |
+ {3: 20, 4: [1, 12], 18: [1, 17], 19: 18, 20: 19}, | |
+ { | |
+ 3: 5, | |
+ 4: [1, 12], | |
+ 5: 6, | |
+ 6: [1, 13], | |
+ 7: 3, | |
+ 8: [1, 9], | |
+ 9: 4, | |
+ 10: [1, 10], | |
+ 11: [1, 11], | |
+ 13: 23, | |
+ 15: 7, | |
+ 16: 8, | |
+ 17: [1, 14], | |
+ 23: [1, 15], | |
+ 24: [1, 21], | |
+ 25: 22, | |
+ }, | |
+ | |
+ {1: [2, 6]}, | |
+ {14: [2, 13], 18: [2, 13], 22: [2, 13], 24: [2, 13]}, | |
+ {18: [1, 24], 22: [1, 25]}, | |
+ {18: [2, 16], 22: [2, 16]}, | |
+ {21: [1, 26]}, | |
+ {14: [2, 18], 18: [2, 18], 22: [2, 18], 24: [2, 18]}, | |
+ {22: [1, 28], 24: [1, 27]}, | |
+ {22: [2, 20], 24: [2, 20]}, | |
+ {14: [2, 14], 18: [2, 14], 22: [2, 14], 24: [2, 14]}, | |
+ {3: 20, 4: [1, 12], 20: 29}, | |
+ { | |
+ 3: 5, | |
+ 4: [1, 12], | |
+ 5: 6, | |
+ 6: [1, 13], | |
+ 7: 3, | |
+ 8: [1, 9], | |
+ 9: 4, | |
+ 10: [1, 10], | |
+ 11: [1, 11], | |
+ 13: 30, | |
+ 15: 7, | |
+ 16: 8, | |
+ 17: [1, 14], | |
+ 23: [1, 15], | |
+ }, | |
+ | |
+ {14: [2, 19], 18: [2, 19], 22: [2, 19], 24: [2, 19]}, | |
+ { | |
+ 3: 5, | |
+ 4: [1, 12], | |
+ 5: 6, | |
+ 6: [1, 13], | |
+ 7: 3, | |
+ 8: [1, 9], | |
+ 9: 4, | |
+ 10: [1, 10], | |
+ 11: [1, 11], | |
+ 13: 31, | |
+ 15: 7, | |
+ 16: 8, | |
+ 17: [1, 14], | |
+ 23: [1, 15], | |
+ }, | |
+ | |
+ {18: [2, 17], 22: [2, 17]}, | |
+ {18: [2, 15], 22: [2, 15]}, | |
+ {22: [2, 21], 24: [2, 21]}, | |
+ ], | |
+ | |
+ defaultActions: {16: [2, 6]}, | |
parseError: function parseError(str, hash) { | |
throw new Error(str); | |
}, | |
parse: function parse(input) { | |
var self = this, | |
- stack = [0], | |
- vstack = [null], // semantic value stack | |
- lstack = [], // location stack | |
- table = this.table, | |
- yytext = '', | |
- yylineno = 0, | |
- yyleng = 0, | |
- recovering = 0, | |
- TERROR = 2, | |
- EOF = 1; | |
+ stack = [0], | |
+ vstack = [null], // semantic value stack | |
+ lstack = [], // location stack | |
+ table = this.table, | |
+ yytext = '', | |
+ yylineno = 0, | |
+ yyleng = 0, | |
+ recovering = 0, | |
+ TERROR = 2, | |
+ EOF = 1; | |
//this.reductionCount = this.shiftCount = 0; | |
@@ -265,7 +273,7 @@ var jsonlint = function () { | |
lstack.push(yyloc); | |
if (typeof this.yy.parseError === 'function') | |
- this.parseError = this.yy.parseError; | |
+ this.parseError = this.yy.parseError; | |
function popStack(n) { | |
stack.length = stack.length - 2 * n; | |
@@ -284,16 +292,16 @@ var jsonlint = function () { | |
} | |
var symbol, | |
- preErrorSymbol, | |
- state, | |
- action, | |
- a, | |
- r, | |
- yyval = {}, | |
- p, | |
- len, | |
- newState, | |
- expected; | |
+ preErrorSymbol, | |
+ state, | |
+ action, | |
+ a, | |
+ r, | |
+ yyval = {}, | |
+ p, | |
+ len, | |
+ newState, | |
+ expected; | |
while (true) { | |
// retreive state number from top of stack | |
state = stack[stack.length - 1]; | |
@@ -309,45 +317,45 @@ var jsonlint = function () { | |
// handle parse error | |
_handle_error: if ( | |
- typeof action === 'undefined' || | |
- !action.length || | |
- !action[0]) | |
- { | |
+ typeof action === 'undefined' || | |
+ !action.length || | |
+ !action[0] | |
+ ) { | |
if (!recovering) { | |
// Report error | |
expected = []; | |
for (p in table[state]) | |
- if (this.terminals_[p] && p > 2) { | |
- expected.push("'" + this.terminals_[p] + "'"); | |
- } | |
+ if (this.terminals_[p] && p > 2) { | |
+ expected.push("'" + this.terminals_[p] + "'"); | |
+ } | |
var errStr = ''; | |
if (this.lexer.showPosition) { | |
errStr = | |
- 'Parse error on line ' + ( | |
- yylineno + 1) + | |
- ':\n' + | |
- this.lexer.showPosition() + | |
- '\nExpecting ' + | |
- expected.join(', ') + | |
- ", got '" + | |
- this.terminals_[symbol] + | |
- "'"; | |
+ 'Parse error on line ' + | |
+ (yylineno + 1) + | |
+ ':\n' + | |
+ this.lexer.showPosition() + | |
+ '\nExpecting ' + | |
+ expected.join(', ') + | |
+ ", got '" + | |
+ this.terminals_[symbol] + | |
+ "'"; | |
} else { | |
errStr = | |
- 'Parse error on line ' + ( | |
- yylineno + 1) + | |
- ': Unexpected ' + ( | |
- symbol == 1 /*EOF*/ ? | |
- 'end of input' : | |
- "'" + (this.terminals_[symbol] || symbol) + "'"); | |
+ 'Parse error on line ' + | |
+ (yylineno + 1) + | |
+ ': Unexpected ' + | |
+ (symbol == 1 /*EOF*/ | |
+ ? 'end of input' | |
+ : "'" + (this.terminals_[symbol] || symbol) + "'"); | |
} | |
this.parseError(errStr, { | |
text: this.lexer.match, | |
token: this.terminals_[symbol] || symbol, | |
line: this.lexer.yylineno, | |
loc: yyloc, | |
- expected: expected }); | |
- | |
+ expected: expected, | |
+ }); | |
} | |
// just recovered from another error | |
@@ -387,11 +395,11 @@ var jsonlint = function () { | |
// this shouldn't happen, unless resolve defaults are off | |
if (action[0] instanceof Array && action.length > 1) { | |
throw new Error( | |
- 'Parse Error: multiple actions possible at state: ' + | |
- state + | |
- ', token: ' + | |
- symbol); | |
- | |
+ 'Parse Error: multiple actions possible at state: ' + | |
+ state + | |
+ ', token: ' + | |
+ symbol | |
+ ); | |
} | |
switch (action[0]) { | |
@@ -429,18 +437,19 @@ var jsonlint = function () { | |
first_line: lstack[lstack.length - (len || 1)].first_line, | |
last_line: lstack[lstack.length - 1].last_line, | |
first_column: lstack[lstack.length - (len || 1)].first_column, | |
- last_column: lstack[lstack.length - 1].last_column }; | |
+ last_column: lstack[lstack.length - 1].last_column, | |
+ }; | |
r = this.performAction.call( | |
- yyval, | |
- yytext, | |
- yyleng, | |
- yylineno, | |
- this.yy, | |
- action[1], | |
- vstack, | |
- lstack); | |
- | |
+ yyval, | |
+ yytext, | |
+ yyleng, | |
+ yylineno, | |
+ this.yy, | |
+ action[1], | |
+ vstack, | |
+ lstack | |
+ ); | |
if (typeof r !== 'undefined') { | |
return r; | |
@@ -462,15 +471,16 @@ var jsonlint = function () { | |
break; | |
case 3: // accept | |
- return true;} | |
- | |
+ return true; | |
+ } | |
} | |
return true; | |
- } }; | |
+ }, | |
+ }; | |
/* Jison generated lexer */ | |
- var lexer = function () { | |
+ var lexer = (function() { | |
var lexer = { | |
EOF: 1, | |
parseError: function parseError(str, hash) { | |
@@ -480,7 +490,7 @@ var jsonlint = function () { | |
throw new Error(str); | |
} | |
}, | |
- setInput: function (input) { | |
+ setInput: function(input) { | |
this._input = input; | |
this._more = this._less = this.done = false; | |
this.yylineno = this.yyleng = 0; | |
@@ -490,11 +500,12 @@ var jsonlint = function () { | |
first_line: 1, | |
first_column: 0, | |
last_line: 1, | |
- last_column: 0 }; | |
+ last_column: 0, | |
+ }; | |
return this; | |
}, | |
- input: function () { | |
+ input: function() { | |
var ch = this._input[0]; | |
this.yytext += ch; | |
this.yyleng++; | |
@@ -505,42 +516,43 @@ var jsonlint = function () { | |
this._input = this._input.slice(1); | |
return ch; | |
}, | |
- unput: function (ch) { | |
+ unput: function(ch) { | |
this._input = ch + this._input; | |
return this; | |
}, | |
- more: function () { | |
+ more: function() { | |
this._more = true; | |
return this; | |
}, | |
- less: function (n) { | |
+ less: function(n) { | |
this._input = this.match.slice(n) + this._input; | |
}, | |
- pastInput: function () { | |
+ pastInput: function() { | |
var past = this.matched.substr( | |
- 0, | |
- this.matched.length - this.match.length); | |
+ 0, | |
+ this.matched.length - this.match.length | |
+ ); | |
return ( | |
- (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '')); | |
- | |
+ (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') | |
+ ); | |
}, | |
- upcomingInput: function () { | |
+ upcomingInput: function() { | |
var next = this.match; | |
if (next.length < 20) { | |
next += this._input.substr(0, 20 - next.length); | |
} | |
return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace( | |
- /\n/g, | |
- ''); | |
- | |
+ /\n/g, | |
+ '' | |
+ ); | |
}, | |
- showPosition: function () { | |
+ showPosition: function() { | |
var pre = this.pastInput(); | |
var c = new Array(pre.length + 1).join('-'); | |
return pre + this.upcomingInput() + '\n' + c + '^'; | |
}, | |
- next: function () { | |
+ next: function() { | |
if (this.done) { | |
return this.EOF; | |
} | |
@@ -567,9 +579,10 @@ var jsonlint = function () { | |
first_line: this.yylloc.last_line, | |
last_line: this.yylineno + 1, | |
first_column: this.yylloc.last_column, | |
- last_column: lines ? | |
- lines[lines.length - 1].length - 1 : | |
- this.yylloc.last_column + match[0].length }; | |
+ last_column: lines | |
+ ? lines[lines.length - 1].length - 1 | |
+ : this.yylloc.last_column + match[0].length, | |
+ }; | |
this.yytext += match[0]; | |
this.match += match[0]; | |
@@ -578,26 +591,27 @@ var jsonlint = function () { | |
this._input = this._input.slice(match[0].length); | |
this.matched += match[0]; | |
token = this.performAction.call( | |
- this, | |
- this.yy, | |
- this, | |
- rules[index], | |
- this.conditionStack[this.conditionStack.length - 1]); | |
+ this, | |
+ this.yy, | |
+ this, | |
+ rules[index], | |
+ this.conditionStack[this.conditionStack.length - 1] | |
+ ); | |
if (this.done && this._input) this.done = false; | |
- if (token) return token;else | |
- return; | |
+ if (token) return token; | |
+ else return; | |
} | |
if (this._input === '') { | |
return this.EOF; | |
} else { | |
this.parseError( | |
- 'Lexical error on line ' + ( | |
- this.yylineno + 1) + | |
- '. Unrecognized text.\n' + | |
- this.showPosition(), | |
- { text: '', token: null, line: this.yylineno }); | |
- | |
+ 'Lexical error on line ' + | |
+ (this.yylineno + 1) + | |
+ '. Unrecognized text.\n' + | |
+ this.showPosition(), | |
+ {text: '', token: null, line: this.yylineno} | |
+ ); | |
} | |
}, | |
lex: function lex() { | |
@@ -616,23 +630,24 @@ var jsonlint = function () { | |
}, | |
_currentRules: function _currentRules() { | |
return this.conditions[ | |
- this.conditionStack[this.conditionStack.length - 1]]. | |
- rules; | |
+ this.conditionStack[this.conditionStack.length - 1] | |
+ ].rules; | |
}, | |
- topState: function () { | |
+ topState: function() { | |
return this.conditionStack[this.conditionStack.length - 2]; | |
}, | |
pushState: function begin(condition) { | |
this.begin(condition); | |
- } }; | |
+ }, | |
+ }; | |
lexer.options = {}; | |
lexer.performAction = function anonymous( | |
- yy, | |
- yy_, | |
- $avoiding_name_collisions, | |
- YY_START) | |
- { | |
+ yy, | |
+ yy_, | |
+ $avoiding_name_collisions, | |
+ YY_START | |
+ ) { | |
var YYSTATE = YY_START; | |
switch ($avoiding_name_collisions) { | |
case 0 /* skip whitespace */: | |
@@ -676,59 +691,60 @@ var jsonlint = function () { | |
break; | |
case 13: | |
return 'INVALID'; | |
- break;} | |
- | |
+ break; | |
+ } | |
}; | |
lexer.rules = [ | |
- /^(?:\s+)/, | |
- /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/, | |
- /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/, | |
- /^(?:\{)/, | |
- /^(?:\})/, | |
- /^(?:\[)/, | |
- /^(?:\])/, | |
- /^(?:,)/, | |
- /^(?::)/, | |
- /^(?:true\b)/, | |
- /^(?:false\b)/, | |
- /^(?:null\b)/, | |
- /^(?:$)/, | |
- /^(?:.)/]; | |
+ /^(?:\s+)/, | |
+ /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/, | |
+ /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/, | |
+ /^(?:\{)/, | |
+ /^(?:\})/, | |
+ /^(?:\[)/, | |
+ /^(?:\])/, | |
+ /^(?:,)/, | |
+ /^(?::)/, | |
+ /^(?:true\b)/, | |
+ /^(?:false\b)/, | |
+ /^(?:null\b)/, | |
+ /^(?:$)/, | |
+ /^(?:.)/, | |
+ ]; | |
lexer.conditions = { | |
INITIAL: { | |
rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], | |
- inclusive: true } }; | |
- | |
- | |
+ inclusive: true, | |
+ }, | |
+ }; | |
return lexer; | |
- }(); | |
+ })(); | |
parser.lexer = lexer; | |
return parser; | |
-}(); | |
+})(); | |
exports.parser = jsonlint; | |
-exports.errors = function (input) { | |
+exports.errors = function(input) { | |
try { | |
this.parse(input); | |
} catch (e) { | |
return e.stack; | |
} | |
}; | |
-exports.parse = function () { | |
+exports.parse = function() { | |
return jsonlint.parse.apply(jsonlint, arguments); | |
}; | |
exports.main = function commonjsMain(args) { | |
if (!args[1]) throw new Error('Usage: ' + args[0] + ' FILE'); | |
if (typeof process !== 'undefined') { | |
var source = require('fs').readFileSync( | |
- require('path').join(process.cwd(), args[1]), | |
- 'utf8'); | |
- | |
+ require('path').join(process.cwd(), args[1]), | |
+ 'utf8' | |
+ ); | |
} else { | |
var cwd = require('file').path(require('file').cwd()); | |
- var source = cwd.join(args[1]).read({ charset: 'utf-8' }); | |
+ var source = cwd.join(args[1]).read({charset: 'utf-8'}); | |
} | |
return exports.parser.parse(source); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-diff/build/constants.js w/packages/jest-diff/build/constants.js | |
index 2326bbfa..dc3f11fe 100644 | |
--- i/packages/jest-diff/build/constants.js | |
+++ w/packages/jest-diff/build/constants.js | |
@@ -13,9 +13,10 @@ | |
const chalk = require('chalk'); | |
exports.NO_DIFF_MESSAGE = chalk.dim( | |
-'Compared values have no visual difference.'); | |
- | |
+ 'Compared values have no visual difference.' | |
+); | |
exports.SIMILAR_MESSAGE = chalk.dim( | |
-'Compared values serialize to the same structure.\n' + | |
-'Printing internal object structure without calling `toJSON` instead.'); | |
\ No newline at end of file | |
+ 'Compared values serialize to the same structure.\n' + | |
+ 'Printing internal object structure without calling `toJSON` instead.' | |
+); | |
diff --git i/packages/jest-diff/build/diffStrings.js w/packages/jest-diff/build/diffStrings.js | |
index 9566e9a6..3763f417 100644 | |
--- i/packages/jest-diff/build/diffStrings.js | |
+++ w/packages/jest-diff/build/diffStrings.js | |
@@ -11,73 +11,57 @@ | |
'use strict'; | |
const chalk = require('chalk'); | |
-const diff = require('diff');var _require = | |
- | |
-require('./constants.js');const NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE; | |
+const diff = require('diff'); | |
+var _require = require('./constants.js'); | |
+const NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE; | |
const DIFF_CONTEXT = 5; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const getColor = (added, removed) => | |
-added ? chalk.red : removed ? chalk.green : chalk.dim; | |
+ added ? chalk.red : removed ? chalk.green : chalk.dim; | |
const getBgColor = (added, removed) => | |
-added ? chalk.bgRed : removed ? chalk.bgGreen : chalk.dim; | |
+ added ? chalk.bgRed : removed ? chalk.bgGreen : chalk.dim; | |
const highlightTrailingWhitespace = (line, bgColor) => | |
-line.replace(/\s+$/, bgColor('$&')); | |
+ line.replace(/\s+$/, bgColor('$&')); | |
const getAnnotation = options => | |
-chalk.green('- ' + (options && options.aAnnotation || 'Expected')) + | |
-'\n' + | |
-chalk.red('+ ' + (options && options.bAnnotation || 'Received')) + | |
-'\n\n'; | |
+ chalk.green('- ' + ((options && options.aAnnotation) || 'Expected')) + | |
+ '\n' + | |
+ chalk.red('+ ' + ((options && options.bAnnotation) || 'Received')) + | |
+ '\n\n'; | |
const diffLines = (a, b) => { | |
let isDifferent = false; | |
return { | |
- diff: diff. | |
- diffLines(a, b). | |
- map(part => {const | |
- added = part.added,removed = part.removed; | |
- if (part.added || part.removed) { | |
- isDifferent = true; | |
- } | |
- | |
- const lines = part.value.split('\n'); | |
- const color = getColor(added, removed); | |
- const bgColor = getBgColor(added, removed); | |
- | |
- if (lines[lines.length - 1] === '') { | |
- lines.pop(); | |
- } | |
- | |
- return lines. | |
- map(line => { | |
- const highlightedLine = highlightTrailingWhitespace(line, bgColor); | |
- const mark = color(part.added ? '+' : part.removed ? '-' : ' '); | |
- return mark + ' ' + color(highlightedLine) + '\n'; | |
- }). | |
- join(''); | |
- }). | |
- join(''). | |
- trim(), | |
- isDifferent }; | |
+ diff: diff | |
+ .diffLines(a, b) | |
+ .map(part => { | |
+ const added = part.added, removed = part.removed; | |
+ if (part.added || part.removed) { | |
+ isDifferent = true; | |
+ } | |
+ | |
+ const lines = part.value.split('\n'); | |
+ const color = getColor(added, removed); | |
+ const bgColor = getBgColor(added, removed); | |
+ if (lines[lines.length - 1] === '') { | |
+ lines.pop(); | |
+ } | |
+ | |
+ return lines | |
+ .map(line => { | |
+ const highlightedLine = highlightTrailingWhitespace(line, bgColor); | |
+ const mark = color(part.added ? '+' : part.removed ? '-' : ' '); | |
+ return mark + ' ' + color(highlightedLine) + '\n'; | |
+ }) | |
+ .join(''); | |
+ }) | |
+ .join('') | |
+ .trim(), | |
+ isDifferent, | |
+ }; | |
}; | |
// Only show patch marks ("@@ ... @@") if the diff is big. | |
@@ -86,7 +70,7 @@ const diffLines = (a, b) => { | |
// If the `oldLinesCount` is greater than `hunk.oldLines` | |
// we can be sure that at least 1 line has been "hidden". | |
const shouldShowPatchMarks = (hunk, oldLinesCount) => | |
-oldLinesCount > hunk.oldLines; | |
+ oldLinesCount > hunk.oldLines; | |
const createPatchMark = hunk => { | |
const markOld = `-${hunk.oldStart},${hunk.oldLines}`; | |
@@ -95,7 +79,7 @@ const createPatchMark = hunk => { | |
}; | |
const structuredPatch = (a, b) => { | |
- const options = { context: DIFF_CONTEXT }; | |
+ const options = {context: DIFF_CONTEXT}; | |
let isDifferent = false; | |
// Make sure the strings end with a newline. | |
if (!a.endsWith('\n')) { | |
@@ -108,31 +92,31 @@ const structuredPatch = (a, b) => { | |
const oldLinesCount = (a.match(/\n/g) || []).length; | |
return { | |
- diff: diff. | |
- structuredPatch('', '', a, b, '', '', options). | |
- hunks.map(hunk => { | |
- const lines = hunk.lines. | |
- map(line => { | |
- const added = line[0] === '+'; | |
- const removed = line[0] === '-'; | |
- | |
- const color = getColor(added, removed); | |
- const bgColor = getBgColor(added, removed); | |
- | |
- const highlightedLine = highlightTrailingWhitespace(line, bgColor); | |
- return color(highlightedLine) + '\n'; | |
- }). | |
- join(''); | |
- | |
- isDifferent = true; | |
- return shouldShowPatchMarks(hunk, oldLinesCount) ? | |
- createPatchMark(hunk) + lines : | |
- lines; | |
- }). | |
- join(''). | |
- trim(), | |
- isDifferent }; | |
+ diff: diff | |
+ .structuredPatch('', '', a, b, '', '', options) | |
+ .hunks.map(hunk => { | |
+ const lines = hunk.lines | |
+ .map(line => { | |
+ const added = line[0] === '+'; | |
+ const removed = line[0] === '-'; | |
+ | |
+ const color = getColor(added, removed); | |
+ const bgColor = getBgColor(added, removed); | |
+ | |
+ const highlightedLine = highlightTrailingWhitespace(line, bgColor); | |
+ return color(highlightedLine) + '\n'; | |
+ }) | |
+ .join(''); | |
+ isDifferent = true; | |
+ return shouldShowPatchMarks(hunk, oldLinesCount) | |
+ ? createPatchMark(hunk) + lines | |
+ : lines; | |
+ }) | |
+ .join('') | |
+ .trim(), | |
+ isDifferent, | |
+ }; | |
}; | |
function diffStrings(a, b, options) { | |
@@ -140,9 +124,9 @@ function diffStrings(a, b, options) { | |
// (where "d" is the edit distance) and can get very slow for large edit | |
// distances. Mitigate the cost by switching to a lower-resolution diff | |
// whenever linebreaks are involved. | |
- const result = options && options.expand === false ? | |
- structuredPatch(a, b) : | |
- diffLines(a, b); | |
+ const result = options && options.expand === false | |
+ ? structuredPatch(a, b) | |
+ : diffLines(a, b); | |
if (result.isDifferent) { | |
return getAnnotation(options) + result.diff; | |
@@ -151,4 +135,4 @@ function diffStrings(a, b, options) { | |
} | |
} | |
-module.exports = diffStrings; | |
\ No newline at end of file | |
+module.exports = diffStrings; | |
diff --git i/packages/jest-diff/build/index.js w/packages/jest-diff/build/index.js | |
index 91d5af03..d96f7e9a 100644 | |
--- i/packages/jest-diff/build/index.js | |
+++ w/packages/jest-diff/build/index.js | |
@@ -8,39 +8,38 @@ | |
* | |
*/ | |
-'use strict';var _require$plugins = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('pretty-format').plugins;const ReactElement = _require$plugins.ReactElement,ReactTestComponent = _require$plugins.ReactTestComponent,AsymmetricMatcher = _require$plugins.AsymmetricMatcher,HTMLElement = _require$plugins.HTMLElement,Immutable = _require$plugins.Immutable; | |
+'use strict'; | |
+var _require$plugins = require('pretty-format').plugins; | |
+const ReactElement = _require$plugins.ReactElement, | |
+ ReactTestComponent = _require$plugins.ReactTestComponent, | |
+ AsymmetricMatcher = _require$plugins.AsymmetricMatcher, | |
+ HTMLElement = _require$plugins.HTMLElement, | |
+ Immutable = _require$plugins.Immutable; | |
const chalk = require('chalk'); | |
-const diffStrings = require('./diffStrings');var _require = | |
-require('jest-matcher-utils');const getType = _require.getType; | |
-const prettyFormat = require('pretty-format');var _require2 = | |
- | |
-require('./constants');const NO_DIFF_MESSAGE = _require2.NO_DIFF_MESSAGE,SIMILAR_MESSAGE = _require2.SIMILAR_MESSAGE; | |
+const diffStrings = require('./diffStrings'); | |
+var _require = require('jest-matcher-utils'); | |
+const getType = _require.getType; | |
+const prettyFormat = require('pretty-format'); | |
+var _require2 = require('./constants'); | |
+const NO_DIFF_MESSAGE = _require2.NO_DIFF_MESSAGE, | |
+ SIMILAR_MESSAGE = _require2.SIMILAR_MESSAGE; | |
const PLUGINS = [ | |
-ReactTestComponent, | |
-ReactElement, | |
-AsymmetricMatcher, | |
-HTMLElement]. | |
-concat(Immutable); | |
+ ReactTestComponent, | |
+ ReactElement, | |
+ AsymmetricMatcher, | |
+ HTMLElement, | |
+].concat(Immutable); | |
const FORMAT_OPTIONS = { | |
- plugins: PLUGINS }; | |
+ plugins: PLUGINS, | |
+}; | |
const FALLBACK_FORMAT_OPTIONS = { | |
callToJSON: false, | |
maxDepth: 10, | |
- plugins: PLUGINS }; | |
- | |
+ plugins: PLUGINS, | |
+}; | |
// Generate a string that will highlight the difference between two values | |
// with green and red. (similar to how github does code diffing) | |
@@ -71,8 +70,8 @@ function diff(a, b, options) { | |
return ( | |
' Comparing two different types of values.' + | |
` Expected ${chalk.green(expectedType)} but ` + | |
- `received ${chalk.red(getType(b))}.`); | |
- | |
+ `received ${chalk.red(getType(b))}.` | |
+ ); | |
} | |
if (omitDifference) { | |
@@ -94,8 +93,8 @@ function diff(a, b, options) { | |
case 'set': | |
return compareObjects(sortSet(a), sortSet(b), options); | |
default: | |
- return compareObjects(a, b, options);} | |
- | |
+ return compareObjects(a, b, options); | |
+ } | |
} | |
function sortMap(map) { | |
@@ -112,10 +111,10 @@ function compareObjects(a, b, options) { | |
try { | |
diffMessage = diffStrings( | |
- prettyFormat(a, FORMAT_OPTIONS), | |
- prettyFormat(b, FORMAT_OPTIONS), | |
- options); | |
- | |
+ prettyFormat(a, FORMAT_OPTIONS), | |
+ prettyFormat(b, FORMAT_OPTIONS), | |
+ options | |
+ ); | |
} catch (e) { | |
hasThrown = true; | |
} | |
@@ -124,9 +123,10 @@ function compareObjects(a, b, options) { | |
// without calling `toJSON`. It's also possible that toJSON might throw. | |
if (!diffMessage || diffMessage === NO_DIFF_MESSAGE) { | |
diffMessage = diffStrings( | |
- prettyFormat(a, FALLBACK_FORMAT_OPTIONS), | |
- prettyFormat(b, FALLBACK_FORMAT_OPTIONS), | |
- options); | |
+ prettyFormat(a, FALLBACK_FORMAT_OPTIONS), | |
+ prettyFormat(b, FALLBACK_FORMAT_OPTIONS), | |
+ options | |
+ ); | |
if (diffMessage !== NO_DIFF_MESSAGE && !hasThrown) { | |
diffMessage = SIMILAR_MESSAGE + '\n\n' + diffMessage; | |
@@ -136,4 +136,4 @@ function compareObjects(a, b, options) { | |
return diffMessage; | |
} | |
-module.exports = diff; | |
\ No newline at end of file | |
+module.exports = diff; | |
diff --git i/packages/jest-docblock/build/index.js w/packages/jest-docblock/build/index.js | |
index 63452f8b..e81580a7 100644 | |
--- i/packages/jest-docblock/build/index.js | |
+++ w/packages/jest-docblock/build/index.js | |
@@ -26,12 +26,12 @@ function extract(contents) { | |
} | |
function parse(docblock) { | |
- docblock = docblock. | |
- replace(commentStartRe, ''). | |
- replace(commentEndRe, ''). | |
- replace(wsRe, ' '). | |
- replace(lineCommentRe, ''). | |
- replace(stringStartRe, '$1'); | |
+ docblock = docblock | |
+ .replace(commentStartRe, '') | |
+ .replace(commentEndRe, '') | |
+ .replace(wsRe, ' ') | |
+ .replace(lineCommentRe, '') | |
+ .replace(stringStartRe, '$1'); | |
// Normalize multi-line directives | |
let prev = ''; | |
@@ -43,11 +43,11 @@ function parse(docblock) { | |
const result = Object.create(null); | |
let match; | |
- while (match = propertyRe.exec(docblock)) { | |
+ while ((match = propertyRe.exec(docblock))) { | |
result[match[1]] = match[2]; | |
} | |
return result; | |
} | |
exports.extract = extract; | |
-exports.parse = parse; | |
\ No newline at end of file | |
+exports.parse = parse; | |
diff --git i/packages/jest-editor-support/build/Process.js w/packages/jest-editor-support/build/Process.js | |
index f816c588..ca304b13 100644 | |
--- i/packages/jest-editor-support/build/Process.js | |
+++ w/packages/jest-editor-support/build/Process.js | |
@@ -8,9 +8,9 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('child_process');const ChildProcess = _require.ChildProcess,spawn = _require.spawn; | |
+'use strict'; | |
+var _require = require('child_process'); | |
+const ChildProcess = _require.ChildProcess, spawn = _require.spawn; | |
const ProjectWorkspace = require('./ProjectWorkspace'); | |
/** | |
@@ -19,10 +19,7 @@ const ProjectWorkspace = require('./ProjectWorkspace'); | |
* @param {string[]} args | |
* @returns {ChildProcess} | |
*/ | |
-module.exports.createProcess = ( | |
-workspace, | |
-args) => | |
-{ | |
+module.exports.createProcess = (workspace, args) => { | |
// 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 | |
@@ -44,5 +41,5 @@ args) => | |
const env = process.env; | |
env['CI'] = 'true'; | |
- return spawn(command, runtimeArgs, { cwd: workspace.rootPath, env }); | |
-}; | |
\ No newline at end of file | |
+ return spawn(command, runtimeArgs, {cwd: workspace.rootPath, env}); | |
+}; | |
diff --git i/packages/jest-editor-support/build/ProjectWorkspace.js w/packages/jest-editor-support/build/ProjectWorkspace.js | |
index 9354ef63..1bbfd886 100644 | |
--- i/packages/jest-editor-support/build/ProjectWorkspace.js | |
+++ w/packages/jest-editor-support/build/ProjectWorkspace.js | |
@@ -14,26 +14,6 @@ | |
* Represents the project that the extension is running on and it's state | |
*/ | |
module.exports = class ProjectWorkspace { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
/** | |
* Path to a local Jest config file. | |
* | |
@@ -44,17 +24,7 @@ module.exports = class ProjectWorkspace { | |
* @type {string} | |
*/ | |
- | |
- | |
- | |
- | |
- | |
- constructor( | |
- rootPath, | |
- pathToJest, | |
- pathToConfig, | |
- localJestMajorVersion) | |
- { | |
+ constructor(rootPath, pathToJest, pathToConfig, localJestMajorVersion) { | |
this.rootPath = rootPath; | |
this.pathToJest = pathToJest; | |
this.pathToConfig = pathToConfig; | |
@@ -74,4 +44,5 @@ module.exports = class ProjectWorkspace { | |
* space, and then move any other args into the args of the process. | |
* | |
* @type {string} | |
- */}; | |
\ No newline at end of file | |
+ */ | |
+}; | |
diff --git i/packages/jest-editor-support/build/Runner.js w/packages/jest-editor-support/build/Runner.js | |
index 07f79a71..be0277cb 100644 | |
--- i/packages/jest-editor-support/build/Runner.js | |
+++ w/packages/jest-editor-support/build/Runner.js | |
@@ -8,32 +8,26 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('child_process');const ChildProcess = _require.ChildProcess,spawn = _require.spawn;var _require2 = | |
-require('fs');const readFile = _require2.readFile;var _require3 = | |
-require('os');const tmpdir = _require3.tmpdir;var _require4 = | |
-require('events');const EventEmitter = _require4.EventEmitter; | |
-const ProjectWorkspace = require('./ProjectWorkspace');var _require5 = | |
-require('./Process');const createProcess = _require5.createProcess; | |
- | |
- | |
+'use strict'; | |
+var _require = require('child_process'); | |
+const ChildProcess = _require.ChildProcess, spawn = _require.spawn; | |
+var _require2 = require('fs'); | |
+const readFile = _require2.readFile; | |
+var _require3 = require('os'); | |
+const tmpdir = _require3.tmpdir; | |
+var _require4 = require('events'); | |
+const EventEmitter = _require4.EventEmitter; | |
+const ProjectWorkspace = require('./ProjectWorkspace'); | |
+var _require5 = require('./Process'); | |
+const createProcess = _require5.createProcess; | |
// This class represents the running process, and | |
// passes out events when it understands what data is being | |
// pass sent out of the process | |
module.exports = class Runner extends EventEmitter { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor(workspace, options) { | |
super(); | |
- this._createProcess = options && options.createProcess || createProcess; | |
+ this._createProcess = (options && options.createProcess) || createProcess; | |
this.workspace = workspace; | |
this.outputPath = tmpdir() + '/jest_runner.json'; | |
} | |
@@ -47,12 +41,12 @@ module.exports = class Runner extends EventEmitter { | |
const outputArg = belowEighteen ? '--jsonOutputFile' : '--outputFile'; | |
const args = [ | |
- '--json', | |
- '--useStderr', | |
- '--watch', | |
- outputArg, | |
- this.outputPath]; | |
- | |
+ '--json', | |
+ '--useStderr', | |
+ '--watch', | |
+ outputArg, | |
+ this.outputPath, | |
+ ]; | |
this.debugprocess = this._createProcess(this.workspace, args); | |
this.debugprocess.stdout.on('data', data => { | |
@@ -106,4 +100,5 @@ module.exports = class Runner extends EventEmitter { | |
this.debugprocess.kill(); | |
} | |
delete this.debugprocess; | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-editor-support/build/Settings.js w/packages/jest-editor-support/build/Settings.js | |
index 7d056c2b..e20f709e 100644 | |
--- i/packages/jest-editor-support/build/Settings.js | |
+++ w/packages/jest-editor-support/build/Settings.js | |
@@ -8,12 +8,13 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('child_process');const ChildProcess = _require.ChildProcess; | |
+'use strict'; | |
+var _require = require('child_process'); | |
+const ChildProcess = _require.ChildProcess; | |
const EventEmitter = require('events'); | |
-const ProjectWorkspace = require('./ProjectWorkspace');var _require2 = | |
-require('./Process');const createProcess = _require2.createProcess; | |
+const ProjectWorkspace = require('./ProjectWorkspace'); | |
+var _require2 = require('./Process'); | |
+const createProcess = _require2.createProcess; | |
// This class represents the the configuration of Jest's process | |
// we want to start with the defaults then override whatever they output | |
@@ -26,41 +27,25 @@ require('./Process');const createProcess = _require2.createProcess; | |
// For now, this is all we care about inside the config | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
module.exports = class Settings extends EventEmitter { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor(workspace, options) { | |
super(); | |
this.workspace = workspace; | |
- this._createProcess = options && options.createProcess || createProcess; | |
+ 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?$' }; | |
- | |
+ testRegex: '(/__tests__/.*|\\.(test|spec))\\.jsx?$', | |
+ }; | |
} | |
getConfig(completed) { | |
this.debugprocess = this._createProcess(this.workspace, ['--showConfig']); | |
- this.debugprocess.stdout.on('data', data => {var _JSON$parse = | |
- JSON.parse(data.toString());const config = _JSON$parse.config,version = _JSON$parse.version; | |
+ this.debugprocess.stdout.on('data', data => { | |
+ var _JSON$parse = JSON.parse(data.toString()); | |
+ const config = _JSON$parse.config, version = _JSON$parse.version; | |
// We can give warnings to versions under 17 now | |
// See https://github.com/facebook/jest/issues/2343 for moving this into | |
// the config object | |
@@ -70,4 +55,5 @@ module.exports = class Settings extends EventEmitter { | |
completed(); | |
}); | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-editor-support/build/TestReconciler.js w/packages/jest-editor-support/build/TestReconciler.js | |
index bd03856b..53ccf37a 100644 | |
--- i/packages/jest-editor-support/build/TestReconciler.js | |
+++ w/packages/jest-editor-support/build/TestReconciler.js | |
@@ -12,14 +12,6 @@ | |
const path = require('path'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
/** | |
* 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. | |
@@ -29,10 +21,6 @@ const path = require('path'); | |
*/ | |
module.exports = class TestReconciler { | |
- | |
- | |
- | |
- | |
constructor() { | |
this.fileStatuses = {}; | |
} | |
@@ -50,7 +38,8 @@ module.exports = class TestReconciler { | |
assertions: this.mapAssertions(file.name, file.assertionResults), | |
file: file.name, | |
message: file.message, | |
- status }; | |
+ status, | |
+ }; | |
this.fileStatuses[file.name] = fileStatus; | |
@@ -74,10 +63,7 @@ module.exports = class TestReconciler { | |
// we don't get this as structured data, but what we get | |
// is useful enough to make it for ourselves | |
- mapAssertions( | |
- filename, | |
- assertions) | |
- { | |
+ mapAssertions(filename, assertions) { | |
// Is it jest < 17? e.g. Before I added this to the JSON | |
if (!assertions) { | |
return []; | |
@@ -103,20 +89,20 @@ module.exports = class TestReconciler { | |
shortMessage: short, | |
status: this.statusToReconcilationState(assertion.status), | |
terseMessage: terse, | |
- title: assertion.title }; | |
- | |
+ title: assertion.title, | |
+ }; | |
}); | |
} | |
// Do everything we can to try make a one-liner from the error report | |
sanitizeShortErrorMessage(string) { | |
- return string. | |
- split('\n'). | |
- splice(2). | |
- join(''). | |
- replace(' ', ' '). | |
- replace('Received:', ' Received:'). | |
- replace('Difference:', ' Difference:'); | |
+ return string | |
+ .split('\n') | |
+ .splice(2) | |
+ .join('') | |
+ .replace(' ', ' ') | |
+ .replace('Received:', ' Received:') | |
+ .replace('Difference:', ' Difference:'); | |
} | |
// Pull the line out from the stack trace | |
@@ -133,8 +119,8 @@ module.exports = class TestReconciler { | |
case 'failed': | |
return 'KnownFail'; | |
default: | |
- return 'Unknown';} | |
- | |
+ return 'Unknown'; | |
+ } | |
} | |
stateForTestFile(file) { | |
@@ -145,10 +131,7 @@ module.exports = class TestReconciler { | |
return results.status; | |
} | |
- stateForTestAssertion( | |
- file, | |
- name) | |
- { | |
+ stateForTestAssertion(file, name) { | |
const results = this.fileStatuses[file]; | |
if (!results) { | |
return null; | |
@@ -158,4 +141,5 @@ module.exports = class TestReconciler { | |
return null; | |
} | |
return assertion; | |
- }}; | |
\ No newline at end of file | |
+ } | |
+}; | |
diff --git i/packages/jest-editor-support/build/index.js w/packages/jest-editor-support/build/index.js | |
index 27edb3a4..9c35eb06 100644 | |
--- i/packages/jest-editor-support/build/index.js | |
+++ w/packages/jest-editor-support/build/index.js | |
@@ -13,9 +13,13 @@ | |
const Process = require('./Process'); | |
const ProjectWorkspace = require('./ProjectWorkspace'); | |
const Runner = require('./Runner'); | |
-const Settings = require('./Settings');var _require = | |
-require('./parsers/ParserNodes');const Expect = _require.Expect,ItBlock = _require.ItBlock,Node = _require.Node;var _require2 = | |
-require('./parsers/BabylonParser');const parse = _require2.parse; | |
+const Settings = require('./Settings'); | |
+var _require = require('./parsers/ParserNodes'); | |
+const Expect = _require.Expect, | |
+ ItBlock = _require.ItBlock, | |
+ Node = _require.Node; | |
+var _require2 = require('./parsers/BabylonParser'); | |
+const parse = _require2.parse; | |
const TestReconciler = require('./TestReconciler'); | |
module.exports = { | |
@@ -27,4 +31,5 @@ module.exports = { | |
Runner, | |
Settings, | |
TestReconciler, | |
- parse }; | |
\ No newline at end of file | |
+ parse, | |
+}; | |
diff --git i/packages/jest-editor-support/build/parsers/BabylonParser.js w/packages/jest-editor-support/build/parsers/BabylonParser.js | |
index e7811726..bc26a211 100644 | |
--- i/packages/jest-editor-support/build/parsers/BabylonParser.js | |
+++ w/packages/jest-editor-support/build/parsers/BabylonParser.js | |
@@ -8,11 +8,12 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('fs');const readFileSync = _require.readFileSync; | |
-const babylon = require('babylon');var _require2 = | |
-require('./ParserNodes');const Expect = _require2.Expect,ItBlock = _require2.ItBlock; | |
+'use strict'; | |
+var _require = require('fs'); | |
+const readFileSync = _require.readFileSync; | |
+const babylon = require('babylon'); | |
+var _require2 = require('./ParserNodes'); | |
+const Expect = _require2.Expect, ItBlock = _require2.ItBlock; | |
const parse = file => { | |
const itBlocks = []; | |
@@ -20,7 +21,7 @@ const parse = file => { | |
const data = readFileSync(file).toString(); | |
- const config = { plugins: ['*'], sourceType: 'module' }; | |
+ const config = {plugins: ['*'], sourceType: 'module'}; | |
const ast = babylon.parse(data, config); | |
// An `it`/`test` was found in the AST | |
@@ -57,15 +58,15 @@ const parse = file => { | |
return ( | |
node.type === 'ExpressionStatement' && | |
node.expression && | |
- node.expression.type === 'CallExpression'); | |
- | |
+ node.expression.type === 'CallExpression' | |
+ ); | |
}; | |
const isFunctionDeclaration = nodeType => { | |
return ( | |
nodeType === 'ArrowFunctionExpression' || | |
- nodeType === 'FunctionExpression'); | |
- | |
+ nodeType === 'FunctionExpression' | |
+ ); | |
}; | |
// Pull out the name of a CallExpression (describe/it) | |
@@ -74,16 +75,16 @@ const parse = file => { | |
if (!isFunctionCall(node)) { | |
return false; | |
} | |
- let name = node && node.expression && node.expression.callee ? | |
- node.expression.callee.name : | |
- undefined; | |
+ 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 && | |
+ node.expression && | |
+ node.expression.callee && | |
+ node.expression.callee.object | |
+ ) { | |
name = node.expression.callee.object.name; | |
} | |
return name; | |
@@ -129,34 +130,34 @@ const parse = file => { | |
} else if (isAnExpect(element)) { | |
foundExpectNode(element, file); | |
} else if (element && element.type === 'VariableDeclaration') { | |
- element.declarations. | |
- filter( | |
- declaration => | |
- declaration.init && isFunctionDeclaration(declaration.init.type)). | |
- | |
- forEach(declaration => searchNodes(declaration.init.body, file)); | |
+ 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 && | |
+ 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)); | |
+ 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)); | |
} | |
} | |
}; | |
@@ -165,9 +166,10 @@ const parse = file => { | |
return { | |
expects, | |
- itBlocks }; | |
- | |
+ itBlocks, | |
+ }; | |
}; | |
module.exports = { | |
- parse }; | |
\ No newline at end of file | |
+ parse, | |
+}; | |
diff --git i/packages/jest-editor-support/build/parsers/ParserNodes.js w/packages/jest-editor-support/build/parsers/ParserNodes.js | |
index 885925e1..04c8f2ed 100644 | |
--- i/packages/jest-editor-support/build/parsers/ParserNodes.js | |
+++ w/packages/jest-editor-support/build/parsers/ParserNodes.js | |
@@ -10,21 +10,14 @@ | |
'use strict'; | |
- | |
- | |
class Node {} | |
- | |
- | |
- | |
- | |
class Expect extends Node {} | |
class ItBlock extends Node {} | |
- | |
- | |
module.exports = { | |
Expect, | |
ItBlock, | |
- Node }; | |
\ No newline at end of file | |
+ Node, | |
+}; | |
diff --git i/packages/jest-editor-support/build/types.js w/packages/jest-editor-support/build/types.js | |
index 01523b94..1c02bbe5 100644 | |
--- i/packages/jest-editor-support/build/types.js | |
+++ w/packages/jest-editor-support/build/types.js | |
@@ -8,4 +8,4 @@ | |
* | |
*/ | |
-'use strict'; | |
\ No newline at end of file | |
+'use strict'; | |
diff --git i/packages/jest-environment-jsdom/build/__mocks__/index.js w/packages/jest-environment-jsdom/build/__mocks__/index.js | |
index 8a4bbd84..f23be790 100644 | |
--- i/packages/jest-environment-jsdom/build/__mocks__/index.js | |
+++ w/packages/jest-environment-jsdom/build/__mocks__/index.js | |
@@ -11,12 +11,12 @@ const vm = require.requireActual('vm'); | |
const JSDOMEnvironment = jest.genMockFromModule('../index'); | |
-JSDOMEnvironment.mockImplementation(function (config) { | |
+JSDOMEnvironment.mockImplementation(function(config) { | |
this.global = { | |
JSON, | |
console: {}, | |
- mockClearTimers: jest.genMockFn() }; | |
- | |
+ mockClearTimers: jest.genMockFn(), | |
+ }; | |
const globalValues = Object.assign({}, config.globals); | |
for (const customGlobalKey in globalValues) { | |
@@ -24,14 +24,14 @@ JSDOMEnvironment.mockImplementation(function (config) { | |
} | |
}); | |
-JSDOMEnvironment.prototype.runSourceText.mockImplementation(function ( | |
-sourceText, | |
-filename) | |
-{ | |
+JSDOMEnvironment.prototype.runSourceText.mockImplementation(function( | |
+ sourceText, | |
+ filename | |
+) { | |
return vm.runInNewContext(sourceText, this.global, { | |
displayErrors: false, | |
- filename }); | |
- | |
+ filename, | |
+ }); | |
}); | |
-module.exports = JSDOMEnvironment; | |
\ No newline at end of file | |
+module.exports = JSDOMEnvironment; | |
diff --git i/packages/jest-environment-jsdom/build/index.js w/packages/jest-environment-jsdom/build/index.js | |
index 3b9e0479..112484b8 100644 | |
--- i/packages/jest-environment-jsdom/build/index.js | |
+++ w/packages/jest-environment-jsdom/build/index.js | |
@@ -8,27 +8,18 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
const FakeTimers = require('jest-util').FakeTimers; | |
const installCommonGlobals = require('jest-util').installCommonGlobals; | |
const mock = require('jest-mock'); | |
class JSDOMEnvironment { | |
- | |
- | |
- | |
- | |
- | |
constructor(config) { | |
// lazy require | |
- this.document = require('jsdom').jsdom( /* markup */undefined, { | |
- url: config.testURL }); | |
+ this.document = require('jsdom').jsdom(/* markup */ undefined, { | |
+ url: config.testURL, | |
+ }); | |
- const global = this.global = this.document.defaultView; | |
+ const global = (this.global = this.document.defaultView); | |
// Node's error-message stack size is limited at 10, but it's pretty useful | |
// to see more than that when a test fails. | |
this.global.Error.stackTraceLimit = 100; | |
@@ -55,7 +46,7 @@ class JSDOMEnvironment { | |
return require('jsdom').evalVMScript(this.global, script); | |
} | |
return null; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = JSDOMEnvironment; | |
\ No newline at end of file | |
+module.exports = JSDOMEnvironment; | |
diff --git i/packages/jest-environment-node/build/index.js w/packages/jest-environment-node/build/index.js | |
index adcd4448..716c9847 100644 | |
--- i/packages/jest-environment-node/build/index.js | |
+++ w/packages/jest-environment-node/build/index.js | |
@@ -9,25 +9,15 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
const FakeTimers = require('jest-util').FakeTimers; | |
const installCommonGlobals = require('jest-util').installCommonGlobals; | |
const mock = require('jest-mock'); | |
const vm = require('vm'); | |
class NodeEnvironment { | |
- | |
- | |
- | |
- | |
- | |
constructor(config) { | |
this.context = vm.createContext(); | |
- const global = this.global = vm.runInContext('this', this.context); | |
+ const global = (this.global = vm.runInContext('this', this.context)); | |
global.global = global; | |
global.clearInterval = clearInterval; | |
global.clearTimeout = clearTimeout; | |
@@ -52,7 +42,7 @@ class NodeEnvironment { | |
return script.runInContext(this.context); | |
} | |
return null; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = NodeEnvironment; | |
\ No newline at end of file | |
+module.exports = NodeEnvironment; | |
diff --git i/packages/jest-haste-map/build/HasteFS.js w/packages/jest-haste-map/build/HasteFS.js | |
index 759ee9dd..e891fa49 100644 | |
--- i/packages/jest-haste-map/build/HasteFS.js | |
+++ w/packages/jest-haste-map/build/HasteFS.js | |
@@ -9,27 +9,22 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const H = require('./constants'); | |
const micromatch = require('micromatch'); | |
const path = require('path'); | |
class HasteFS { | |
- | |
- | |
constructor(files) { | |
this._files = files; | |
} | |
getModuleName(file) { | |
- return this._files[file] && this._files[file][H.ID] || null; | |
+ return (this._files[file] && this._files[file][H.ID]) || null; | |
} | |
getDependencies(file) { | |
- return this._files[file] && this._files[file][H.DEPENDENCIES] || null; | |
+ return (this._files[file] && this._files[file][H.DEPENDENCIES]) || null; | |
} | |
exists(file) { | |
@@ -62,7 +57,7 @@ class HasteFS { | |
} | |
} | |
return files; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = HasteFS; | |
\ No newline at end of file | |
+module.exports = HasteFS; | |
diff --git i/packages/jest-haste-map/build/ModuleMap.js w/packages/jest-haste-map/build/ModuleMap.js | |
index 18a3fa31..7a59e9a1 100644 | |
--- i/packages/jest-haste-map/build/ModuleMap.js | |
+++ w/packages/jest-haste-map/build/ModuleMap.js | |
@@ -9,32 +9,15 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const H = require('./constants'); | |
class ModuleMap { | |
- | |
- | |
- | |
constructor(map, mocks) { | |
this._map = map; | |
this._mocks = mocks; | |
} | |
- getModule( | |
- name, | |
- platform, | |
- supportsNativePlatform, | |
- type) | |
- { | |
+ getModule(name, platform, supportsNativePlatform, type) { | |
if (!type) { | |
type = H.MODULE; | |
} | |
@@ -55,11 +38,7 @@ class ModuleMap { | |
return null; | |
} | |
- getPackage( | |
- name, | |
- platform, | |
- supportsNativePlatform) | |
- { | |
+ getPackage(name, platform, supportsNativePlatform) { | |
return this.getModule(name, platform, null, H.PACKAGE); | |
} | |
@@ -70,9 +49,9 @@ class ModuleMap { | |
getRawModuleMap() { | |
return { | |
map: this._map, | |
- mocks: this._mocks }; | |
- | |
- }} | |
- | |
+ mocks: this._mocks, | |
+ }; | |
+ } | |
+} | |
-module.exports = ModuleMap; | |
\ No newline at end of file | |
+module.exports = ModuleMap; | |
diff --git i/packages/jest-haste-map/build/constants.js w/packages/jest-haste-map/build/constants.js | |
index 15c2b75b..4e78f949 100644 | |
--- i/packages/jest-haste-map/build/constants.js | |
+++ w/packages/jest-haste-map/build/constants.js | |
@@ -34,4 +34,5 @@ module.exports = { | |
/* platforms */ | |
GENERIC_PLATFORM: 'g', | |
- NATIVE_PLATFORM: 'native' }; | |
\ No newline at end of file | |
+ NATIVE_PLATFORM: 'native', | |
+}; | |
diff --git i/packages/jest-haste-map/build/crawlers/node.js w/packages/jest-haste-map/build/crawlers/node.js | |
index 109ad988..cefea35e 100644 | |
--- i/packages/jest-haste-map/build/crawlers/node.js | |
+++ w/packages/jest-haste-map/build/crawlers/node.js | |
@@ -9,23 +9,13 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const H = require('../constants'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const spawn = require('child_process').spawn; | |
- | |
- | |
-function find( | |
-roots, | |
-extensions, | |
-ignore, | |
-callback) | |
-{ | |
+function find(roots, extensions, ignore, callback) { | |
const result = []; | |
let activeCalls = 0; | |
@@ -69,12 +59,7 @@ callback) | |
roots.forEach(search); | |
} | |
-function findNative( | |
-roots, | |
-extensions, | |
-ignore, | |
-callback) | |
-{ | |
+function findNative(roots, extensions, ignore, callback) { | |
const args = [].concat(roots); | |
args.push('-type', 'f'); | |
if (extensions.length) { | |
@@ -94,7 +79,7 @@ callback) | |
const child = spawn('find', args); | |
let stdout = ''; | |
child.stdout.setEncoding('utf-8'); | |
- child.stdout.on('data', data => stdout += data); | |
+ child.stdout.on('data', data => (stdout += data)); | |
child.stdout.on('close', () => { | |
const lines = stdout.trim().split('\n').filter(x => !ignore(x)); | |
@@ -117,10 +102,12 @@ callback) | |
}); | |
} | |
-module.exports = function nodeCrawl( | |
-options) | |
-{const | |
- data = options.data,extensions = options.extensions,forceNodeFilesystemAPI = options.forceNodeFilesystemAPI,ignore = options.ignore,roots = options.roots; | |
+module.exports = function nodeCrawl(options) { | |
+ const data = options.data, | |
+ extensions = options.extensions, | |
+ forceNodeFilesystemAPI = options.forceNodeFilesystemAPI, | |
+ ignore = options.ignore, | |
+ roots = options.roots; | |
return new Promise(resolve => { | |
const callback = list => { | |
@@ -146,4 +133,4 @@ options) | |
findNative(roots, extensions, ignore, callback); | |
} | |
}); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-haste-map/build/crawlers/watchman.js w/packages/jest-haste-map/build/crawlers/watchman.js | |
index 91a3dcfb..88e815ad 100644 | |
--- i/packages/jest-haste-map/build/crawlers/watchman.js | |
+++ w/packages/jest-haste-map/build/crawlers/watchman.js | |
@@ -9,16 +9,13 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const H = require('../constants'); | |
const path = require('path'); | |
const watchman = require('fb-watchman'); | |
const watchmanURL = | |
-'https://facebook.github.io/watchman/docs/troubleshooting.html'; | |
+ 'https://facebook.github.io/watchman/docs/troubleshooting.html'; | |
function isDescendant(root, child) { | |
return child.startsWith(root); | |
@@ -26,114 +23,117 @@ function isDescendant(root, child) { | |
function WatchmanError(error) { | |
return new Error( | |
- `Watchman error: ${error.message.trim()}. Make sure watchman ` + | |
- `is running for this project. See ${watchmanURL}.`); | |
- | |
+ `Watchman error: ${error.message.trim()}. Make sure watchman ` + | |
+ `is running for this project. See ${watchmanURL}.` | |
+ ); | |
} | |
-module.exports = function watchmanCrawl( | |
-options) | |
-{const | |
- data = options.data,extensions = options.extensions,ignore = options.ignore,roots = options.roots; | |
+module.exports = function watchmanCrawl(options) { | |
+ const data = options.data, | |
+ extensions = options.extensions, | |
+ ignore = options.ignore, | |
+ roots = options.roots; | |
return new Promise((resolve, reject) => { | |
const client = new watchman.Client(); | |
client.on('error', error => reject(error)); | |
const cmd = args => | |
- new Promise((resolve, reject) => { | |
- client.command(args, (error, result) => { | |
- if (error) { | |
- reject(error); | |
- } else { | |
- resolve(result); | |
- } | |
+ new Promise((resolve, reject) => { | |
+ client.command(args, (error, result) => { | |
+ if (error) { | |
+ reject(error); | |
+ } else { | |
+ resolve(result); | |
+ } | |
+ }); | |
}); | |
- }); | |
const clocks = data.clocks; | |
let files = data.files; | |
- return Promise.all(roots.map(root => cmd(['watch-project', root]))). | |
- then(responses => { | |
- const watchmanRoots = Array.from( | |
- new Set(responses.map(response => response.watch))); | |
- | |
- return Promise.all( | |
- watchmanRoots.map(root => { | |
- // Build an expression to filter the output by the relevant roots. | |
- const dirExpr = ['anyof']; | |
- roots.forEach(subRoot => { | |
- if (isDescendant(root, subRoot)) { | |
- dirExpr.push(['dirname', path.relative(root, subRoot)]); | |
+ return Promise.all(roots.map(root => cmd(['watch-project', root]))) | |
+ .then(responses => { | |
+ const watchmanRoots = Array.from( | |
+ new Set(responses.map(response => response.watch)) | |
+ ); | |
+ | |
+ return Promise.all( | |
+ watchmanRoots.map(root => { | |
+ // Build an expression to filter the output by the relevant roots. | |
+ const dirExpr = ['anyof']; | |
+ roots.forEach(subRoot => { | |
+ if (isDescendant(root, subRoot)) { | |
+ dirExpr.push(['dirname', path.relative(root, subRoot)]); | |
+ } | |
+ }); | |
+ const expression = [ | |
+ 'allof', | |
+ ['type', 'f'], | |
+ ['anyof'].concat( | |
+ extensions.map(extension => ['suffix', extension]) | |
+ ), | |
+ ]; | |
+ | |
+ if (dirExpr.length > 1) { | |
+ expression.push(dirExpr); | |
+ } | |
+ const fields = ['name', 'exists', 'mtime_ms']; | |
+ | |
+ const query = clocks[root] | |
+ ? // Use the `since` generator if we have a clock available | |
+ {expression, fields, since: clocks[root]} | |
+ : // Otherwise use the `suffix` generator | |
+ {expression, fields, suffix: extensions}; | |
+ return cmd(['query', root, query]).then(response => ({ | |
+ response, | |
+ root, | |
+ })); | |
+ }) | |
+ ).then(pairs => { | |
+ // Reset the file map if watchman was restarted and sends us a list of | |
+ // files. | |
+ if (pairs.some(pair => pair.response.is_fresh_instance)) { | |
+ files = Object.create(null); | |
} | |
- }); | |
- const expression = [ | |
- 'allof', | |
- ['type', 'f'], | |
- ['anyof'].concat( | |
- extensions.map(extension => ['suffix', extension]))]; | |
- | |
- | |
- if (dirExpr.length > 1) { | |
- expression.push(dirExpr); | |
- } | |
- const fields = ['name', 'exists', 'mtime_ms']; | |
- | |
- const query = clocks[root] ? | |
- // Use the `since` generator if we have a clock available | |
- { expression, fields, since: clocks[root] } : | |
- // Otherwise use the `suffix` generator | |
- { expression, fields, suffix: extensions }; | |
- return cmd(['query', root, query]).then(response => ({ | |
- response, | |
- root })); | |
- })). | |
- then(pairs => { | |
- // Reset the file map if watchman was restarted and sends us a list of | |
- // files. | |
- if (pairs.some(pair => pair.response.is_fresh_instance)) { | |
- files = Object.create(null); | |
- } | |
- | |
- pairs.forEach(pair => { | |
- const root = pair.root; | |
- const response = pair.response; | |
- if ('warning' in response) { | |
- console.warn('watchman warning: ', response.warning); | |
- } | |
+ pairs.forEach(pair => { | |
+ const root = pair.root; | |
+ const response = pair.response; | |
+ if ('warning' in response) { | |
+ console.warn('watchman warning: ', response.warning); | |
+ } | |
- clocks[root] = response.clock; | |
- response.files.forEach(fileData => { | |
- const name = root + path.sep + fileData.name; | |
- if (!fileData.exists) { | |
- delete files[name]; | |
- } else if (!ignore(name)) { | |
- const mtime = typeof fileData.mtime_ms === 'number' ? | |
- fileData.mtime_ms : | |
- fileData.mtime_ms.toNumber(); | |
- const isNew = | |
- !data.files[name] || data.files[name][H.MTIME] !== mtime; | |
- if (isNew) { | |
- // See ../constants.js | |
- files[name] = ['', mtime, 0, []]; | |
- } else { | |
- files[name] = data.files[name]; | |
+ clocks[root] = response.clock; | |
+ response.files.forEach(fileData => { | |
+ const name = root + path.sep + fileData.name; | |
+ if (!fileData.exists) { | |
+ delete files[name]; | |
+ } else if (!ignore(name)) { | |
+ const mtime = typeof fileData.mtime_ms === 'number' | |
+ ? fileData.mtime_ms | |
+ : fileData.mtime_ms.toNumber(); | |
+ const isNew = | |
+ !data.files[name] || data.files[name][H.MTIME] !== mtime; | |
+ if (isNew) { | |
+ // See ../constants.js | |
+ files[name] = ['', mtime, 0, []]; | |
+ } else { | |
+ files[name] = data.files[name]; | |
+ } | |
} | |
- } | |
+ }); | |
}); | |
}); | |
+ }) | |
+ .then(() => { | |
+ client.end(); | |
+ data.files = files; | |
+ resolve(data); | |
+ }) | |
+ .catch(error => { | |
+ client.end(); | |
+ reject(WatchmanError(error)); | |
}); | |
- }). | |
- then(() => { | |
- client.end(); | |
- data.files = files; | |
- resolve(data); | |
- }). | |
- catch(error => { | |
- client.end(); | |
- reject(WatchmanError(error)); | |
- }); | |
}); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-haste-map/build/getMockName.js w/packages/jest-haste-map/build/getMockName.js | |
index 9432a9ad..705ec20b 100644 | |
--- i/packages/jest-haste-map/build/getMockName.js | |
+++ w/packages/jest-haste-map/build/getMockName.js | |
@@ -18,4 +18,4 @@ const getMockName = filePath => { | |
return mockPath.substring(0, mockPath.lastIndexOf(path.extname(mockPath))); | |
}; | |
-module.exports = getMockName; | |
\ No newline at end of file | |
+module.exports = getMockName; | |
diff --git i/packages/jest-haste-map/build/index.js w/packages/jest-haste-map/build/index.js | |
index f8245745..e537a25a 100644 | |
--- i/packages/jest-haste-map/build/index.js | |
+++ w/packages/jest-haste-map/build/index.js | |
@@ -7,22 +7,9 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('events');const EventEmitter = _require.EventEmitter; | |
+'use strict'; | |
+var _require = require('events'); | |
+const EventEmitter = _require.EventEmitter; | |
const H = require('./constants'); | |
const HasteFS = require('./HasteFS'); | |
const HasteModuleMap = require('./ModuleMap'); | |
@@ -40,51 +27,6 @@ const watchmanCrawl = require('./crawlers/watchman'); | |
const worker = require('./worker'); | |
const workerFarm = require('worker-farm'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const CHANGE_INTERVAL = 30; | |
const MAX_WAIT_TIME = 240000; | |
const NODE_MODULES = path.sep + 'node_modules' + path.sep; | |
@@ -92,27 +34,27 @@ const VERSION = require('../package.json').version; | |
const canUseWatchman = (() => { | |
try { | |
- execSync('watchman --version', { stdio: ['ignore'] }); | |
+ execSync('watchman --version', {stdio: ['ignore']}); | |
return true; | |
} catch (e) {} | |
return false; | |
})(); | |
const escapePathSeparator = string => | |
-path.sep === '\\' ? string.replace(/(\/|\\)/g, '\\\\') : string; | |
+ path.sep === '\\' ? string.replace(/(\/|\\)/g, '\\\\') : string; | |
const getWhiteList = list => { | |
if (list && list.length) { | |
return new RegExp( | |
- '(' + | |
- escapePathSeparator(NODE_MODULES) + | |
- '(?:' + | |
- list.join('|') + | |
- ')(?=$|' + | |
- escapePathSeparator(path.sep) + | |
- '))', | |
- 'g'); | |
- | |
+ '(' + | |
+ escapePathSeparator(NODE_MODULES) + | |
+ '(?:' + | |
+ list.join('|') + | |
+ ')(?=$|' + | |
+ escapePathSeparator(path.sep) + | |
+ '))', | |
+ 'g' | |
+ ); | |
} | |
return null; | |
}; | |
@@ -191,16 +133,6 @@ const getWhiteList = list => { | |
* | |
*/ | |
class HasteMap extends EventEmitter { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor(options) { | |
super(); | |
this._options = { | |
@@ -210,9 +142,9 @@ class HasteMap extends EventEmitter { | |
hasteImplModulePath: options.hasteImplModulePath, | |
ignorePattern: options.ignorePattern, | |
maxWorkers: options.maxWorkers, | |
- mocksPattern: options.mocksPattern ? | |
- new RegExp(options.mocksPattern) : | |
- null, | |
+ mocksPattern: options.mocksPattern | |
+ ? new RegExp(options.mocksPattern) | |
+ : null, | |
name: options.name, | |
platforms: options.platforms, | |
resetCache: options.resetCache, | |
@@ -220,17 +152,19 @@ class HasteMap extends EventEmitter { | |
roots: Array.from(new Set(options.roots)), | |
throwOnModuleCollision: !!options.throwOnModuleCollision, | |
useWatchman: options.useWatchman == null ? true : options.useWatchman, | |
- watch: !!options.watch }; | |
+ watch: !!options.watch, | |
+ }; | |
this._console = options.console || global.console; | |
this._cachePath = HasteMap.getCacheFilePath( | |
- this._options.cacheDirectory, | |
- `haste-map-${this._options.name}`, | |
- VERSION, | |
- this._options.roots.join(':'), | |
- this._options.extensions.join(':'), | |
- this._options.platforms.join(':'), | |
- options.mocksPattern || ''); | |
+ this._options.cacheDirectory, | |
+ `haste-map-${this._options.name}`, | |
+ VERSION, | |
+ this._options.roots.join(':'), | |
+ this._options.extensions.join(':'), | |
+ this._options.platforms.join(':'), | |
+ options.mocksPattern || '' | |
+ ); | |
this._whitelist = getWhiteList(options.providesModuleNodeModules); | |
this._buildPromise = null; | |
@@ -243,27 +177,27 @@ class HasteMap extends EventEmitter { | |
const hash = crypto.createHash('md5'); | |
Array.from(arguments).slice(1).forEach(arg => hash.update(arg)); | |
return path.join( | |
- tmpdir, | |
- name.replace(/\W/g, '-') + '-' + hash.digest('hex')); | |
- | |
+ tmpdir, | |
+ name.replace(/\W/g, '-') + '-' + hash.digest('hex') | |
+ ); | |
} | |
build() { | |
if (!this._buildPromise) { | |
- this._buildPromise = this._buildFileMap(). | |
- then(fileMap => this._buildHasteMap(fileMap)). | |
- then(hasteMap => { | |
- this._persist(hasteMap); | |
- const hasteFS = new HasteFS(hasteMap.files); | |
- const moduleMap = new HasteModuleMap(hasteMap.map, hasteMap.mocks); | |
- const __hasteMapForTest = | |
- process.env.NODE_ENV === 'test' && hasteMap || null; | |
- return this._watch(hasteMap, hasteFS, moduleMap).then(() => ({ | |
- __hasteMapForTest, | |
- hasteFS, | |
- moduleMap })); | |
- | |
- }); | |
+ this._buildPromise = this._buildFileMap() | |
+ .then(fileMap => this._buildHasteMap(fileMap)) | |
+ .then(hasteMap => { | |
+ this._persist(hasteMap); | |
+ const hasteFS = new HasteFS(hasteMap.files); | |
+ const moduleMap = new HasteModuleMap(hasteMap.map, hasteMap.mocks); | |
+ const __hasteMapForTest = | |
+ (process.env.NODE_ENV === 'test' && hasteMap) || null; | |
+ return this._watch(hasteMap, hasteFS, moduleMap).then(() => ({ | |
+ __hasteMapForTest, | |
+ hasteFS, | |
+ moduleMap, | |
+ })); | |
+ }); | |
} | |
return this._buildPromise; | |
} | |
@@ -286,40 +220,34 @@ class HasteMap extends EventEmitter { | |
_buildFileMap() { | |
const read = this._options.resetCache ? this._createEmptyMap : this.read; | |
- return Promise.resolve(). | |
- then(() => read.call(this)). | |
- catch(() => this._createEmptyMap()). | |
- then(hasteMap => this._crawl(hasteMap)); | |
+ return Promise.resolve() | |
+ .then(() => read.call(this)) | |
+ .catch(() => this._createEmptyMap()) | |
+ .then(hasteMap => this._crawl(hasteMap)); | |
} | |
/** | |
* 3. parse and extract metadata from changed files. | |
*/ | |
- _processFile( | |
- hasteMap, | |
- map, | |
- mocks, | |
- filePath, | |
- workerOptions) | |
- { | |
+ _processFile(hasteMap, map, mocks, filePath, workerOptions) { | |
const setModule = (id, module) => { | |
if (!map[id]) { | |
map[id] = Object.create(null); | |
} | |
const moduleMap = map[id]; | |
const platform = | |
- getPlatformExtension(module[H.PATH], this._options.platforms) || | |
- H.GENERIC_PLATFORM; | |
+ getPlatformExtension(module[H.PATH], this._options.platforms) || | |
+ H.GENERIC_PLATFORM; | |
const existingModule = moduleMap[platform]; | |
if (existingModule && existingModule[H.PATH] !== module[H.PATH]) { | |
const message = | |
- `jest-haste-map: @providesModule naming collision:\n` + | |
- ` Duplicate module name: ${id}\n` + | |
- ` Paths: ${module[H.PATH]} collides with ` + | |
- `${existingModule[H.PATH]}\n\nThis ` + | |
- `${this._options.throwOnModuleCollision ? 'error' : 'warning'} ` + | |
- `is caused by a @providesModule declaration ` + | |
- `with the same name across two different files.`; | |
+ `jest-haste-map: @providesModule naming collision:\n` + | |
+ ` Duplicate module name: ${id}\n` + | |
+ ` Paths: ${module[H.PATH]} collides with ` + | |
+ `${existingModule[H.PATH]}\n\nThis ` + | |
+ `${this._options.throwOnModuleCollision ? 'error' : 'warning'} ` + | |
+ `is caused by a @providesModule declaration ` + | |
+ `with the same name across two different files.`; | |
if (this._options.throwOnModuleCollision) { | |
throw new Error(message); | |
} | |
@@ -336,21 +264,21 @@ class HasteMap extends EventEmitter { | |
} | |
if ( | |
- this._options.mocksPattern && | |
- this._options.mocksPattern.test(filePath)) | |
- { | |
+ this._options.mocksPattern && | |
+ this._options.mocksPattern.test(filePath) | |
+ ) { | |
const mockPath = getMockName(filePath); | |
if (mocks[mockPath]) { | |
this._console.warn( | |
- `jest-haste-map: duplicate manual mock found:\n` + | |
- ` Module name: ${mockPath}\n` + | |
- ` Duplicate Mock path: ${filePath}\nThis warning ` + | |
- `is caused by two manual mock files with the same file name.\n` + | |
- `Jest will use the mock file found in: \n` + | |
- `${filePath}\n` + | |
- ` Please delete one of the following two files: \n ` + | |
- `${mocks[mockPath]}\n${filePath}\n\n`); | |
- | |
+ `jest-haste-map: duplicate manual mock found:\n` + | |
+ ` Module name: ${mockPath}\n` + | |
+ ` Duplicate Mock path: ${filePath}\nThis warning ` + | |
+ `is caused by two manual mock files with the same file name.\n` + | |
+ `Jest will use the mock file found in: \n` + | |
+ `${filePath}\n` + | |
+ ` Please delete one of the following two files: \n ` + | |
+ `${mocks[mockPath]}\n${filePath}\n\n` | |
+ ); | |
} | |
mocks[mockPath] = filePath; | |
} | |
@@ -368,25 +296,25 @@ class HasteMap extends EventEmitter { | |
return this._getWorker(workerOptions)({ | |
filePath, | |
- hasteImplModulePath: this._options.hasteImplModulePath }). | |
- then( | |
- metadata => { | |
- // `1` for truthy values instead of `true` to save cache space. | |
- fileMetadata[H.VISITED] = 1; | |
- const metadataId = metadata.id; | |
- const metadataModule = metadata.module; | |
- if (metadataId && metadataModule) { | |
- fileMetadata[H.ID] = metadataId; | |
- setModule(metadataId, metadataModule); | |
+ hasteImplModulePath: this._options.hasteImplModulePath, | |
+ }).then( | |
+ metadata => { | |
+ // `1` for truthy values instead of `true` to save cache space. | |
+ fileMetadata[H.VISITED] = 1; | |
+ const metadataId = metadata.id; | |
+ const metadataModule = metadata.module; | |
+ if (metadataId && metadataModule) { | |
+ fileMetadata[H.ID] = metadataId; | |
+ setModule(metadataId, metadataModule); | |
+ } | |
+ fileMetadata[H.DEPENDENCIES] = metadata.dependencies || []; | |
+ }, | |
+ error => { | |
+ // If a file cannot be read we remove it from the file list and | |
+ // ignore the failure silently. | |
+ delete hasteMap.files[filePath]; | |
} | |
- fileMetadata[H.DEPENDENCIES] = metadata.dependencies || []; | |
- }, | |
- error => { | |
- // If a file cannot be read we remove it from the file list and | |
- // ignore the failure silently. | |
- delete hasteMap.files[filePath]; | |
- }); | |
- | |
+ ); | |
} | |
_buildHasteMap(hasteMap) { | |
@@ -409,17 +337,17 @@ class HasteMap extends EventEmitter { | |
this._workerPromise = null; | |
}; | |
- return Promise.all(promises). | |
- then(cleanup). | |
- then(() => { | |
- hasteMap.map = map; | |
- hasteMap.mocks = mocks; | |
- return hasteMap; | |
- }). | |
- catch(error => { | |
- cleanup(); | |
- return Promise.reject(error); | |
- }); | |
+ return Promise.all(promises) | |
+ .then(cleanup) | |
+ .then(() => { | |
+ hasteMap.map = map; | |
+ hasteMap.mocks = mocks; | |
+ return hasteMap; | |
+ }) | |
+ .catch(error => { | |
+ cleanup(); | |
+ return Promise.reject(error); | |
+ }); | |
} | |
/** | |
@@ -432,33 +360,32 @@ class HasteMap extends EventEmitter { | |
/** | |
* Creates workers or parses files and extracts metadata in-process. | |
*/ | |
- _getWorker( | |
- options) | |
- { | |
+ _getWorker(options) { | |
if (!this._workerPromise) { | |
let workerFn; | |
- if (options && options.forceInBand || this._options.maxWorkers <= 1) { | |
+ if ((options && options.forceInBand) || this._options.maxWorkers <= 1) { | |
workerFn = worker; | |
} else { | |
this._workerFarm = workerFarm( | |
- { | |
- maxConcurrentWorkers: this._options.maxWorkers }, | |
- | |
- require.resolve('./worker')); | |
+ { | |
+ maxConcurrentWorkers: this._options.maxWorkers, | |
+ }, | |
+ require.resolve('./worker') | |
+ ); | |
workerFn = this._workerFarm; | |
} | |
this._workerPromise = message => | |
- new Promise((resolve, reject) => | |
- workerFn(message, (error, metadata) => { | |
- if (error || !metadata) { | |
- reject(error); | |
- } else { | |
- resolve(metadata); | |
- } | |
- })); | |
- | |
+ new Promise((resolve, reject) => | |
+ workerFn(message, (error, metadata) => { | |
+ if (error || !metadata) { | |
+ reject(error); | |
+ } else { | |
+ resolve(metadata); | |
+ } | |
+ }) | |
+ ); | |
} | |
return this._workerPromise; | |
@@ -475,33 +402,34 @@ class HasteMap extends EventEmitter { | |
_crawl(hasteMap) { | |
const options = this._options; | |
const ignore = this._ignore.bind(this); | |
- const crawl = canUseWatchman && this._options.useWatchman ? | |
- watchmanCrawl : | |
- nodeCrawl; | |
+ const crawl = canUseWatchman && this._options.useWatchman | |
+ ? watchmanCrawl | |
+ : nodeCrawl; | |
const retry = error => { | |
if (crawl === watchmanCrawl) { | |
this._console.warn( | |
- `jest-haste-map: Watchman crawl failed. Retrying once with node ` + | |
- `crawler.\n` + | |
- ` Usually this happens when watchman isn't running. Create an ` + | |
- `empty \`.watchmanconfig\` file in your project's root folder or ` + | |
- `initialize a git or hg repository in your project.\n` + | |
- ` ` + | |
- error); | |
+ `jest-haste-map: Watchman crawl failed. Retrying once with node ` + | |
+ `crawler.\n` + | |
+ ` Usually this happens when watchman isn't running. Create an ` + | |
+ `empty \`.watchmanconfig\` file in your project's root folder or ` + | |
+ `initialize a git or hg repository in your project.\n` + | |
+ ` ` + | |
+ error | |
+ ); | |
return nodeCrawl({ | |
data: hasteMap, | |
extensions: options.extensions, | |
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI, | |
ignore, | |
- roots: options.roots }). | |
- catch(e => { | |
+ roots: options.roots, | |
+ }).catch(e => { | |
throw new Error( | |
- `Crawler retry failed:\n` + | |
- ` Original error: ${error.message}\n` + | |
- ` Retry error: ${e.message}\n`); | |
- | |
+ `Crawler retry failed:\n` + | |
+ ` Original error: ${error.message}\n` + | |
+ ` Retry error: ${e.message}\n` | |
+ ); | |
}); | |
} | |
@@ -514,8 +442,8 @@ class HasteMap extends EventEmitter { | |
extensions: options.extensions, | |
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI, | |
ignore, | |
- roots: options.roots }). | |
- catch(retry); | |
+ roots: options.roots, | |
+ }).catch(retry); | |
} catch (error) { | |
return retry(error); | |
} | |
@@ -524,11 +452,7 @@ class HasteMap extends EventEmitter { | |
/** | |
* Watch mode | |
*/ | |
- _watch( | |
- hasteMap, | |
- hasteFS, | |
- moduleMap) | |
- { | |
+ _watch(hasteMap, hasteFS, moduleMap) { | |
if (!this._options.watch) { | |
return Promise.resolve(); | |
} | |
@@ -538,9 +462,9 @@ class HasteMap extends EventEmitter { | |
this._options.throwOnModuleCollision = false; | |
this._options.retainAllFiles = true; | |
- const Watcher = canUseWatchman && this._options.useWatchman ? | |
- sane.WatchmanWatcher : | |
- sane.NodeWatcher; | |
+ const Watcher = canUseWatchman && this._options.useWatchman | |
+ ? sane.WatchmanWatcher | |
+ : sane.NodeWatcher; | |
const extensions = this._options.extensions; | |
const ignorePattern = this._options.ignorePattern; | |
let changeQueue = Promise.resolve(); | |
@@ -554,14 +478,14 @@ class HasteMap extends EventEmitter { | |
const watcher = new Watcher(root, { | |
dot: false, | |
glob: extensions.map(extension => '**/*.' + extension), | |
- ignored: ignorePattern }); | |
- | |
+ ignored: ignorePattern, | |
+ }); | |
return new Promise((resolve, reject) => { | |
const rejectTimeout = setTimeout( | |
- () => reject(new Error('Failed to start watch mode.')), | |
- MAX_WAIT_TIME); | |
- | |
+ () => reject(new Error('Failed to start watch mode.')), | |
+ MAX_WAIT_TIME | |
+ ); | |
watcher.once('ready', () => { | |
clearTimeout(rejectTimeout); | |
@@ -577,105 +501,102 @@ class HasteMap extends EventEmitter { | |
this.emit('change', { | |
eventsQueue, | |
hasteFS: new HasteFS(hasteMap.files), | |
- moduleMap: new HasteModuleMap(hasteMap.map, hasteMap.mocks) }); | |
+ moduleMap: new HasteModuleMap(hasteMap.map, hasteMap.mocks), | |
+ }); | |
eventsQueue = []; | |
} | |
}; | |
- const onChange = ( | |
- type, | |
- filePath, | |
- root, | |
- stat) => | |
- { | |
+ const onChange = (type, filePath, root, stat) => { | |
filePath = path.join(root, filePath); | |
if ( | |
- this._ignore(filePath) || | |
- !extensions.some(extension => filePath.endsWith(extension))) | |
- { | |
+ this._ignore(filePath) || | |
+ !extensions.some(extension => filePath.endsWith(extension)) | |
+ ) { | |
return; | |
} | |
- changeQueue = changeQueue. | |
- then(() => { | |
- // If we get duplicate events for the same file, ignore them. | |
- if ( | |
- eventsQueue.find( | |
- event => | |
- event.type === type && | |
- event.filePath === filePath && ( | |
- !event.stat && !stat || | |
- event.stat && | |
- stat && | |
- event.stat.mtime.getTime() === stat.mtime.getTime()))) | |
- | |
- { | |
- return null; | |
- } | |
- | |
- if (mustCopy) { | |
- mustCopy = false; | |
- hasteMap = { | |
- clocks: copy(hasteMap.clocks), | |
- files: copy(hasteMap.files), | |
- map: copy(hasteMap.map), | |
- mocks: copy(hasteMap.mocks) }; | |
- | |
- } | |
- | |
- const add = () => eventsQueue.push({ filePath, stat, type }); | |
- | |
- // Delete the file and all of its metadata. | |
- const moduleName = | |
- hasteMap.files[filePath] && hasteMap.files[filePath][H.ID]; | |
- delete hasteMap.files[filePath]; | |
- delete hasteMap.map[moduleName]; | |
- if ( | |
- this._options.mocksPattern && | |
- this._options.mocksPattern.test(filePath)) | |
- { | |
- const mockName = getMockName(filePath); | |
- delete hasteMap.mocks[mockName]; | |
- } | |
+ changeQueue = changeQueue | |
+ .then(() => { | |
+ // If we get duplicate events for the same file, ignore them. | |
+ if ( | |
+ eventsQueue.find( | |
+ event => | |
+ event.type === type && | |
+ event.filePath === filePath && | |
+ ((!event.stat && !stat) || | |
+ (event.stat && | |
+ stat && | |
+ event.stat.mtime.getTime() === stat.mtime.getTime())) | |
+ ) | |
+ ) { | |
+ return null; | |
+ } | |
- // If the file was added or changed, | |
- // parse it and update the haste map. | |
- if (type === 'add' || type === 'change') { | |
- const fileMetadata = ['', stat.mtime.getTime(), 0, []]; | |
- hasteMap.files[filePath] = fileMetadata; | |
- const promise = this._processFile( | |
- hasteMap, | |
- hasteMap.map, | |
- hasteMap.mocks, | |
- filePath, | |
- { | |
- forceInBand: true }); | |
+ if (mustCopy) { | |
+ mustCopy = false; | |
+ hasteMap = { | |
+ clocks: copy(hasteMap.clocks), | |
+ files: copy(hasteMap.files), | |
+ map: copy(hasteMap.map), | |
+ mocks: copy(hasteMap.mocks), | |
+ }; | |
+ } | |
+ const add = () => eventsQueue.push({filePath, stat, type}); | |
+ | |
+ // Delete the file and all of its metadata. | |
+ const moduleName = | |
+ hasteMap.files[filePath] && hasteMap.files[filePath][H.ID]; | |
+ delete hasteMap.files[filePath]; | |
+ delete hasteMap.map[moduleName]; | |
+ if ( | |
+ this._options.mocksPattern && | |
+ this._options.mocksPattern.test(filePath) | |
+ ) { | |
+ const mockName = getMockName(filePath); | |
+ delete hasteMap.mocks[mockName]; | |
+ } | |
- // Cleanup | |
- this._workerPromise = null; | |
- if (promise) { | |
- return promise.then(add); | |
+ // If the file was added or changed, | |
+ // parse it and update the haste map. | |
+ if (type === 'add' || type === 'change') { | |
+ const fileMetadata = ['', stat.mtime.getTime(), 0, []]; | |
+ hasteMap.files[filePath] = fileMetadata; | |
+ const promise = this._processFile( | |
+ hasteMap, | |
+ hasteMap.map, | |
+ hasteMap.mocks, | |
+ filePath, | |
+ { | |
+ forceInBand: true, | |
+ } | |
+ ); | |
+ | |
+ // Cleanup | |
+ this._workerPromise = null; | |
+ if (promise) { | |
+ return promise.then(add); | |
+ } else { | |
+ // If a file in node_modules has changed, | |
+ // emit an event regardless. | |
+ add(); | |
+ } | |
} else { | |
- // If a file in node_modules has changed, | |
- // emit an event regardless. | |
add(); | |
} | |
- } else { | |
- add(); | |
- } | |
- return null; | |
- }). | |
- catch(error => { | |
- this._console.error(`jest-haste-map: watch error:\n ${error}\n`); | |
- }); | |
+ return null; | |
+ }) | |
+ .catch(error => { | |
+ this._console.error(`jest-haste-map: watch error:\n ${error}\n`); | |
+ }); | |
}; | |
this._changeInterval = setInterval(emitChange, CHANGE_INTERVAL); | |
return Promise.all( | |
- this._options.roots.map(createWatcher)). | |
- then(watchers => { | |
+ this._options.roots.map(createWatcher) | |
+ ).then(watchers => { | |
this._watchers = watchers; | |
}); | |
} | |
@@ -687,10 +608,10 @@ class HasteMap extends EventEmitter { | |
} | |
return Promise.all( | |
- this._watchers.map( | |
- watcher => new Promise(resolve => watcher.close(resolve)))). | |
- | |
- then(() => this._watchers = []); | |
+ this._watchers.map( | |
+ watcher => new Promise(resolve => watcher.close(resolve)) | |
+ ) | |
+ ).then(() => (this._watchers = [])); | |
} | |
/** | |
@@ -698,14 +619,14 @@ class HasteMap extends EventEmitter { | |
*/ | |
_ignore(filePath) { | |
const ignorePattern = this._options.ignorePattern; | |
- const ignoreMatched = ignorePattern instanceof RegExp ? | |
- ignorePattern.test(filePath) : | |
- ignorePattern(filePath); | |
+ const ignoreMatched = ignorePattern instanceof RegExp | |
+ ? ignorePattern.test(filePath) | |
+ : ignorePattern(filePath); | |
return ( | |
ignoreMatched || | |
- !this._options.retainAllFiles && this._isNodeModulesDir(filePath)); | |
- | |
+ (!this._options.retainAllFiles && this._isNodeModulesDir(filePath)) | |
+ ); | |
} | |
_isNodeModulesDir(filePath) { | |
@@ -726,15 +647,12 @@ class HasteMap extends EventEmitter { | |
clocks: Object.create(null), | |
files: Object.create(null), | |
map: Object.create(null), | |
- mocks: Object.create(null) }; | |
- | |
- }} | |
- | |
- | |
- | |
- | |
+ mocks: Object.create(null), | |
+ }; | |
+ } | |
+} | |
HasteMap.H = H; | |
HasteMap.ModuleMap = HasteModuleMap; | |
-module.exports = HasteMap; | |
\ No newline at end of file | |
+module.exports = HasteMap; | |
diff --git i/packages/jest-haste-map/build/lib/extractRequires.js w/packages/jest-haste-map/build/lib/extractRequires.js | |
index 045545ed..1999a591 100644 | |
--- i/packages/jest-haste-map/build/lib/extractRequires.js | |
+++ w/packages/jest-haste-map/build/lib/extractRequires.js | |
@@ -17,7 +17,8 @@ const replacePatterns = { | |
EXPORT_RE: /(\bexport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g, | |
IMPORT_RE: /(\bimport\s+(?:[^'"]+\s+from\s+)??)(['"])([^'"]+)(\2)/g, | |
REQUIRE_EXTENSIONS_PATTERN: /(\b(?:require\s*?\.\s*?(?:requireActual|requireMock)|jest\s*?\.\s*?genMockFromModule)\s*?\(\s*?)([`'"])([^`'"]+)(\2\s*?\))/g, | |
- REQUIRE_RE: /(\brequire\s*?\(\s*?)([`'"])([^`'"]+)(\2\s*?\))/g }; | |
+ REQUIRE_RE: /(\brequire\s*?\(\s*?)([`'"])([^`'"]+)(\2\s*?\))/g, | |
+}; | |
/* eslint-enable max-len */ | |
@@ -28,15 +29,15 @@ function extractRequires(code) { | |
return match; | |
}; | |
- code. | |
- replace(blockCommentRe, ''). | |
- replace(lineCommentRe, ''). | |
- replace(replacePatterns.EXPORT_RE, addDependency). | |
- replace(replacePatterns.IMPORT_RE, addDependency). | |
- replace(replacePatterns.REQUIRE_EXTENSIONS_PATTERN, addDependency). | |
- replace(replacePatterns.REQUIRE_RE, addDependency); | |
+ code | |
+ .replace(blockCommentRe, '') | |
+ .replace(lineCommentRe, '') | |
+ .replace(replacePatterns.EXPORT_RE, addDependency) | |
+ .replace(replacePatterns.IMPORT_RE, addDependency) | |
+ .replace(replacePatterns.REQUIRE_EXTENSIONS_PATTERN, addDependency) | |
+ .replace(replacePatterns.REQUIRE_RE, addDependency); | |
return Array.from(dependencies); | |
} | |
-module.exports = extractRequires; | |
\ No newline at end of file | |
+module.exports = extractRequires; | |
diff --git i/packages/jest-haste-map/build/lib/getPlatformExtension.js w/packages/jest-haste-map/build/lib/getPlatformExtension.js | |
index 69d49c2d..08553208 100644 | |
--- i/packages/jest-haste-map/build/lib/getPlatformExtension.js | |
+++ w/packages/jest-haste-map/build/lib/getPlatformExtension.js | |
@@ -13,14 +13,11 @@ const SUPPORTED_PLATFORM_EXTS = { | |
android: true, | |
ios: true, | |
native: true, | |
- web: true }; | |
- | |
+ web: true, | |
+}; | |
// Extract platform extension: index.ios.js -> ios | |
-function getPlatformExtension( | |
-file, | |
-platforms) | |
-{ | |
+function getPlatformExtension(file, platforms) { | |
const last = file.lastIndexOf('.'); | |
const secondToLast = file.lastIndexOf('.', last - 1); | |
if (secondToLast === -1) { | |
@@ -35,4 +32,4 @@ platforms) | |
return SUPPORTED_PLATFORM_EXTS[platform] ? platform : null; | |
} | |
-module.exports = getPlatformExtension; | |
\ No newline at end of file | |
+module.exports = getPlatformExtension; | |
diff --git i/packages/jest-haste-map/build/types.js w/packages/jest-haste-map/build/types.js | |
index 4780db18..04ec3f0a 100644 | |
--- i/packages/jest-haste-map/build/types.js | |
+++ w/packages/jest-haste-map/build/types.js | |
@@ -7,4 +7,4 @@ | |
* | |
* | |
*/ | |
-'use strict'; | |
\ No newline at end of file | |
+'use strict'; | |
diff --git i/packages/jest-haste-map/build/worker.js w/packages/jest-haste-map/build/worker.js | |
index af80cb05..309e4908 100644 | |
--- i/packages/jest-haste-map/build/worker.js | |
+++ w/packages/jest-haste-map/build/worker.js | |
@@ -9,9 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
const H = require('./constants'); | |
const docblock = require('jest-docblock'); | |
@@ -30,30 +27,30 @@ const formatError = error => { | |
return { | |
message: error, | |
stack: null, | |
- type: 'Error' }; | |
- | |
+ type: 'Error', | |
+ }; | |
} | |
return { | |
message: error.message, | |
stack: error.stack, | |
- type: 'Error' }; | |
- | |
+ type: 'Error', | |
+ }; | |
}; | |
module.exports = (data, callback) => { | |
try { | |
if ( | |
- data.hasteImplModulePath && | |
- data.hasteImplModulePath !== hasteImplModulePath) | |
- { | |
+ data.hasteImplModulePath && | |
+ data.hasteImplModulePath !== hasteImplModulePath | |
+ ) { | |
if (hasteImpl) { | |
throw new Error('jest-haste-map: hasteImplModulePath changed'); | |
} | |
hasteImplModulePath = data.hasteImplModulePath; | |
hasteImpl = | |
- // $FlowFixMe: dynamic require | |
- require(hasteImplModulePath); | |
+ // $FlowFixMe: dynamic require | |
+ require(hasteImplModulePath); | |
} | |
const filePath = data.filePath; | |
@@ -81,8 +78,8 @@ module.exports = (data, callback) => { | |
} | |
} | |
- callback(null, { dependencies, id, module }); | |
+ callback(null, {dependencies, id, module}); | |
} catch (error) { | |
callback(formatError(error)); | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-jasmine2/build/ExpectationFailed.js w/packages/jest-jasmine2/build/ExpectationFailed.js | |
index 25e1dfd4..2685eb25 100644 | |
--- i/packages/jest-jasmine2/build/ExpectationFailed.js | |
+++ w/packages/jest-jasmine2/build/ExpectationFailed.js | |
@@ -11,4 +11,4 @@ | |
class ExpectationFailed extends Error {} | |
-module.exports = ExpectationFailed; | |
\ No newline at end of file | |
+module.exports = ExpectationFailed; | |
diff --git i/packages/jest-jasmine2/build/assert-support.js w/packages/jest-jasmine2/build/assert-support.js | |
index c659ee6e..ced76768 100644 | |
--- i/packages/jest-jasmine2/build/assert-support.js | |
+++ w/packages/jest-jasmine2/build/assert-support.js | |
@@ -8,37 +8,26 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('jest-matcher-utils');const printReceived = _require.printReceived,printExpected = _require.printExpected; | |
+'use strict'; | |
+var _require = require('jest-matcher-utils'); | |
+const printReceived = _require.printReceived, | |
+ printExpected = _require.printExpected; | |
const chalk = require('chalk'); | |
const diff = require('jest-diff'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const assertOperatorsMap = { | |
'!=': 'notEqual', | |
'!==': 'notStrictEqual', | |
'==': 'equal', | |
- '===': 'strictEqual' }; | |
- | |
+ '===': 'strictEqual', | |
+}; | |
const humanReadableOperators = { | |
deepEqual: 'to deeply equal', | |
deepStrictEqual: 'to deeply and strictly equal', | |
notDeepEqual: 'not to deeply equal', | |
- notDeepStrictEqual: 'not to deeply and strictly equal' }; | |
- | |
+ notDeepStrictEqual: 'not to deeply and strictly equal', | |
+}; | |
const getOperatorName = (operator, stack) => { | |
if (typeof operator === 'string') { | |
@@ -54,48 +43,52 @@ const getOperatorName = (operator, stack) => { | |
}; | |
const operatorMessage = (operator, negator) => | |
-typeof operator === 'string' ? | |
-operator.startsWith('!') || operator.startsWith('=') ? | |
-`${negator ? 'not ' : ''}to be (operator: ${operator}):\n` : | |
-`${humanReadableOperators[operator] || operator} to:\n` : | |
-''; | |
+ typeof operator === 'string' | |
+ ? operator.startsWith('!') || operator.startsWith('=') | |
+ ? `${negator ? 'not ' : ''}to be (operator: ${operator}):\n` | |
+ : `${humanReadableOperators[operator] || operator} to:\n` | |
+ : ''; | |
const assertThrowingMatcherHint = operatorName => { | |
return ( | |
chalk.dim('assert') + | |
chalk.dim('.' + operatorName + '(') + | |
chalk.red('function') + | |
- chalk.dim(')')); | |
- | |
+ chalk.dim(')') | |
+ ); | |
}; | |
const assertMatcherHint = (operator, operatorName) => { | |
let message = | |
- chalk.dim('assert') + | |
- chalk.dim('.' + operatorName + '(') + | |
- chalk.red('received') + | |
- chalk.dim(', ') + | |
- chalk.green('expected') + | |
- chalk.dim(')'); | |
+ chalk.dim('assert') + | |
+ chalk.dim('.' + operatorName + '(') + | |
+ chalk.red('received') + | |
+ chalk.dim(', ') + | |
+ chalk.green('expected') + | |
+ chalk.dim(')'); | |
if (operator === '==') { | |
message += | |
- ' or ' + | |
- chalk.dim('assert') + | |
- chalk.dim('(') + | |
- chalk.red('received') + | |
- chalk.dim(') '); | |
+ ' or ' + | |
+ chalk.dim('assert') + | |
+ chalk.dim('(') + | |
+ chalk.red('received') + | |
+ chalk.dim(') '); | |
} | |
return message; | |
}; | |
-function assertionErrorMessage(error, options) {const | |
- expected = error.expected,actual = error.actual,message = error.message,operator = error.operator,stack = error.stack; | |
+function assertionErrorMessage(error, options) { | |
+ const expected = error.expected, | |
+ actual = error.actual, | |
+ message = error.message, | |
+ operator = error.operator, | |
+ stack = error.stack; | |
const diffString = diff(expected, actual, options); | |
const negator = | |
- typeof operator === 'string' && ( | |
- operator.startsWith('!') || operator.startsWith('not')); | |
+ typeof operator === 'string' && | |
+ (operator.startsWith('!') || operator.startsWith('not')); | |
const hasCustomMessage = !error.generatedMessage; | |
const operatorName = getOperatorName(operator, stack); | |
@@ -107,8 +100,8 @@ function assertionErrorMessage(error, options) {const | |
chalk.reset(`Instead, it threw:\n`) + | |
` ${printReceived(actual)}` + | |
chalk.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') + | |
- stack.replace(/AssertionError(.*)/g, '')); | |
- | |
+ stack.replace(/AssertionError(.*)/g, '') | |
+ ); | |
} | |
if (operatorName === 'throws') { | |
@@ -118,8 +111,8 @@ function assertionErrorMessage(error, options) {const | |
chalk.reset(`Expected the function to throw an error.\n`) + | |
chalk.reset(`But it didn't throw anything.`) + | |
chalk.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') + | |
- stack.replace(/AssertionError(.*)/g, '')); | |
- | |
+ stack.replace(/AssertionError(.*)/g, '') | |
+ ); | |
} | |
return ( | |
@@ -129,10 +122,10 @@ function assertionErrorMessage(error, options) {const | |
` ${printExpected(expected)}\n` + | |
chalk.reset(`Received:\n`) + | |
` ${printReceived(actual)}` + | |
- chalk.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') + ( | |
- diffString ? `\n\nDifference:\n\n${diffString}` : '') + | |
- stack.replace(/AssertionError(.*)/g, '')); | |
- | |
+ chalk.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') + | |
+ (diffString ? `\n\nDifference:\n\n${diffString}` : '') + | |
+ stack.replace(/AssertionError(.*)/g, '') | |
+ ); | |
} | |
-module.exports = assertionErrorMessage; | |
\ No newline at end of file | |
+module.exports = assertionErrorMessage; | |
diff --git i/packages/jest-jasmine2/build/expectationResultFactory.js w/packages/jest-jasmine2/build/expectationResultFactory.js | |
index b03b0fae..ae5af66a 100644 | |
--- i/packages/jest-jasmine2/build/expectationResultFactory.js | |
+++ w/packages/jest-jasmine2/build/expectationResultFactory.js | |
@@ -9,7 +9,8 @@ | |
*/ | |
'use strict'; | |
-function messageFormatter(_ref) {let error = _ref.error,message = _ref.message,passed = _ref.passed; | |
+function messageFormatter(_ref) { | |
+ let error = _ref.error, message = _ref.message, passed = _ref.passed; | |
if (passed) { | |
return 'Passed.'; | |
} | |
@@ -19,28 +20,20 @@ function messageFormatter(_ref) {let error = _ref.error,message = _ref.message,p | |
if (!error) { | |
return ''; | |
} | |
- return error.message && error.name ? | |
- `${error.name}: ${error.message}` : | |
- `${error.toString()} thrown`; | |
+ return error.message && error.name | |
+ ? `${error.name}: ${error.message}` | |
+ : `${error.toString()} thrown`; | |
} | |
function stackFormatter(options, errorMessage) { | |
if (options.passed) { | |
return ''; | |
- }var _ref2 = | |
- options.error || new Error(errorMessage);const stack = _ref2.stack; | |
+ } | |
+ var _ref2 = options.error || new Error(errorMessage); | |
+ const stack = _ref2.stack; | |
return stack; | |
} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
function expectationResultFactory(options) { | |
const message = messageFormatter(options); | |
const stack = stackFormatter(options, message); | |
@@ -51,8 +44,8 @@ function expectationResultFactory(options) { | |
matcherName: options.matcherName, | |
message, | |
passed: options.passed, | |
- stack }; | |
- | |
+ stack, | |
+ }; | |
} | |
return { | |
@@ -62,8 +55,8 @@ function expectationResultFactory(options) { | |
matcherName: options.matcherName, | |
message, | |
passed: options.passed, | |
- stack }; | |
- | |
+ stack, | |
+ }; | |
} | |
-module.exports = expectationResultFactory; | |
\ No newline at end of file | |
+module.exports = expectationResultFactory; | |
diff --git i/packages/jest-jasmine2/build/index.js w/packages/jest-jasmine2/build/index.js | |
index 4f997b9b..18567e54 100644 | |
--- i/packages/jest-jasmine2/build/index.js | |
+++ w/packages/jest-jasmine2/build/index.js | |
@@ -9,12 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
const JasmineReporter = require('./reporter'); | |
const jasmineAsync = require('./jasmine-async'); | |
@@ -22,18 +16,13 @@ const path = require('path'); | |
const JASMINE = require.resolve('./jasmine/jasmine-light.js'); | |
-function jasmine2( | |
-globalConfig, | |
-config, | |
-environment, | |
-runtime, | |
-testPath) | |
-{ | |
+function jasmine2(globalConfig, config, environment, runtime, testPath) { | |
const reporter = new JasmineReporter( | |
- globalConfig, | |
- config, | |
- environment, | |
- testPath); | |
+ globalConfig, | |
+ config, | |
+ environment, | |
+ testPath | |
+ ); | |
const jasmineFactory = runtime.requireInternalModule(JASMINE); | |
const jasmine = jasmineFactory.create(); | |
@@ -73,17 +62,17 @@ testPath) | |
env.addReporter(reporter); | |
runtime.requireInternalModule(path.resolve(__dirname, './jest-expect.js'))({ | |
- expand: globalConfig.expand }); | |
- | |
+ expand: globalConfig.expand, | |
+ }); | |
const snapshotState = runtime.requireInternalModule( | |
- path.resolve(__dirname, './setup-jest-globals.js'))( | |
- { | |
+ path.resolve(__dirname, './setup-jest-globals.js') | |
+ )({ | |
config, | |
globalConfig, | |
localRequire: runtime.requireModule.bind(runtime), | |
- testPath }); | |
- | |
+ testPath, | |
+ }); | |
if (config.setupTestFrameworkScriptFile) { | |
runtime.requireModule(config.setupTestFrameworkScriptFile); | |
@@ -96,13 +85,14 @@ testPath) | |
runtime.requireModule(testPath); | |
env.execute(); | |
- return reporter. | |
- getResults(). | |
- then(results => addSnapshotData(results, snapshotState)); | |
+ return reporter | |
+ .getResults() | |
+ .then(results => addSnapshotData(results, snapshotState)); | |
} | |
const addSnapshotData = (results, snapshotState) => { | |
- results.testResults.forEach((_ref) => {let fullName = _ref.fullName,status = _ref.status; | |
+ results.testResults.forEach(_ref => { | |
+ let fullName = _ref.fullName, status = _ref.status; | |
if (status === 'pending' || status === 'failed') { | |
// if test is skipped or failed, we don't want to mark | |
// its snapshots as obsolete. | |
@@ -125,4 +115,4 @@ const addSnapshotData = (results, snapshotState) => { | |
return results; | |
}; | |
-module.exports = jasmine2; | |
\ No newline at end of file | |
+module.exports = jasmine2; | |
diff --git i/packages/jest-jasmine2/build/jasmine-async.js w/packages/jest-jasmine2/build/jasmine-async.js | |
index 27e21d41..1d088dcb 100644 | |
--- i/packages/jest-jasmine2/build/jasmine-async.js | |
+++ w/packages/jest-jasmine2/build/jasmine-async.js | |
@@ -15,14 +15,12 @@ | |
'use strict'; | |
- | |
- | |
function isPromise(obj) { | |
return obj && typeof obj.then === 'function'; | |
} | |
function promisifyLifeCycleFunction(originalFn, env) { | |
- return function (fn, timeout) { | |
+ return function(fn, timeout) { | |
if (!fn) { | |
return originalFn.call(env); | |
} | |
@@ -36,7 +34,7 @@ function promisifyLifeCycleFunction(originalFn, env) { | |
// We make *all* functions async and run `done` right away if they | |
// didn't return a promise. | |
- const asyncFn = function (done) { | |
+ const asyncFn = function(done) { | |
const returnValue = fn.call(this); | |
if (isPromise(returnValue)) { | |
@@ -53,7 +51,7 @@ function promisifyLifeCycleFunction(originalFn, env) { | |
// Similar to promisifyLifeCycleFunction but throws an error | |
// when the return value is neither a Promise nor `undefined` | |
function promisifyIt(originalFn, env) { | |
- return function (specName, fn, timeout) { | |
+ return function(specName, fn, timeout) { | |
if (!fn) { | |
const spec = originalFn.call(env, specName); | |
spec.pend('not implemented'); | |
@@ -66,7 +64,7 @@ function promisifyIt(originalFn, env) { | |
return originalFn.call(env, specName, fn, timeout); | |
} | |
- const asyncFn = function (done) { | |
+ const asyncFn = function(done) { | |
const returnValue = fn.call(this); | |
if (isPromise(returnValue)) { | |
@@ -75,10 +73,10 @@ function promisifyIt(originalFn, env) { | |
done(); | |
} else { | |
done.fail( | |
- new Error( | |
- 'Jest: `it` and `test` must return either a Promise or undefined.')); | |
- | |
- | |
+ new Error( | |
+ 'Jest: `it` and `test` must return either a Promise or undefined.' | |
+ ) | |
+ ); | |
} | |
}; | |
@@ -87,8 +85,8 @@ function promisifyIt(originalFn, env) { | |
} | |
function makeConcurrent(originalFn, env) { | |
- return function (specName, fn, timeout) { | |
- if (env != null && !env.specFilter({ getFullName: () => specName || '' })) { | |
+ return function(specName, fn, timeout) { | |
+ if (env != null && !env.specFilter({getFullName: () => specName || ''})) { | |
return originalFn.call(env, specName, () => Promise.resolve(), timeout); | |
} | |
@@ -98,8 +96,8 @@ function makeConcurrent(originalFn, env) { | |
promise = fn(); | |
if (!isPromise(promise)) { | |
throw new Error( | |
- `Jest: concurrent test "${specName}" must return a Promise.`); | |
- | |
+ `Jest: concurrent test "${specName}" must return a Promise.` | |
+ ); | |
} | |
} catch (error) { | |
return originalFn.call(env, specName, () => Promise.reject(error)); | |
@@ -126,4 +124,5 @@ function install(global) { | |
} | |
module.exports = { | |
- install }; | |
\ No newline at end of file | |
+ install, | |
+}; | |
diff --git i/packages/jest-jasmine2/build/jasmine/CallTracker.js w/packages/jest-jasmine2/build/jasmine/CallTracker.js | |
index 35eae355..7e8176ef 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/CallTracker.js | |
+++ w/packages/jest-jasmine2/build/jasmine/CallTracker.js | |
@@ -35,28 +35,28 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
function CallTracker() { | |
let calls = []; | |
- this.track = function (context) { | |
+ this.track = function(context) { | |
calls.push(context); | |
}; | |
- this.any = function () { | |
+ this.any = function() { | |
return !!calls.length; | |
}; | |
- this.count = function () { | |
+ this.count = function() { | |
return calls.length; | |
}; | |
- this.argsFor = function (index) { | |
+ this.argsFor = function(index) { | |
const call = calls[index]; | |
return call ? call.args : []; | |
}; | |
- this.all = function () { | |
+ this.all = function() { | |
return calls; | |
}; | |
- this.allArgs = function () { | |
+ this.allArgs = function() { | |
const callArgs = []; | |
for (let i = 0; i < calls.length; i++) { | |
callArgs.push(calls[i].args); | |
@@ -65,17 +65,17 @@ function CallTracker() { | |
return callArgs; | |
}; | |
- this.first = function () { | |
+ this.first = function() { | |
return calls[0]; | |
}; | |
- this.mostRecent = function () { | |
+ this.mostRecent = function() { | |
return calls[calls.length - 1]; | |
}; | |
- this.reset = function () { | |
+ this.reset = function() { | |
calls = []; | |
}; | |
} | |
-module.exports = CallTracker; | |
\ No newline at end of file | |
+module.exports = CallTracker; | |
diff --git i/packages/jest-jasmine2/build/jasmine/Env.js w/packages/jest-jasmine2/build/jasmine/Env.js | |
index 1504188c..9bf7b166 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/Env.js | |
+++ w/packages/jest-jasmine2/build/jasmine/Env.js | |
@@ -35,7 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
const queueRunner = require('../queueRunner'); | |
const treeProcessor = require('../treeProcessor'); | |
-module.exports = function (j$) { | |
+module.exports = function(j$) { | |
function Env(options) { | |
options = options || {}; | |
@@ -57,50 +57,50 @@ module.exports = function (j$) { | |
let random = false; | |
let seed = null; | |
- const currentSuite = function () { | |
+ const currentSuite = function() { | |
return currentlyExecutingSuites[currentlyExecutingSuites.length - 1]; | |
}; | |
- const currentRunnable = function () { | |
+ const currentRunnable = function() { | |
return currentSpec || currentSuite(); | |
}; | |
const reporter = new j$.ReportDispatcher([ | |
- 'jasmineStarted', | |
- 'jasmineDone', | |
- 'suiteStarted', | |
- 'suiteDone', | |
- 'specStarted', | |
- 'specDone']); | |
- | |
- | |
- this.specFilter = function () { | |
+ 'jasmineStarted', | |
+ 'jasmineDone', | |
+ 'suiteStarted', | |
+ 'suiteDone', | |
+ 'specStarted', | |
+ 'specDone', | |
+ ]); | |
+ | |
+ this.specFilter = function() { | |
return true; | |
}; | |
let nextSpecId = 0; | |
- const getNextSpecId = function () { | |
+ const getNextSpecId = function() { | |
return 'spec' + nextSpecId++; | |
}; | |
let nextSuiteId = 0; | |
- const getNextSuiteId = function () { | |
+ const getNextSuiteId = function() { | |
return 'suite' + nextSuiteId++; | |
}; | |
- const defaultResourcesForRunnable = function (id, parentRunnableId) { | |
- const resources = { spies: [] }; | |
+ const defaultResourcesForRunnable = function(id, parentRunnableId) { | |
+ const resources = {spies: []}; | |
runnableResources[id] = resources; | |
}; | |
- const clearResourcesForRunnable = function (id) { | |
+ const clearResourcesForRunnable = function(id) { | |
spyRegistry.clearSpies(); | |
delete runnableResources[id]; | |
}; | |
- const beforeAndAfterFns = function (suite) { | |
- return function () { | |
+ const beforeAndAfterFns = function(suite) { | |
+ return function() { | |
let afters = []; | |
let befores = []; | |
@@ -113,12 +113,12 @@ module.exports = function (j$) { | |
return { | |
befores: befores.reverse(), | |
- afters }; | |
- | |
+ afters, | |
+ }; | |
}; | |
}; | |
- const getSpecName = function (spec, suite) { | |
+ const getSpecName = function(spec, suite) { | |
const fullName = [spec.description]; | |
const suiteFullName = suite.getFullName(); | |
@@ -129,32 +129,32 @@ module.exports = function (j$) { | |
return fullName.join(' '); | |
}; | |
- this.catchExceptions = function (value) { | |
+ this.catchExceptions = function(value) { | |
catchExceptions = !!value; | |
return catchExceptions; | |
}; | |
- this.catchingExceptions = function () { | |
+ this.catchingExceptions = function() { | |
return catchExceptions; | |
}; | |
- this.throwOnExpectationFailure = function (value) { | |
+ this.throwOnExpectationFailure = function(value) { | |
throwOnExpectationFailure = !!value; | |
}; | |
- this.throwingExpectationFailures = function () { | |
+ this.throwingExpectationFailures = function() { | |
return throwOnExpectationFailure; | |
}; | |
- this.randomizeTests = function (value) { | |
+ this.randomizeTests = function(value) { | |
random = !!value; | |
}; | |
- this.randomTests = function () { | |
+ this.randomTests = function() { | |
return random; | |
}; | |
- this.seed = function (value) { | |
+ this.seed = function(value) { | |
if (value) { | |
seed = value; | |
} | |
@@ -169,16 +169,17 @@ module.exports = function (j$) { | |
} | |
const topSuite = new j$.Suite({ | |
- id: getNextSuiteId() }); | |
+ id: getNextSuiteId(), | |
+ }); | |
defaultResourcesForRunnable(topSuite.id); | |
currentDeclarationSuite = topSuite; | |
- this.topSuite = function () { | |
+ this.topSuite = function() { | |
return topSuite; | |
}; | |
- this.execute = function (runnablesToRun) { | |
+ this.execute = function(runnablesToRun) { | |
if (!runnablesToRun) { | |
if (focusedRunnables.length) { | |
runnablesToRun = focusedRunnables; | |
@@ -188,8 +189,8 @@ module.exports = function (j$) { | |
} | |
reporter.jasmineStarted({ | |
- totalSpecsDefined }); | |
- | |
+ totalSpecsDefined, | |
+ }); | |
currentlyExecutingSuites.push(topSuite); | |
@@ -208,25 +209,25 @@ module.exports = function (j$) { | |
}, | |
queueRunnerFactory, | |
runnableIds: runnablesToRun, | |
- tree: topSuite }). | |
- then(() => { | |
+ tree: topSuite, | |
+ }).then(() => { | |
clearResourcesForRunnable(topSuite.id); | |
currentlyExecutingSuites.pop(); | |
reporter.jasmineDone({ | |
- failedExpectations: topSuite.result.failedExpectations }); | |
- | |
+ failedExpectations: topSuite.result.failedExpectations, | |
+ }); | |
}); | |
}; | |
- this.addReporter = function (reporterToAdd) { | |
+ this.addReporter = function(reporterToAdd) { | |
reporter.addReporter(reporterToAdd); | |
}; | |
- this.provideFallbackReporter = function (reporterToAdd) { | |
+ this.provideFallbackReporter = function(reporterToAdd) { | |
reporter.provideFallbackReporter(reporterToAdd); | |
}; | |
- this.clearReporters = function () { | |
+ this.clearReporters = function() { | |
reporter.clearReporters(); | |
}; | |
@@ -234,33 +235,33 @@ module.exports = function (j$) { | |
currentSpies() { | |
if (!currentRunnable()) { | |
throw new Error( | |
- 'Spies must be created in a before function or a spec'); | |
- | |
+ 'Spies must be created in a before function or a spec' | |
+ ); | |
} | |
return runnableResources[currentRunnable().id].spies; | |
- } }); | |
+ }, | |
+ }); | |
- | |
- this.allowRespy = function (allow) { | |
+ this.allowRespy = function(allow) { | |
spyRegistry.allowRespy(allow); | |
}; | |
- this.spyOn = function () { | |
+ this.spyOn = function() { | |
return spyRegistry.spyOn.apply(spyRegistry, arguments); | |
}; | |
- const suiteFactory = function (description) { | |
+ const suiteFactory = function(description) { | |
const suite = new j$.Suite({ | |
id: getNextSuiteId(), | |
description, | |
parentSuite: currentDeclarationSuite, | |
- throwOnExpectationFailure }); | |
- | |
+ throwOnExpectationFailure, | |
+ }); | |
return suite; | |
}; | |
- this.describe = function (description, specDefinitions) { | |
+ this.describe = function(description, specDefinitions) { | |
const suite = suiteFactory(description); | |
if (specDefinitions.length > 0) { | |
throw new Error('describe does not expect any arguments'); | |
@@ -272,7 +273,7 @@ module.exports = function (j$) { | |
return suite; | |
}; | |
- this.xdescribe = function (description, specDefinitions) { | |
+ this.xdescribe = function(description, specDefinitions) { | |
const suite = suiteFactory(description); | |
suite.pend(); | |
addSpecsToSuite(suite, specDefinitions); | |
@@ -281,7 +282,7 @@ module.exports = function (j$) { | |
const focusedRunnables = []; | |
- this.fdescribe = function (description, specDefinitions) { | |
+ this.fdescribe = function(description, specDefinitions) { | |
const suite = suiteFactory(description); | |
suite.isFocused = true; | |
@@ -336,7 +337,7 @@ module.exports = function (j$) { | |
} | |
} | |
- const specFactory = function (description, fn, suite, timeout) { | |
+ const specFactory = function(description, fn, suite, timeout) { | |
totalSpecsDefined++; | |
const spec = new j$.Spec({ | |
id: getNextSpecId(), | |
@@ -355,10 +356,11 @@ module.exports = function (j$) { | |
fn, | |
timeout() { | |
return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; | |
- } }, | |
- | |
- throwOnExpectationFailure }); | |
+ }, | |
+ }, | |
+ throwOnExpectationFailure, | |
+ }); | |
if (!self.specFilter(spec)) { | |
spec.disable(); | |
@@ -379,12 +381,13 @@ module.exports = function (j$) { | |
} | |
}; | |
- this.it = function (description, fn, timeout) { | |
+ this.it = function(description, fn, timeout) { | |
const spec = specFactory( | |
- description, | |
- fn, | |
- currentDeclarationSuite, | |
- timeout); | |
+ description, | |
+ fn, | |
+ currentDeclarationSuite, | |
+ timeout | |
+ ); | |
if (currentDeclarationSuite.markedPending) { | |
spec.pend(); | |
@@ -393,18 +396,19 @@ module.exports = function (j$) { | |
return spec; | |
}; | |
- this.xit = function () { | |
+ this.xit = function() { | |
const spec = this.it.apply(this, arguments); | |
spec.pend('Temporarily disabled with xit'); | |
return spec; | |
}; | |
- this.fit = function (description, fn, timeout) { | |
+ this.fit = function(description, fn, timeout) { | |
const spec = specFactory( | |
- description, | |
- fn, | |
- currentDeclarationSuite, | |
- timeout); | |
+ description, | |
+ fn, | |
+ currentDeclarationSuite, | |
+ timeout | |
+ ); | |
currentDeclarationSuite.addChild(spec); | |
focusedRunnables.push(spec.id); | |
@@ -412,43 +416,43 @@ module.exports = function (j$) { | |
return spec; | |
}; | |
- this.beforeEach = function (beforeEachFunction, timeout) { | |
+ this.beforeEach = function(beforeEachFunction, timeout) { | |
currentDeclarationSuite.beforeEach({ | |
fn: beforeEachFunction, | |
timeout() { | |
return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; | |
- } }); | |
- | |
+ }, | |
+ }); | |
}; | |
- this.beforeAll = function (beforeAllFunction, timeout) { | |
+ this.beforeAll = function(beforeAllFunction, timeout) { | |
currentDeclarationSuite.beforeAll({ | |
fn: beforeAllFunction, | |
timeout() { | |
return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; | |
- } }); | |
- | |
+ }, | |
+ }); | |
}; | |
- this.afterEach = function (afterEachFunction, timeout) { | |
+ this.afterEach = function(afterEachFunction, timeout) { | |
currentDeclarationSuite.afterEach({ | |
fn: afterEachFunction, | |
timeout() { | |
return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; | |
- } }); | |
- | |
+ }, | |
+ }); | |
}; | |
- this.afterAll = function (afterAllFunction, timeout) { | |
+ this.afterAll = function(afterAllFunction, timeout) { | |
currentDeclarationSuite.afterAll({ | |
fn: afterAllFunction, | |
timeout() { | |
return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; | |
- } }); | |
- | |
+ }, | |
+ }); | |
}; | |
- this.pending = function (message) { | |
+ this.pending = function(message) { | |
let fullMessage = j$.Spec.pendingSpecExceptionMessage; | |
if (message) { | |
fullMessage += message; | |
@@ -456,7 +460,7 @@ module.exports = function (j$) { | |
throw fullMessage; | |
}; | |
- this.fail = function (error) { | |
+ this.fail = function(error) { | |
let message = 'Failed'; | |
if (error) { | |
message += ': '; | |
@@ -469,10 +473,10 @@ module.exports = function (j$) { | |
expected: '', | |
actual: '', | |
message, | |
- error: error && error.message ? error : null }); | |
- | |
+ error: error && error.message ? error : null, | |
+ }); | |
}; | |
} | |
return Env; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-jasmine2/build/jasmine/JsApiReporter.js w/packages/jest-jasmine2/build/jasmine/JsApiReporter.js | |
index a20d0090..4bba2819 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/JsApiReporter.js | |
+++ w/packages/jest-jasmine2/build/jasmine/JsApiReporter.js | |
@@ -36,8 +36,8 @@ const noopTimer = { | |
start() {}, | |
elapsed() { | |
return 0; | |
- } }; | |
- | |
+ }, | |
+}; | |
function JsApiReporter(options) { | |
const timer = options.timer || noopTimer; | |
@@ -47,7 +47,7 @@ function JsApiReporter(options) { | |
this.finished = false; | |
this.runDetails = {}; | |
- this.jasmineStarted = function () { | |
+ this.jasmineStarted = function() { | |
this.started = true; | |
status = 'started'; | |
timer.start(); | |
@@ -55,29 +55,29 @@ function JsApiReporter(options) { | |
let executionTime; | |
- this.jasmineDone = function (runDetails) { | |
+ this.jasmineDone = function(runDetails) { | |
this.finished = true; | |
this.runDetails = runDetails; | |
executionTime = timer.elapsed(); | |
status = 'done'; | |
}; | |
- this.status = function () { | |
+ this.status = function() { | |
return status; | |
}; | |
const suites = []; | |
const suites_hash = {}; | |
- this.suiteStarted = function (result) { | |
+ this.suiteStarted = function(result) { | |
suites_hash[result.id] = result; | |
}; | |
- this.suiteDone = function (result) { | |
+ this.suiteDone = function(result) { | |
storeSuite(result); | |
}; | |
- this.suiteResults = function (index, length) { | |
+ this.suiteResults = function(index, length) { | |
return suites.slice(index, index + length); | |
}; | |
@@ -86,27 +86,27 @@ function JsApiReporter(options) { | |
suites_hash[result.id] = result; | |
} | |
- this.suites = function () { | |
+ this.suites = function() { | |
return suites_hash; | |
}; | |
const specs = []; | |
- this.specDone = function (result) { | |
+ this.specDone = function(result) { | |
specs.push(result); | |
}; | |
- this.specResults = function (index, length) { | |
+ this.specResults = function(index, length) { | |
return specs.slice(index, index + length); | |
}; | |
- this.specs = function () { | |
+ this.specs = function() { | |
return specs; | |
}; | |
- this.executionTime = function () { | |
+ this.executionTime = function() { | |
return executionTime; | |
}; | |
} | |
-module.exports = JsApiReporter; | |
\ No newline at end of file | |
+module.exports = JsApiReporter; | |
diff --git i/packages/jest-jasmine2/build/jasmine/ReportDispatcher.js w/packages/jest-jasmine2/build/jasmine/ReportDispatcher.js | |
index 1630e2fc..15e4bb6c 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/ReportDispatcher.js | |
+++ w/packages/jest-jasmine2/build/jasmine/ReportDispatcher.js | |
@@ -37,25 +37,25 @@ function ReportDispatcher(methods) { | |
for (let i = 0; i < dispatchedMethods.length; i++) { | |
const method = dispatchedMethods[i]; | |
- this[method] = function (m) { | |
- return function () { | |
+ this[method] = (function(m) { | |
+ return function() { | |
dispatch(m, arguments); | |
}; | |
- }(method); | |
+ })(method); | |
} | |
let reporters = []; | |
let fallbackReporter = null; | |
- this.addReporter = function (reporter) { | |
+ this.addReporter = function(reporter) { | |
reporters.push(reporter); | |
}; | |
- this.provideFallbackReporter = function (reporter) { | |
+ this.provideFallbackReporter = function(reporter) { | |
fallbackReporter = reporter; | |
}; | |
- this.clearReporters = function () { | |
+ this.clearReporters = function() { | |
reporters = []; | |
}; | |
@@ -74,4 +74,4 @@ function ReportDispatcher(methods) { | |
} | |
} | |
-module.exports = ReportDispatcher; | |
\ No newline at end of file | |
+module.exports = ReportDispatcher; | |
diff --git i/packages/jest-jasmine2/build/jasmine/Spec.js w/packages/jest-jasmine2/build/jasmine/Spec.js | |
index 8213f4bc..13a98070 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/Spec.js | |
+++ w/packages/jest-jasmine2/build/jasmine/Spec.js | |
@@ -36,27 +36,27 @@ const ExpectationFailed = require('../ExpectationFailed'); | |
const expectationResultFactory = require('../expectationResultFactory'); | |
function Spec(attrs) { | |
- this.resultCallback = attrs.resultCallback || function () {}; | |
+ this.resultCallback = attrs.resultCallback || function() {}; | |
this.id = attrs.id; | |
this.description = attrs.description || ''; | |
this.queueableFn = attrs.queueableFn; | |
this.beforeAndAfterFns = | |
- attrs.beforeAndAfterFns || | |
- function () { | |
- return { befores: [], afters: [] }; | |
- }; | |
+ attrs.beforeAndAfterFns || | |
+ function() { | |
+ return {befores: [], afters: []}; | |
+ }; | |
this.userContext = | |
- attrs.userContext || | |
- function () { | |
- return {}; | |
- }; | |
- this.onStart = attrs.onStart || function () {}; | |
+ attrs.userContext || | |
+ function() { | |
+ return {}; | |
+ }; | |
+ this.onStart = attrs.onStart || function() {}; | |
this.getSpecName = | |
- attrs.getSpecName || | |
- function () { | |
- return ''; | |
- }; | |
- this.queueRunnerFactory = attrs.queueRunnerFactory || function () {}; | |
+ attrs.getSpecName || | |
+ function() { | |
+ return ''; | |
+ }; | |
+ this.queueRunnerFactory = attrs.queueRunnerFactory || function() {}; | |
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure; | |
this.result = { | |
@@ -65,11 +65,11 @@ function Spec(attrs) { | |
fullName: this.getFullName(), | |
failedExpectations: [], | |
passedExpectations: [], | |
- pendingReason: '' }; | |
- | |
+ pendingReason: '', | |
+ }; | |
} | |
-Spec.prototype.addExpectationResult = function (passed, data, isError) { | |
+Spec.prototype.addExpectationResult = function(passed, data, isError) { | |
const expectationResult = expectationResultFactory(data); | |
if (passed) { | |
this.result.passedExpectations.push(expectationResult); | |
@@ -82,7 +82,7 @@ Spec.prototype.addExpectationResult = function (passed, data, isError) { | |
} | |
}; | |
-Spec.prototype.execute = function (onComplete, enabled) { | |
+Spec.prototype.execute = function(onComplete, enabled) { | |
const self = this; | |
this.onStart(this); | |
@@ -100,8 +100,8 @@ Spec.prototype.execute = function (onComplete, enabled) { | |
onException() { | |
self.onException.apply(self, arguments); | |
}, | |
- userContext: this.userContext() }). | |
- then(() => complete(true)); | |
+ userContext: this.userContext(), | |
+ }).then(() => complete(true)); | |
function complete(enabledAgain) { | |
self.result.status = self.status(enabledAgain); | |
@@ -125,39 +125,39 @@ Spec.prototype.onException = function onException(error) { | |
if (error instanceof require('assert').AssertionError) { | |
const assertionErrorMessage = require('../assert-support'); | |
- error = assertionErrorMessage(error, { expand: this.expand }); | |
+ error = assertionErrorMessage(error, {expand: this.expand}); | |
} | |
this.addExpectationResult( | |
- false, | |
- { | |
- matcherName: '', | |
- passed: false, | |
- expected: '', | |
- actual: '', | |
- error }, | |
- | |
- true); | |
- | |
+ false, | |
+ { | |
+ matcherName: '', | |
+ passed: false, | |
+ expected: '', | |
+ actual: '', | |
+ error, | |
+ }, | |
+ true | |
+ ); | |
}; | |
-Spec.prototype.disable = function () { | |
+Spec.prototype.disable = function() { | |
this.disabled = true; | |
}; | |
-Spec.prototype.pend = function (message) { | |
+Spec.prototype.pend = function(message) { | |
this.markedPending = true; | |
if (message) { | |
this.result.pendingReason = message; | |
} | |
}; | |
-Spec.prototype.getResult = function () { | |
+Spec.prototype.getResult = function() { | |
this.result.status = this.status(); | |
return this.result; | |
}; | |
-Spec.prototype.status = function (enabled) { | |
+Spec.prototype.status = function(enabled) { | |
if (this.disabled || enabled === false) { | |
return 'disabled'; | |
} | |
@@ -173,31 +173,32 @@ Spec.prototype.status = function (enabled) { | |
} | |
}; | |
-Spec.prototype.isExecutable = function () { | |
+Spec.prototype.isExecutable = function() { | |
return !this.disabled; | |
}; | |
-Spec.prototype.getFullName = function () { | |
+Spec.prototype.getFullName = function() { | |
return this.getSpecName(this); | |
}; | |
-const extractCustomPendingMessage = function (e) { | |
+const extractCustomPendingMessage = function(e) { | |
const fullMessage = e.toString(); | |
const boilerplateStart = fullMessage.indexOf( | |
- Spec.pendingSpecExceptionMessage); | |
+ Spec.pendingSpecExceptionMessage | |
+ ); | |
const boilerplateEnd = | |
- boilerplateStart + Spec.pendingSpecExceptionMessage.length; | |
+ boilerplateStart + Spec.pendingSpecExceptionMessage.length; | |
return fullMessage.substr(boilerplateEnd); | |
}; | |
Spec.pendingSpecExceptionMessage = '=> marked Pending'; | |
-Spec.isPendingSpecException = function (e) { | |
+Spec.isPendingSpecException = function(e) { | |
return !!(e && | |
- e.toString && | |
- e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); | |
+ e.toString && | |
+ e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); | |
}; | |
-module.exports = Spec; | |
\ No newline at end of file | |
+module.exports = Spec; | |
diff --git i/packages/jest-jasmine2/build/jasmine/SpyRegistry.js w/packages/jest-jasmine2/build/jasmine/SpyRegistry.js | |
index e159128b..1696af49 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/SpyRegistry.js | |
+++ w/packages/jest-jasmine2/build/jasmine/SpyRegistry.js | |
@@ -36,7 +36,7 @@ const CallTracker = require('./CallTracker'); | |
const createSpy = require('./createSpy'); | |
const SpyStrategy = require('./SpyStrategy'); | |
-const formatErrorMsg = function () { | |
+const formatErrorMsg = function() { | |
function generateErrorMsg(domain, usage) { | |
const usageDefinition = usage ? '\nUsage: ' + usage : ''; | |
@@ -54,8 +54,8 @@ function isSpy(putativeSpy) { | |
} | |
return ( | |
putativeSpy.and instanceof SpyStrategy && | |
- putativeSpy.calls instanceof CallTracker); | |
- | |
+ putativeSpy.calls instanceof CallTracker | |
+ ); | |
} | |
const getErrorMsg = formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)'); | |
@@ -63,22 +63,22 @@ const getErrorMsg = formatErrorMsg('<spyOn>', 'spyOn(<object>, <methodName>)'); | |
function SpyRegistry(options) { | |
options = options || {}; | |
const currentSpies = | |
- options.currentSpies || | |
- function () { | |
- return []; | |
- }; | |
+ options.currentSpies || | |
+ function() { | |
+ return []; | |
+ }; | |
- this.allowRespy = function (allow) { | |
+ this.allowRespy = function(allow) { | |
this.respy = allow; | |
}; | |
- this.spyOn = function (obj, methodName) { | |
+ this.spyOn = function(obj, methodName) { | |
if (obj === void 0) { | |
throw new Error( | |
- getErrorMsg( | |
- 'could not find an object to spy upon for ' + methodName + '()')); | |
- | |
- | |
+ getErrorMsg( | |
+ 'could not find an object to spy upon for ' + methodName + '()' | |
+ ) | |
+ ); | |
} | |
if (methodName === void 0) { | |
@@ -94,8 +94,8 @@ function SpyRegistry(options) { | |
return obj[methodName]; | |
} else { | |
throw new Error( | |
- getErrorMsg(methodName + ' has already been spied upon')); | |
- | |
+ getErrorMsg(methodName + ' has already been spied upon') | |
+ ); | |
} | |
} | |
@@ -108,8 +108,8 @@ function SpyRegistry(options) { | |
if (descriptor && !(descriptor.writable || descriptor.set)) { | |
throw new Error( | |
- getErrorMsg(methodName + ' is not declared writable or has no setter')); | |
- | |
+ getErrorMsg(methodName + ' is not declared writable or has no setter') | |
+ ); | |
} | |
const originalMethod = obj[methodName]; | |
@@ -117,11 +117,11 @@ function SpyRegistry(options) { | |
let restoreStrategy; | |
if (Object.prototype.hasOwnProperty.call(obj, methodName)) { | |
- restoreStrategy = function () { | |
+ restoreStrategy = function() { | |
obj[methodName] = originalMethod; | |
}; | |
} else { | |
- restoreStrategy = function () { | |
+ restoreStrategy = function() { | |
if (!delete obj[methodName]) { | |
obj[methodName] = originalMethod; | |
} | |
@@ -129,15 +129,15 @@ function SpyRegistry(options) { | |
} | |
currentSpies().push({ | |
- restoreObjectToOriginalState: restoreStrategy }); | |
- | |
+ restoreObjectToOriginalState: restoreStrategy, | |
+ }); | |
obj[methodName] = spiedMethod; | |
return spiedMethod; | |
}; | |
- this.clearSpies = function () { | |
+ this.clearSpies = function() { | |
const spies = currentSpies(); | |
for (let i = spies.length - 1; i >= 0; i--) { | |
const spyEntry = spies[i]; | |
@@ -146,4 +146,4 @@ function SpyRegistry(options) { | |
}; | |
} | |
-module.exports = SpyRegistry; | |
\ No newline at end of file | |
+module.exports = SpyRegistry; | |
diff --git i/packages/jest-jasmine2/build/jasmine/SpyStrategy.js w/packages/jest-jasmine2/build/jasmine/SpyStrategy.js | |
index d828f557..f0f81290 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/SpyStrategy.js | |
+++ w/packages/jest-jasmine2/build/jasmine/SpyStrategy.js | |
@@ -36,60 +36,60 @@ function SpyStrategy(options) { | |
options = options || {}; | |
const identity = options.name || 'unknown'; | |
- const originalFn = options.fn || function () {}; | |
- const getSpy = options.getSpy || function () {}; | |
- let plan = function () {}; | |
+ const originalFn = options.fn || function() {}; | |
+ const getSpy = options.getSpy || function() {}; | |
+ let plan = function() {}; | |
- this.identity = function () { | |
+ this.identity = function() { | |
return identity; | |
}; | |
- this.exec = function () { | |
+ this.exec = function() { | |
return plan.apply(this, arguments); | |
}; | |
- this.callThrough = function () { | |
+ this.callThrough = function() { | |
plan = originalFn; | |
return getSpy(); | |
}; | |
- this.returnValue = function (value) { | |
- plan = function () { | |
+ this.returnValue = function(value) { | |
+ plan = function() { | |
return value; | |
}; | |
return getSpy(); | |
}; | |
- this.returnValues = function () { | |
+ this.returnValues = function() { | |
const values = Array.prototype.slice.call(arguments); | |
- plan = function () { | |
+ plan = function() { | |
return values.shift(); | |
}; | |
return getSpy(); | |
}; | |
- this.throwError = function (something) { | |
+ this.throwError = function(something) { | |
const error = something instanceof Error ? something : new Error(something); | |
- plan = function () { | |
+ plan = function() { | |
throw error; | |
}; | |
return getSpy(); | |
}; | |
- this.callFake = function (fn) { | |
+ this.callFake = function(fn) { | |
if (typeof fn !== 'function') { | |
throw new Error( | |
- 'Argument passed to callFake should be a function, got ' + fn); | |
- | |
+ 'Argument passed to callFake should be a function, got ' + fn | |
+ ); | |
} | |
plan = fn; | |
return getSpy(); | |
}; | |
- this.stub = function (fn) { | |
- plan = function () {}; | |
+ this.stub = function(fn) { | |
+ plan = function() {}; | |
return getSpy(); | |
}; | |
} | |
-module.exports = SpyStrategy; | |
\ No newline at end of file | |
+module.exports = SpyStrategy; | |
diff --git i/packages/jest-jasmine2/build/jasmine/Suite.js w/packages/jest-jasmine2/build/jasmine/Suite.js | |
index 06c880ec..6e579b1b 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/Suite.js | |
+++ w/packages/jest-jasmine2/build/jasmine/Suite.js | |
@@ -53,17 +53,17 @@ function Suite(attrs) { | |
id: this.id, | |
description: this.description, | |
fullName: this.getFullName(), | |
- failedExpectations: [] }; | |
- | |
+ failedExpectations: [], | |
+ }; | |
} | |
-Suite.prototype.getFullName = function () { | |
+Suite.prototype.getFullName = function() { | |
const fullName = []; | |
for ( | |
- let parentSuite = this; | |
- parentSuite; | |
- parentSuite = parentSuite.parentSuite) | |
- { | |
+ let parentSuite = this; | |
+ parentSuite; | |
+ parentSuite = parentSuite.parentSuite | |
+ ) { | |
if (parentSuite.parentSuite) { | |
fullName.unshift(parentSuite.description); | |
} | |
@@ -71,35 +71,35 @@ Suite.prototype.getFullName = function () { | |
return fullName.join(' '); | |
}; | |
-Suite.prototype.disable = function () { | |
+Suite.prototype.disable = function() { | |
this.disabled = true; | |
}; | |
-Suite.prototype.pend = function (message) { | |
+Suite.prototype.pend = function(message) { | |
this.markedPending = true; | |
}; | |
-Suite.prototype.beforeEach = function (fn) { | |
+Suite.prototype.beforeEach = function(fn) { | |
this.beforeFns.unshift(fn); | |
}; | |
-Suite.prototype.beforeAll = function (fn) { | |
+Suite.prototype.beforeAll = function(fn) { | |
this.beforeAllFns.push(fn); | |
}; | |
-Suite.prototype.afterEach = function (fn) { | |
+Suite.prototype.afterEach = function(fn) { | |
this.afterFns.unshift(fn); | |
}; | |
-Suite.prototype.afterAll = function (fn) { | |
+Suite.prototype.afterAll = function(fn) { | |
this.afterAllFns.unshift(fn); | |
}; | |
-Suite.prototype.addChild = function (child) { | |
+Suite.prototype.addChild = function(child) { | |
this.children.push(child); | |
}; | |
-Suite.prototype.status = function () { | |
+Suite.prototype.status = function() { | |
if (this.disabled) { | |
return 'disabled'; | |
} | |
@@ -115,20 +115,20 @@ Suite.prototype.status = function () { | |
} | |
}; | |
-Suite.prototype.isExecutable = function () { | |
+Suite.prototype.isExecutable = function() { | |
return !this.disabled; | |
}; | |
-Suite.prototype.canBeReentered = function () { | |
+Suite.prototype.canBeReentered = function() { | |
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0; | |
}; | |
-Suite.prototype.getResult = function () { | |
+Suite.prototype.getResult = function() { | |
this.result.status = this.status(); | |
return this.result; | |
}; | |
-Suite.prototype.sharedUserContext = function () { | |
+Suite.prototype.sharedUserContext = function() { | |
if (!this.sharedContext) { | |
this.sharedContext = {}; | |
} | |
@@ -136,11 +136,11 @@ Suite.prototype.sharedUserContext = function () { | |
return this.sharedContext; | |
}; | |
-Suite.prototype.clonedSharedUserContext = function () { | |
+Suite.prototype.clonedSharedUserContext = function() { | |
return this.sharedUserContext(); | |
}; | |
-Suite.prototype.onException = function () { | |
+Suite.prototype.onException = function() { | |
if (arguments[0] instanceof ExpectationFailed) { | |
return; | |
} | |
@@ -151,7 +151,8 @@ Suite.prototype.onException = function () { | |
passed: false, | |
expected: '', | |
actual: '', | |
- error: arguments[0] }; | |
+ error: arguments[0], | |
+ }; | |
this.result.failedExpectations.push(expectationResultFactory(data)); | |
} else { | |
@@ -162,7 +163,7 @@ Suite.prototype.onException = function () { | |
} | |
}; | |
-Suite.prototype.addExpectationResult = function () { | |
+Suite.prototype.addExpectationResult = function() { | |
if (isAfterAll(this.children) && isFailure(arguments)) { | |
const data = arguments[1]; | |
this.result.failedExpectations.push(expectationResultFactory(data)); | |
@@ -189,4 +190,4 @@ function isFailure(args) { | |
return !args[0]; | |
} | |
-module.exports = Suite; | |
\ No newline at end of file | |
+module.exports = Suite; | |
diff --git i/packages/jest-jasmine2/build/jasmine/Timer.js w/packages/jest-jasmine2/build/jasmine/Timer.js | |
index adde6c3e..a7a2a6dd 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/Timer.js | |
+++ w/packages/jest-jasmine2/build/jasmine/Timer.js | |
@@ -32,11 +32,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
/* eslint-disable sort-keys */ | |
'use strict'; | |
-const defaultNow = function (Date) { | |
- return function () { | |
+const defaultNow = (function(Date) { | |
+ return function() { | |
return new Date().getTime(); | |
}; | |
-}(Date); | |
+})(Date); | |
function Timer(options) { | |
options = options || {}; | |
@@ -44,13 +44,13 @@ function Timer(options) { | |
const now = options.now || defaultNow; | |
let startTime; | |
- this.start = function () { | |
+ this.start = function() { | |
startTime = now(); | |
}; | |
- this.elapsed = function () { | |
+ this.elapsed = function() { | |
return now() - startTime; | |
}; | |
} | |
-module.exports = Timer; | |
\ No newline at end of file | |
+module.exports = Timer; | |
diff --git i/packages/jest-jasmine2/build/jasmine/createSpy.js w/packages/jest-jasmine2/build/jasmine/createSpy.js | |
index 1777dad9..7f846f69 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/createSpy.js | |
+++ w/packages/jest-jasmine2/build/jasmine/createSpy.js | |
@@ -41,14 +41,15 @@ function createSpy(name, originalFn) { | |
fn: originalFn, | |
getSpy() { | |
return spy; | |
- } }); | |
+ }, | |
+ }); | |
const callTracker = new CallTracker(); | |
- const spy = function () { | |
+ const spy = function() { | |
const callData = { | |
object: this, | |
- args: Array.prototype.slice.apply(arguments) }; | |
- | |
+ args: Array.prototype.slice.apply(arguments), | |
+ }; | |
callTracker.track(callData); | |
const returnValue = spyStrategy.exec.apply(this, arguments); | |
@@ -60,9 +61,9 @@ function createSpy(name, originalFn) { | |
for (const prop in originalFn) { | |
if (prop === 'and' || prop === 'calls') { | |
throw new Error( | |
- "Jasmine spies would overwrite the 'and' and 'calls' properties " + | |
- 'on the object being spied upon'); | |
- | |
+ "Jasmine spies would overwrite the 'and' and 'calls' properties " + | |
+ 'on the object being spied upon' | |
+ ); | |
} | |
spy[prop] = originalFn[prop]; | |
@@ -74,4 +75,4 @@ function createSpy(name, originalFn) { | |
return spy; | |
} | |
-module.exports = createSpy; | |
\ No newline at end of file | |
+module.exports = createSpy; | |
diff --git i/packages/jest-jasmine2/build/jasmine/jasmine-light.js w/packages/jest-jasmine2/build/jasmine/jasmine-light.js | |
index 0e5f2a38..99b41309 100644 | |
--- i/packages/jest-jasmine2/build/jasmine/jasmine-light.js | |
+++ w/packages/jest-jasmine2/build/jasmine/jasmine-light.js | |
@@ -41,13 +41,13 @@ const SpyRegistry = require('./SpyRegistry'); | |
const Suite = require('./Suite'); | |
const Timer = require('./Timer'); | |
-exports.create = function () { | |
+exports.create = function() { | |
const j$ = {}; | |
j$.DEFAULT_TIMEOUT_INTERVAL = 5000; | |
- j$.getEnv = function (options) { | |
- const env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options); | |
+ j$.getEnv = function(options) { | |
+ const env = (j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options)); | |
//jasmine. singletons in here (setTimeout blah blah). | |
return env; | |
}; | |
@@ -64,7 +64,7 @@ exports.create = function () { | |
return j$; | |
}; | |
-exports.interface = function (jasmine, env) { | |
+exports.interface = function(jasmine, env) { | |
const jasmineInterface = { | |
describe(description, specDefinitions) { | |
return env.describe(description, specDefinitions); | |
@@ -119,11 +119,11 @@ exports.interface = function (jasmine, env) { | |
}, | |
jsApiReporter: new jasmine.JsApiReporter({ | |
- timer: new jasmine.Timer() }), | |
- | |
- | |
- jasmine }; | |
+ timer: new jasmine.Timer(), | |
+ }), | |
+ jasmine, | |
+ }; | |
return jasmineInterface; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-jasmine2/build/jest-expect.js w/packages/jest-jasmine2/build/jest-expect.js | |
index 5edd569d..46a948c8 100644 | |
--- i/packages/jest-jasmine2/build/jest-expect.js | |
+++ w/packages/jest-jasmine2/build/jest-expect.js | |
@@ -9,29 +9,19 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
-const expect = require('jest-matchers');var _require = | |
- | |
- | |
- | |
- | |
- | |
-require('jest-snapshot');const addSerializer = _require.addSerializer,toMatchSnapshot = _require.toMatchSnapshot,toThrowErrorMatchingSnapshot = _require.toThrowErrorMatchingSnapshot; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+const expect = require('jest-matchers'); | |
+var _require = require('jest-snapshot'); | |
+const addSerializer = _require.addSerializer, | |
+ toMatchSnapshot = _require.toMatchSnapshot, | |
+ toThrowErrorMatchingSnapshot = _require.toThrowErrorMatchingSnapshot; | |
module.exports = config => { | |
global.expect = expect; | |
expect.setState({ | |
- expand: config.expand }); | |
+ expand: config.expand, | |
+ }); | |
- expect.extend({ toMatchSnapshot, toThrowErrorMatchingSnapshot }); | |
+ expect.extend({toMatchSnapshot, toThrowErrorMatchingSnapshot}); | |
expect.addSnapshotSerializer = addSerializer; | |
const jasmine = global.jasmine; | |
@@ -44,18 +34,18 @@ module.exports = config => { | |
jasmine.addMatchers = jasmineMatchersObject => { | |
const jestMatchersObject = Object.create(null); | |
Object.keys(jasmineMatchersObject).forEach(name => { | |
- jestMatchersObject[name] = function () { | |
+ jestMatchersObject[name] = function() { | |
const result = jasmineMatchersObject[name](jasmine.matchersUtil, null); | |
// if there is no 'negativeCompare', both should be handled by `compare` | |
const negativeCompare = result.negativeCompare || result.compare; | |
- return this.isNot ? | |
- negativeCompare.apply(null, arguments) : | |
- result.compare.apply(null, arguments); | |
+ return this.isNot | |
+ ? negativeCompare.apply(null, arguments) | |
+ : result.compare.apply(null, arguments); | |
}; | |
}); | |
const expect = global.expect; | |
expect.extend(jestMatchersObject); | |
}; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-jasmine2/build/p-timeout.js w/packages/jest-jasmine2/build/p-timeout.js | |
index 727fc326..1695c167 100644 | |
--- i/packages/jest-jasmine2/build/p-timeout.js | |
+++ w/packages/jest-jasmine2/build/p-timeout.js | |
@@ -11,26 +11,20 @@ | |
// A specialized version of `p-timeout` that does not touch globals. | |
// It does not throw on timeout. | |
-function pTimeout( | |
-promise, | |
-ms, | |
-clearTimeout, | |
-setTimeout, | |
-onTimeout) | |
-{ | |
+function pTimeout(promise, ms, clearTimeout, setTimeout, onTimeout) { | |
return new Promise((resolve, reject) => { | |
const timer = setTimeout(() => resolve(onTimeout()), ms); | |
promise.then( | |
- val => { | |
- clearTimeout(timer); | |
- resolve(val); | |
- }, | |
- err => { | |
- clearTimeout(timer); | |
- reject(err); | |
- }); | |
- | |
+ val => { | |
+ clearTimeout(timer); | |
+ resolve(val); | |
+ }, | |
+ err => { | |
+ clearTimeout(timer); | |
+ reject(err); | |
+ } | |
+ ); | |
}); | |
} | |
-module.exports = pTimeout; | |
\ No newline at end of file | |
+module.exports = pTimeout; | |
diff --git i/packages/jest-jasmine2/build/queueRunner.js w/packages/jest-jasmine2/build/queueRunner.js | |
index 3dcc456d..74e31eae 100644 | |
--- i/packages/jest-jasmine2/build/queueRunner.js | |
+++ w/packages/jest-jasmine2/build/queueRunner.js | |
@@ -13,25 +13,12 @@ const once = require('once'); | |
const pMap = require('p-map'); | |
const pTimeout = require('./p-timeout'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
function queueRunner(options) { | |
- const mapper = (_ref) => {let fn = _ref.fn,timeout = _ref.timeout; | |
+ const mapper = _ref => { | |
+ let fn = _ref.fn, timeout = _ref.timeout; | |
const promise = new Promise(resolve => { | |
const next = once(resolve); | |
- next.fail = function () { | |
+ next.fail = function() { | |
options.fail.apply(null, arguments); | |
resolve(); | |
}; | |
@@ -46,20 +33,21 @@ function queueRunner(options) { | |
return promise; | |
} | |
return pTimeout( | |
- promise, | |
- timeout(), | |
- options.clearTimeout, | |
- options.setTimeout, | |
- () => { | |
- const error = new Error( | |
- 'Timeout - Async callback was not invoked within timeout specified ' + | |
- 'by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); | |
- | |
- options.onException(error); | |
- }); | |
- | |
+ promise, | |
+ timeout(), | |
+ options.clearTimeout, | |
+ options.setTimeout, | |
+ () => { | |
+ const error = new Error( | |
+ 'Timeout - Async callback was not invoked within timeout specified ' + | |
+ 'by jasmine.DEFAULT_TIMEOUT_INTERVAL.' | |
+ ); | |
+ | |
+ options.onException(error); | |
+ } | |
+ ); | |
}; | |
- return pMap(options.queueableFns, mapper, { concurrency: 1 }); | |
+ return pMap(options.queueableFns, mapper, {concurrency: 1}); | |
} | |
-module.exports = queueRunner; | |
\ No newline at end of file | |
+module.exports = queueRunner; | |
diff --git i/packages/jest-jasmine2/build/reporter.js w/packages/jest-jasmine2/build/reporter.js | |
index 6f0de8cc..5561d270 100644 | |
--- i/packages/jest-jasmine2/build/reporter.js | |
+++ w/packages/jest-jasmine2/build/reporter.js | |
@@ -7,58 +7,19 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-message-util');const formatResultsErrors = _require.formatResultsErrors; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+var _require = require('jest-message-util'); | |
+const formatResultsErrors = _require.formatResultsErrors; | |
class Jasmine2Reporter { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- constructor( | |
- globalConfig, | |
- config, | |
- environment, | |
- testPath) | |
- { | |
+ constructor(globalConfig, config, environment, testPath) { | |
this._globalConfig = globalConfig; | |
this._config = config; | |
this._testPath = testPath; | |
this._testResults = []; | |
this._currentSuites = []; | |
this._resolve = null; | |
- this._resultsPromise = new Promise(resolve => this._resolve = resolve); | |
+ this._resultsPromise = new Promise(resolve => (this._resolve = resolve)); | |
this._startTimes = new Map(); | |
} | |
@@ -68,8 +29,8 @@ class Jasmine2Reporter { | |
specDone(result) { | |
this._testResults.push( | |
- this._extractSpecResults(result, this._currentSuites.slice(0))); | |
- | |
+ this._extractSpecResults(result, this._currentSuites.slice(0)) | |
+ ); | |
} | |
suiteStarted(suite) { | |
@@ -98,17 +59,19 @@ class Jasmine2Reporter { | |
const testResult = { | |
console: null, | |
failureMessage: formatResultsErrors( | |
- testResults, | |
- this._config, | |
- this._globalConfig, | |
- this._testPath), | |
+ testResults, | |
+ this._config, | |
+ this._globalConfig, | |
+ this._testPath | |
+ ), | |
numFailingTests, | |
numPassingTests, | |
numPendingTests, | |
perfStats: { | |
end: 0, | |
- start: 0 }, | |
+ start: 0, | |
+ }, | |
snapshot: { | |
added: 0, | |
@@ -116,11 +79,12 @@ class Jasmine2Reporter { | |
matched: 0, | |
unchecked: 0, | |
unmatched: 0, | |
- updated: 0 }, | |
+ updated: 0, | |
+ }, | |
testFilePath: this._testPath, | |
- testResults }; | |
- | |
+ testResults, | |
+ }; | |
this._resolve(testResult); | |
} | |
@@ -129,15 +93,12 @@ class Jasmine2Reporter { | |
return this._resultsPromise; | |
} | |
- _extractSpecResults( | |
- specResult, | |
- ancestorTitles) | |
- { | |
+ _extractSpecResults(specResult, ancestorTitles) { | |
const start = this._startTimes.get(specResult.id); | |
const duration = start ? Date.now() - start : undefined; | |
- const status = specResult.status === 'disabled' ? | |
- 'pending' : | |
- specResult.status; | |
+ const status = specResult.status === 'disabled' | |
+ ? 'pending' | |
+ : specResult.status; | |
const results = { | |
ancestorTitles, | |
duration, | |
@@ -145,18 +106,18 @@ class Jasmine2Reporter { | |
fullName: specResult.fullName, | |
numPassingAsserts: 0, // Jasmine2 only returns an array of failed asserts. | |
status, | |
- title: specResult.description }; | |
- | |
+ title: specResult.description, | |
+ }; | |
specResult.failedExpectations.forEach(failed => { | |
- const message = !failed.matcherName && failed.stack ? | |
- failed.stack : | |
- failed.message || ''; | |
+ const message = !failed.matcherName && failed.stack | |
+ ? failed.stack | |
+ : failed.message || ''; | |
results.failureMessages.push(message); | |
}); | |
return results; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = Jasmine2Reporter; | |
\ No newline at end of file | |
+module.exports = Jasmine2Reporter; | |
diff --git i/packages/jest-jasmine2/build/setup-jest-globals.js w/packages/jest-jasmine2/build/setup-jest-globals.js | |
index 547604d5..3c159fc0 100644 | |
--- i/packages/jest-jasmine2/build/setup-jest-globals.js | |
+++ w/packages/jest-jasmine2/build/setup-jest-globals.js | |
@@ -8,33 +8,25 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
-require('jest-matchers');const getState = _require.getState,setState = _require.setState;var _require2 = | |
-require('jest-snapshot');const SnapshotState = _require2.SnapshotState,addSerializer = _require2.addSerializer;var _require3 = | |
- | |
- | |
- | |
- | |
- | |
-require('jest-matcher-utils');const EXPECTED_COLOR = _require3.EXPECTED_COLOR,RECEIVED_COLOR = _require3.RECEIVED_COLOR,matcherHint = _require3.matcherHint,pluralize = _require3.pluralize; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+var _require = require('jest-matchers'); | |
+const getState = _require.getState, setState = _require.setState; | |
+var _require2 = require('jest-snapshot'); | |
+const SnapshotState = _require2.SnapshotState, | |
+ addSerializer = _require2.addSerializer; | |
+var _require3 = require('jest-matcher-utils'); | |
+const EXPECTED_COLOR = _require3.EXPECTED_COLOR, | |
+ RECEIVED_COLOR = _require3.RECEIVED_COLOR, | |
+ matcherHint = _require3.matcherHint, | |
+ pluralize = _require3.pluralize; | |
// Get suppressed errors form jest-matchers that weren't throw during | |
// test execution and add them to the test result, potentially failing | |
// a passing test. | |
-const addSuppressedErrors = result => {var _getState = | |
- getState();const suppressedErrors = _getState.suppressedErrors; | |
- setState({ suppressedErrors: [] }); | |
+const addSuppressedErrors = result => { | |
+ var _getState = getState(); | |
+ const suppressedErrors = _getState.suppressedErrors; | |
+ setState({suppressedErrors: []}); | |
if (suppressedErrors.length) { | |
result.status = 'failed'; | |
@@ -45,62 +37,63 @@ const addSuppressedErrors = result => {var _getState = | |
expected: '', | |
message: error.message, | |
passed: false, | |
- stack: error.stack })); | |
- | |
+ stack: error.stack, | |
+ })); | |
} | |
}; | |
-function addAssertionErrors(result) {var _getState2 = | |
- | |
- | |
- | |
- | |
- getState();const assertionCalls = _getState2.assertionCalls,expectedAssertionsNumber = _getState2.expectedAssertionsNumber,isExpectingAssertions = _getState2.isExpectingAssertions; | |
+function addAssertionErrors(result) { | |
+ var _getState2 = getState(); | |
+ const assertionCalls = _getState2.assertionCalls, | |
+ expectedAssertionsNumber = _getState2.expectedAssertionsNumber, | |
+ isExpectingAssertions = _getState2.isExpectingAssertions; | |
setState({ | |
assertionCalls: 0, | |
- expectedAssertionsNumber: null }); | |
+ expectedAssertionsNumber: null, | |
+ }); | |
if ( | |
- typeof expectedAssertionsNumber === 'number' && | |
- assertionCalls !== expectedAssertionsNumber) | |
- { | |
+ typeof expectedAssertionsNumber === 'number' && | |
+ assertionCalls !== expectedAssertionsNumber | |
+ ) { | |
const expected = EXPECTED_COLOR( | |
- pluralize('assertion', expectedAssertionsNumber)); | |
+ pluralize('assertion', expectedAssertionsNumber) | |
+ ); | |
const message = new Error( | |
- matcherHint('.assertions', '', String(expectedAssertionsNumber), { | |
- isDirectExpectCall: true }) + | |
- | |
- '\n\n' + | |
- `Expected ${expected} to be called but only received ` + | |
- RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) + | |
- '.'). | |
- stack; | |
+ matcherHint('.assertions', '', String(expectedAssertionsNumber), { | |
+ isDirectExpectCall: true, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected ${expected} to be called but only received ` + | |
+ RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) + | |
+ '.' | |
+ ).stack; | |
result.status = 'failed'; | |
result.failedExpectations.push({ | |
actual: assertionCalls, | |
expected: expectedAssertionsNumber, | |
message, | |
- passed: false }); | |
- | |
+ passed: false, | |
+ }); | |
} | |
if (isExpectingAssertions && assertionCalls === 0) { | |
const expected = EXPECTED_COLOR('at least one assertion'); | |
const received = RECEIVED_COLOR('received none'); | |
const message = new Error( | |
- matcherHint('.hasAssertions', '', '', { | |
- isDirectExpectCall: true }) + | |
- | |
- '\n\n' + | |
- `Expected ${expected} to be called but ${received}.`). | |
- stack; | |
+ matcherHint('.hasAssertions', '', '', { | |
+ isDirectExpectCall: true, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected ${expected} to be called but ${received}.` | |
+ ).stack; | |
result.status = 'failed'; | |
result.failedExpectations.push({ | |
actual: 'none', | |
expected: 'at least one', | |
message, | |
- passed: false }); | |
- | |
+ passed: false, | |
+ }); | |
} | |
} | |
@@ -108,14 +101,14 @@ const patchJasmine = () => { | |
global.jasmine.Spec = (realSpec => { | |
const Spec = function Spec(attr) { | |
const resultCallback = attr.resultCallback; | |
- attr.resultCallback = function (result) { | |
+ attr.resultCallback = function(result) { | |
addSuppressedErrors(result); | |
addAssertionErrors(result); | |
resultCallback.call(attr, result); | |
}; | |
const onStart = attr.onStart; | |
attr.onStart = context => { | |
- setState({ currentTestName: context.getFullName() }); | |
+ setState({currentTestName: context.getFullName()}); | |
onStart && onStart.call(attr, context); | |
}; | |
realSpec.call(this, attr); | |
@@ -131,21 +124,21 @@ const patchJasmine = () => { | |
})(global.jasmine.Spec); | |
}; | |
-module.exports = (_ref) => | |
- | |
- | |
- | |
- | |
-{let config = _ref.config,globalConfig = _ref.globalConfig,localRequire = _ref.localRequire,testPath = _ref.testPath; | |
+module.exports = _ref => { | |
+ let config = _ref.config, | |
+ globalConfig = _ref.globalConfig, | |
+ localRequire = _ref.localRequire, | |
+ testPath = _ref.testPath; | |
// Jest tests snapshotSerializers in order preceding built-in serializers. | |
// Therefore, add in reverse because the last added is the first tested. | |
config.snapshotSerializers.concat().reverse().forEach(path => { | |
addSerializer(localRequire(path)); | |
}); | |
- patchJasmine();const | |
- expand = globalConfig.expand,updateSnapshot = globalConfig.updateSnapshot; | |
- const snapshotState = new SnapshotState(testPath, { expand, updateSnapshot }); | |
- setState({ snapshotState, testPath }); | |
+ patchJasmine(); | |
+ const expand = globalConfig.expand, | |
+ updateSnapshot = globalConfig.updateSnapshot; | |
+ const snapshotState = new SnapshotState(testPath, {expand, updateSnapshot}); | |
+ setState({snapshotState, testPath}); | |
// Return it back to the outer scope (test runner outside the VM). | |
return snapshotState; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-jasmine2/build/treeProcessor.js w/packages/jest-jasmine2/build/treeProcessor.js | |
index a92a004a..9128cdd5 100644 | |
--- i/packages/jest-jasmine2/build/treeProcessor.js | |
+++ w/packages/jest-jasmine2/build/treeProcessor.js | |
@@ -7,34 +7,43 @@ | |
* | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-function treeProcessor(options) {const | |
- | |
- nodeComplete = | |
- | |
- | |
- | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
- options.nodeComplete,nodeStart = options.nodeStart,queueRunnerFactory = options.queueRunnerFactory,runnableIds = options.runnableIds,tree = options.tree; | |
+function treeProcessor(options) { | |
+ const nodeComplete = options.nodeComplete, | |
+ nodeStart = options.nodeStart, | |
+ queueRunnerFactory = options.queueRunnerFactory, | |
+ runnableIds = options.runnableIds, | |
+ tree = options.tree; | |
function isEnabled(node, parentEnabled) { | |
return parentEnabled || runnableIds.indexOf(node.id) !== -1; | |
@@ -43,8 +52,8 @@ function treeProcessor(options) {const | |
return queueRunnerFactory({ | |
onException: error => tree.onException(error), | |
queueableFns: wrapChildren(tree, isEnabled(tree, false)), | |
- userContext: tree.sharedUserContext() }); | |
- | |
+ userContext: tree.sharedUserContext(), | |
+ }); | |
function executeNode(node, parentEnabled) { | |
const enabled = isEnabled(node, parentEnabled); | |
@@ -52,21 +61,26 @@ function treeProcessor(options) {const | |
return { | |
fn(done) { | |
node.execute(done, enabled); | |
- } }; | |
- | |
+ }, | |
+ }; | |
} | |
return { | |
- fn(done) {return _asyncToGenerator(function* () { | |
+ fn(done) { | |
+ return _asyncToGenerator(function*() { | |
nodeStart(node); | |
yield queueRunnerFactory({ | |
- onException: function (error) {return node.onException(error);}, | |
+ onException: function(error) { | |
+ return node.onException(error); | |
+ }, | |
queueableFns: wrapChildren(node, enabled), | |
- userContext: node.sharedUserContext() }); | |
+ userContext: node.sharedUserContext(), | |
+ }); | |
nodeComplete(node); | |
- done();})(); | |
- } }; | |
- | |
+ done(); | |
+ })(); | |
+ }, | |
+ }; | |
} | |
function wrapChildren(node, enabled) { | |
@@ -78,4 +92,4 @@ function treeProcessor(options) {const | |
} | |
} | |
-module.exports = treeProcessor; | |
\ No newline at end of file | |
+module.exports = treeProcessor; | |
diff --git i/packages/jest-matcher-utils/build/index.js w/packages/jest-matcher-utils/build/index.js | |
index 26c01892..540b2939 100644 | |
--- i/packages/jest-matcher-utils/build/index.js | |
+++ w/packages/jest-matcher-utils/build/index.js | |
@@ -11,31 +11,16 @@ | |
'use strict'; | |
const chalk = require('chalk'); | |
-const prettyFormat = require('pretty-format');var _require$plugins = | |
- | |
- | |
- | |
- | |
- | |
-require('pretty-format').plugins;const AsymmetricMatcher = _require$plugins.AsymmetricMatcher,ReactElement = _require$plugins.ReactElement,HTMLElement = _require$plugins.HTMLElement,Immutable = _require$plugins.Immutable; | |
+const prettyFormat = require('pretty-format'); | |
+var _require$plugins = require('pretty-format').plugins; | |
+const AsymmetricMatcher = _require$plugins.AsymmetricMatcher, | |
+ ReactElement = _require$plugins.ReactElement, | |
+ HTMLElement = _require$plugins.HTMLElement, | |
+ Immutable = _require$plugins.Immutable; | |
const PLUGINS = [AsymmetricMatcher, ReactElement, HTMLElement].concat( | |
-Immutable); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+ Immutable | |
+); | |
const EXPECTED_COLOR = chalk.green; | |
const EXPECTED_BG = chalk.bgGreen; | |
@@ -43,21 +28,21 @@ const RECEIVED_COLOR = chalk.red; | |
const RECEIVED_BG = chalk.bgRed; | |
const NUMBERS = [ | |
-'zero', | |
-'one', | |
-'two', | |
-'three', | |
-'four', | |
-'five', | |
-'six', | |
-'seven', | |
-'eight', | |
-'nine', | |
-'ten', | |
-'eleven', | |
-'twelve', | |
-'thirteen']; | |
- | |
+ 'zero', | |
+ 'one', | |
+ 'two', | |
+ 'three', | |
+ 'four', | |
+ 'five', | |
+ 'six', | |
+ 'seven', | |
+ 'eight', | |
+ 'nine', | |
+ 'ten', | |
+ 'eleven', | |
+ 'twelve', | |
+ 'thirteen', | |
+]; | |
// get the type of a value with handling the edge cases like `typeof []` | |
// and `typeof null` | |
@@ -93,7 +78,10 @@ const getType = value => { | |
throw new Error(`value of unknown type: ${value}`); | |
}; | |
-const stringify = function (object) {let maxDepth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10; | |
+const stringify = function(object) { | |
+ let maxDepth = arguments.length > 1 && arguments[1] !== undefined | |
+ ? arguments[1] | |
+ : 10; | |
const MAX_LENGTH = 10000; | |
let result; | |
@@ -101,53 +89,49 @@ const stringify = function (object) {let maxDepth = arguments.length > 1 && argu | |
result = prettyFormat(object, { | |
maxDepth, | |
min: true, | |
- plugins: PLUGINS }); | |
- | |
+ plugins: PLUGINS, | |
+ }); | |
} catch (e) { | |
result = prettyFormat(object, { | |
callToJSON: false, | |
maxDepth, | |
min: true, | |
- plugins: PLUGINS }); | |
- | |
+ plugins: PLUGINS, | |
+ }); | |
} | |
- return result.length >= MAX_LENGTH && maxDepth > 1 ? | |
- stringify(object, Math.floor(maxDepth / 2)) : | |
- result; | |
+ return result.length >= MAX_LENGTH && maxDepth > 1 | |
+ ? stringify(object, Math.floor(maxDepth / 2)) | |
+ : result; | |
}; | |
const highlightTrailingWhitespace = (text, bgColor) => | |
-text.replace(/\s+$/gm, bgColor('$&')); | |
+ text.replace(/\s+$/gm, bgColor('$&')); | |
const printReceived = object => | |
-highlightTrailingWhitespace(RECEIVED_COLOR(stringify(object)), RECEIVED_BG); | |
+ highlightTrailingWhitespace(RECEIVED_COLOR(stringify(object)), RECEIVED_BG); | |
const printExpected = value => | |
-highlightTrailingWhitespace(EXPECTED_COLOR(stringify(value)), EXPECTED_BG); | |
+ highlightTrailingWhitespace(EXPECTED_COLOR(stringify(value)), EXPECTED_BG); | |
-const printWithType = ( | |
-name, | |
-received, | |
-print) => | |
-{ | |
+const printWithType = (name, received, print) => { | |
const type = getType(received); | |
return ( | |
name + | |
- ':' + ( | |
- type !== 'null' && type !== 'undefined' ? '\n ' + type + ': ' : ' ') + | |
- print(received)); | |
- | |
+ ':' + | |
+ (type !== 'null' && type !== 'undefined' ? '\n ' + type + ': ' : ' ') + | |
+ print(received) | |
+ ); | |
}; | |
const ensureNoExpected = (expected, matcherName) => { | |
matcherName || (matcherName = 'This'); | |
if (typeof expected !== 'undefined') { | |
throw new Error( | |
- matcherHint('[.not]' + matcherName, undefined, '') + | |
- '\n\n' + | |
- 'Matcher does not accept any arguments.\n' + | |
- printWithType('Got', expected, printExpected)); | |
- | |
+ matcherHint('[.not]' + matcherName, undefined, '') + | |
+ '\n\n' + | |
+ 'Matcher does not accept any arguments.\n' + | |
+ printWithType('Got', expected, printExpected) | |
+ ); | |
} | |
}; | |
@@ -155,11 +139,11 @@ const ensureActualIsNumber = (actual, matcherName) => { | |
matcherName || (matcherName = 'This matcher'); | |
if (typeof actual !== 'number') { | |
throw new Error( | |
- matcherHint('[.not]' + matcherName) + | |
- '\n\n' + | |
- `Received value must be a number.\n` + | |
- printWithType('Received', actual, printReceived)); | |
- | |
+ matcherHint('[.not]' + matcherName) + | |
+ '\n\n' + | |
+ `Received value must be a number.\n` + | |
+ printWithType('Received', actual, printReceived) | |
+ ); | |
} | |
}; | |
@@ -167,11 +151,11 @@ const ensureExpectedIsNumber = (expected, matcherName) => { | |
matcherName || (matcherName = 'This matcher'); | |
if (typeof expected !== 'number') { | |
throw new Error( | |
- matcherHint('[.not]' + matcherName) + | |
- '\n\n' + | |
- `Expected value must be a number.\n` + | |
- printWithType('Got', expected, printExpected)); | |
- | |
+ matcherHint('[.not]' + matcherName) + | |
+ '\n\n' + | |
+ `Expected value must be a number.\n` + | |
+ printWithType('Got', expected, printExpected) | |
+ ); | |
} | |
}; | |
@@ -181,27 +165,26 @@ const ensureNumbers = (actual, expected, matcherName) => { | |
}; | |
const pluralize = (word, count) => | |
-(NUMBERS[count] || count) + ' ' + word + (count === 1 ? '' : 's'); | |
- | |
-const matcherHint = function ( | |
-matcherName) | |
- | |
- | |
- | |
- | |
- | |
- | |
-{let received = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'received';let expected = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'expected';let options = arguments[3]; | |
+ (NUMBERS[count] || count) + ' ' + word + (count === 1 ? '' : 's'); | |
+ | |
+const matcherHint = function(matcherName) { | |
+ let received = arguments.length > 1 && arguments[1] !== undefined | |
+ ? arguments[1] | |
+ : 'received'; | |
+ let expected = arguments.length > 2 && arguments[2] !== undefined | |
+ ? arguments[2] | |
+ : 'expected'; | |
+ let options = arguments[3]; | |
const secondArgument = options && options.secondArgument; | |
const isDirectExpectCall = options && options.isDirectExpectCall; | |
return ( | |
chalk.dim('expect' + (isDirectExpectCall ? '' : '(')) + | |
RECEIVED_COLOR(received) + | |
chalk.dim((isDirectExpectCall ? '' : ')') + matcherName + '(') + | |
- EXPECTED_COLOR(expected) + ( | |
- secondArgument ? `, ${EXPECTED_COLOR(secondArgument)}` : '') + | |
- chalk.dim(')')); | |
- | |
+ EXPECTED_COLOR(expected) + | |
+ (secondArgument ? `, ${EXPECTED_COLOR(secondArgument)}` : '') + | |
+ chalk.dim(')') | |
+ ); | |
}; | |
module.exports = { | |
@@ -220,4 +203,5 @@ module.exports = { | |
printExpected, | |
printReceived, | |
printWithType, | |
- stringify }; | |
\ No newline at end of file | |
+ stringify, | |
+}; | |
diff --git i/packages/jest-matchers/build/asymmetric-matchers.js w/packages/jest-matchers/build/asymmetric-matchers.js | |
index 892980ee..94fd21b5 100644 | |
--- i/packages/jest-matchers/build/asymmetric-matchers.js | |
+++ w/packages/jest-matchers/build/asymmetric-matchers.js | |
@@ -8,34 +8,28 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./jasmine-utils');const equals = _require.equals,fnNameFor = _require.fnNameFor,hasProperty = _require.hasProperty,isA = _require.isA,isUndefined = _require.isUndefined; | |
+'use strict'; | |
+var _require = require('./jasmine-utils'); | |
+const equals = _require.equals, | |
+ fnNameFor = _require.fnNameFor, | |
+ hasProperty = _require.hasProperty, | |
+ isA = _require.isA, | |
+ isUndefined = _require.isUndefined; | |
class AsymmetricMatcher { | |
- | |
- | |
constructor() { | |
this.$$typeof = Symbol.for('jest.asymmetricMatcher'); | |
- }} | |
- | |
+ } | |
+} | |
class Any extends AsymmetricMatcher { | |
- | |
- | |
constructor(sample) { | |
super(); | |
if (typeof sample === 'undefined') { | |
throw new TypeError( | |
- 'any() expects to be passed a constructor function. ' + | |
- 'Please pass one or use anything() to match any object.'); | |
- | |
+ 'any() expects to be passed a constructor function. ' + | |
+ 'Please pass one or use anything() to match any object.' | |
+ ); | |
} | |
this.sample = sample; | |
} | |
@@ -94,8 +88,8 @@ class Any extends AsymmetricMatcher { | |
toAsymmetricMatcher() { | |
return 'Any<' + fnNameFor(this.sample) + '>'; | |
- }} | |
- | |
+ } | |
+} | |
class Anything extends AsymmetricMatcher { | |
asymmetricMatch(other) { | |
@@ -110,12 +104,10 @@ class Anything extends AsymmetricMatcher { | |
toAsymmetricMatcher() { | |
return 'Anything'; | |
- }} | |
- | |
+ } | |
+} | |
class ArrayContaining extends AsymmetricMatcher { | |
- | |
- | |
constructor(sample) { | |
super(); | |
this.sample = sample; | |
@@ -124,17 +116,17 @@ class ArrayContaining extends AsymmetricMatcher { | |
asymmetricMatch(other) { | |
if (!Array.isArray(this.sample)) { | |
throw new Error( | |
- "You must provide an array to ArrayContaining, not '" + | |
- typeof this.sample + | |
- "'."); | |
- | |
+ "You must provide an array to ArrayContaining, not '" + | |
+ typeof this.sample + | |
+ "'." | |
+ ); | |
} | |
return ( | |
this.sample.length === 0 || | |
- Array.isArray(other) && | |
- this.sample.every(item => other.some(another => equals(item, another)))); | |
- | |
+ (Array.isArray(other) && | |
+ this.sample.every(item => other.some(another => equals(item, another)))) | |
+ ); | |
} | |
toString() { | |
@@ -143,12 +135,10 @@ class ArrayContaining extends AsymmetricMatcher { | |
getExpectedType() { | |
return 'array'; | |
- }} | |
- | |
+ } | |
+} | |
class ObjectContaining extends AsymmetricMatcher { | |
- | |
- | |
constructor(sample) { | |
super(); | |
this.sample = sample; | |
@@ -157,17 +147,17 @@ class ObjectContaining extends AsymmetricMatcher { | |
asymmetricMatch(other) { | |
if (typeof this.sample !== 'object') { | |
throw new Error( | |
- "You must provide an object to ObjectContaining, not '" + | |
- typeof this.sample + | |
- "'."); | |
- | |
+ "You must provide an object to ObjectContaining, not '" + | |
+ typeof this.sample + | |
+ "'." | |
+ ); | |
} | |
for (const property in this.sample) { | |
if ( | |
- !hasProperty(other, property) || | |
- !equals(this.sample[property], other[property])) | |
- { | |
+ !hasProperty(other, property) || | |
+ !equals(this.sample[property], other[property]) | |
+ ) { | |
return false; | |
} | |
} | |
@@ -181,12 +171,10 @@ class ObjectContaining extends AsymmetricMatcher { | |
getExpectedType() { | |
return 'object'; | |
- }} | |
- | |
+ } | |
+} | |
class StringContaining extends AsymmetricMatcher { | |
- | |
- | |
constructor(sample) { | |
super(); | |
if (!isA('String', sample)) { | |
@@ -205,12 +193,10 @@ class StringContaining extends AsymmetricMatcher { | |
getExpectedType() { | |
return 'string'; | |
- }} | |
- | |
+ } | |
+} | |
class StringMatching extends AsymmetricMatcher { | |
- | |
- | |
constructor(sample) { | |
super(); | |
if (!isA('String', sample) && !isA('RegExp', sample)) { | |
@@ -230,8 +216,8 @@ class StringMatching extends AsymmetricMatcher { | |
getExpectedType() { | |
return 'string'; | |
- }} | |
- | |
+ } | |
+} | |
module.exports = { | |
any: expectedObject => new Any(expectedObject), | |
@@ -239,4 +225,5 @@ module.exports = { | |
arrayContaining: sample => new ArrayContaining(sample), | |
objectContaining: sample => new ObjectContaining(sample), | |
stringContaining: expected => new StringContaining(expected), | |
- stringMatching: expected => new StringMatching(expected) }; | |
\ No newline at end of file | |
+ stringMatching: expected => new StringMatching(expected), | |
+}; | |
diff --git i/packages/jest-matchers/build/index.js w/packages/jest-matchers/build/index.js | |
index d8a23c2d..2f726d2d 100644 | |
--- i/packages/jest-matchers/build/index.js | |
+++ w/packages/jest-matchers/build/index.js | |
@@ -8,45 +8,61 @@ | |
* | |
*/ | |
-'use strict';function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+function _asyncToGenerator(fn) { | |
+ return function() { | |
+ var gen = fn.apply(this, arguments); | |
+ return new Promise(function(resolve, reject) { | |
+ function step(key, arg) { | |
+ try { | |
+ var info = gen[key](arg); | |
+ var value = info.value; | |
+ } catch (error) { | |
+ reject(error); | |
+ return; | |
+ } | |
+ if (info.done) { | |
+ resolve(value); | |
+ } else { | |
+ return Promise.resolve(value).then( | |
+ function(value) { | |
+ step('next', value); | |
+ }, | |
+ function(err) { | |
+ step('throw', err); | |
+ } | |
+ ); | |
+ } | |
+ } | |
+ return step('next'); | |
+ }); | |
+ }; | |
+} | |
const matchers = require('./matchers'); | |
const spyMatchers = require('./spyMatchers'); | |
-const toThrowMatchers = require('./toThrowMatchers');var _require = | |
-require('./jasmine-utils');const equals = _require.equals; | |
-const utils = require('jest-matcher-utils');var _require2 = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./asymmetric-matchers');const any = _require2.any,anything = _require2.anything,arrayContaining = _require2.arrayContaining,objectContaining = _require2.objectContaining,stringContaining = _require2.stringContaining,stringMatching = _require2.stringMatching; | |
+const toThrowMatchers = require('./toThrowMatchers'); | |
+var _require = require('./jasmine-utils'); | |
+const equals = _require.equals; | |
+const utils = require('jest-matcher-utils'); | |
+var _require2 = require('./asymmetric-matchers'); | |
+const any = _require2.any, | |
+ anything = _require2.anything, | |
+ arrayContaining = _require2.arrayContaining, | |
+ objectContaining = _require2.objectContaining, | |
+ stringContaining = _require2.stringContaining, | |
+ stringMatching = _require2.stringMatching; | |
const GLOBAL_STATE = Symbol.for('$$jest-matchers-object'); | |
class JestAssertionError extends Error {} | |
- | |
- | |
const isPromise = obj => { | |
return ( | |
- !!obj && ( | |
- typeof obj === 'object' || typeof obj === 'function') && | |
- typeof obj.then === 'function'); | |
- | |
+ !!obj && | |
+ (typeof obj === 'object' || typeof obj === 'function') && | |
+ typeof obj.then === 'function' | |
+ ); | |
}; | |
if (!global[GLOBAL_STATE]) { | |
@@ -57,53 +73,55 @@ if (!global[GLOBAL_STATE]) { | |
assertionCalls: 0, | |
expectedAssertionsNumber: null, | |
isExpectingAssertions: false, | |
- suppressedErrors: [] } } }); | |
- | |
- | |
- | |
+ suppressedErrors: [], | |
+ }, | |
+ }, | |
+ }); | |
} | |
const expect = actual => { | |
const allMatchers = global[GLOBAL_STATE].matchers; | |
const expectation = { | |
not: {}, | |
- rejects: { not: {} }, | |
- resolves: { not: {} } }; | |
- | |
+ rejects: {not: {}}, | |
+ resolves: {not: {}}, | |
+ }; | |
Object.keys(allMatchers).forEach(name => { | |
expectation[name] = makeThrowingMatcher(allMatchers[name], false, actual); | |
expectation.not[name] = makeThrowingMatcher( | |
- allMatchers[name], | |
- true, | |
- actual); | |
- | |
+ allMatchers[name], | |
+ true, | |
+ actual | |
+ ); | |
expectation.resolves[name] = makeResolveMatcher( | |
- name, | |
- allMatchers[name], | |
- false, | |
- actual); | |
+ name, | |
+ allMatchers[name], | |
+ false, | |
+ actual | |
+ ); | |
expectation.resolves.not[name] = makeResolveMatcher( | |
- name, | |
- allMatchers[name], | |
- true, | |
- actual); | |
- | |
+ name, | |
+ allMatchers[name], | |
+ true, | |
+ actual | |
+ ); | |
expectation.rejects[name] = makeRejectMatcher( | |
- name, | |
- allMatchers[name], | |
- false, | |
- actual); | |
+ name, | |
+ allMatchers[name], | |
+ false, | |
+ actual | |
+ ); | |
expectation.rejects.not[name] = makeRejectMatcher( | |
- name, | |
- allMatchers[name], | |
- true, | |
- actual); | |
- | |
+ name, | |
+ allMatchers[name], | |
+ true, | |
+ actual | |
+ ); | |
}); | |
return expectation; | |
@@ -118,99 +136,109 @@ const getMessage = message => { | |
if (!message) { | |
message = utils.RECEIVED_COLOR( | |
- 'No message was specified for this matcher.'); | |
- | |
+ 'No message was specified for this matcher.' | |
+ ); | |
} | |
return message; | |
}; | |
-const makeResolveMatcher = ( | |
-matcherName, | |
-matcher, | |
-isNot, | |
-actual) => _asyncToGenerator( | |
-function* () {for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];} | |
- const matcherStatement = `.resolves.${isNot ? 'not.' : ''}${matcherName}`; | |
- if (!isPromise(actual)) { | |
- throw new JestAssertionError( | |
- utils.matcherHint(matcherStatement, 'received', '') + | |
- '\n\n' + | |
- `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + | |
- utils.printWithType('Received', actual, utils.printReceived)); | |
- | |
- } | |
- | |
- let result; | |
- try { | |
- result = yield actual; | |
- } catch (e) { | |
- throw new JestAssertionError( | |
- utils.matcherHint(matcherStatement, 'received', '') + | |
- '\n\n' + | |
- `Expected ${utils.RECEIVED_COLOR('received')} Promise to resolve, ` + | |
- 'instead it rejected to value\n' + | |
- ` ${utils.printReceived(e)}`); | |
- | |
- } | |
- return makeThrowingMatcher(matcher, isNot, result).apply(null, args); | |
-}); | |
- | |
-const makeRejectMatcher = ( | |
-matcherName, | |
-matcher, | |
-isNot, | |
-actual) => _asyncToGenerator( | |
-function* () {for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {args[_key2] = arguments[_key2];} | |
- const matcherStatement = `.rejects.${isNot ? 'not.' : ''}${matcherName}`; | |
- if (!isPromise(actual)) { | |
- throw new JestAssertionError( | |
- utils.matcherHint(matcherStatement, 'received', '') + | |
- '\n\n' + | |
- `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + | |
- utils.printWithType('Received', actual, utils.printReceived)); | |
+const makeResolveMatcher = (matcherName, matcher, isNot, actual) => | |
+ _asyncToGenerator(function*() { | |
+ for ( | |
+ var _len = arguments.length, args = Array(_len), _key = 0; | |
+ _key < _len; | |
+ _key++ | |
+ ) { | |
+ args[_key] = arguments[_key]; | |
+ } | |
+ const matcherStatement = `.resolves.${isNot ? 'not.' : ''}${matcherName}`; | |
+ if (!isPromise(actual)) { | |
+ throw new JestAssertionError( | |
+ utils.matcherHint(matcherStatement, 'received', '') + | |
+ '\n\n' + | |
+ `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + | |
+ utils.printWithType('Received', actual, utils.printReceived) | |
+ ); | |
+ } | |
- } | |
+ let result; | |
+ try { | |
+ result = yield actual; | |
+ } catch (e) { | |
+ throw new JestAssertionError( | |
+ utils.matcherHint(matcherStatement, 'received', '') + | |
+ '\n\n' + | |
+ `Expected ${utils.RECEIVED_COLOR('received')} Promise to resolve, ` + | |
+ 'instead it rejected to value\n' + | |
+ ` ${utils.printReceived(e)}` | |
+ ); | |
+ } | |
+ return makeThrowingMatcher(matcher, isNot, result).apply(null, args); | |
+ }); | |
- let result; | |
- try { | |
- result = yield actual; | |
- } catch (e) { | |
- return makeThrowingMatcher(matcher, isNot, e).apply(null, args); | |
- } | |
+const makeRejectMatcher = (matcherName, matcher, isNot, actual) => | |
+ _asyncToGenerator(function*() { | |
+ for ( | |
+ var _len2 = arguments.length, args = Array(_len2), _key2 = 0; | |
+ _key2 < _len2; | |
+ _key2++ | |
+ ) { | |
+ args[_key2] = arguments[_key2]; | |
+ } | |
+ const matcherStatement = `.rejects.${isNot ? 'not.' : ''}${matcherName}`; | |
+ if (!isPromise(actual)) { | |
+ throw new JestAssertionError( | |
+ utils.matcherHint(matcherStatement, 'received', '') + | |
+ '\n\n' + | |
+ `${utils.RECEIVED_COLOR('received')} value must be a Promise.\n` + | |
+ utils.printWithType('Received', actual, utils.printReceived) | |
+ ); | |
+ } | |
- throw new JestAssertionError( | |
- utils.matcherHint(matcherStatement, 'received', '') + | |
- '\n\n' + | |
- `Expected ${utils.RECEIVED_COLOR('received')} Promise to reject, ` + | |
- 'instead it resolved to value\n' + | |
- ` ${utils.printReceived(result)}`); | |
+ let result; | |
+ try { | |
+ result = yield actual; | |
+ } catch (e) { | |
+ return makeThrowingMatcher(matcher, isNot, e).apply(null, args); | |
+ } | |
-}); | |
+ throw new JestAssertionError( | |
+ utils.matcherHint(matcherStatement, 'received', '') + | |
+ '\n\n' + | |
+ `Expected ${utils.RECEIVED_COLOR('received')} Promise to reject, ` + | |
+ 'instead it resolved to value\n' + | |
+ ` ${utils.printReceived(result)}` | |
+ ); | |
+ }); | |
-const makeThrowingMatcher = ( | |
-matcher, | |
-isNot, | |
-actual) => | |
-{ | |
+const makeThrowingMatcher = (matcher, isNot, actual) => { | |
return function throwingMatcher() { | |
let throws = true; | |
const matcherContext = Object.assign( | |
- // When throws is disabled, the matcher will not throw errors during test | |
- // execution but instead add them to the global matcher state. If a | |
- // matcher throws, test execution is normally stopped immediately. The | |
- // snapshot matcher uses it because we want to log all snapshot | |
- // failures in a test. | |
- { dontThrow: () => throws = false }, | |
- global[GLOBAL_STATE].state, | |
- { | |
- equals, | |
- isNot, | |
- utils }); | |
- | |
+ // When throws is disabled, the matcher will not throw errors during test | |
+ // execution but instead add them to the global matcher state. If a | |
+ // matcher throws, test execution is normally stopped immediately. The | |
+ // snapshot matcher uses it because we want to log all snapshot | |
+ // failures in a test. | |
+ {dontThrow: () => (throws = false)}, | |
+ global[GLOBAL_STATE].state, | |
+ { | |
+ equals, | |
+ isNot, | |
+ utils, | |
+ } | |
+ ); | |
let result; | |
- try {for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {args[_key3] = arguments[_key3];} | |
+ try { | |
+ for ( | |
+ var _len3 = arguments.length, args = Array(_len3), _key3 = 0; | |
+ _key3 < _len3; | |
+ _key3++ | |
+ ) { | |
+ args[_key3] = arguments[_key3]; | |
+ } | |
result = matcher.apply(matcherContext, [actual].concat(args)); | |
} catch (error) { | |
// Remove this and deeper functions from the stack trace frame. | |
@@ -222,7 +250,7 @@ actual) => | |
global[GLOBAL_STATE].state.assertionCalls++; | |
- if (result.pass && isNot || !result.pass && !isNot) { | |
+ if ((result.pass && isNot) || (!result.pass && !isNot)) { | |
// XOR | |
const message = getMessage(result.message); | |
const error = new JestAssertionError(message); | |
@@ -255,19 +283,19 @@ expect.stringMatching = stringMatching; | |
const _validateResult = result => { | |
if ( | |
- typeof result !== 'object' || | |
- typeof result.pass !== 'boolean' || | |
- result.message && | |
- typeof result.message !== 'string' && | |
- typeof result.message !== 'function') | |
- { | |
+ typeof result !== 'object' || | |
+ typeof result.pass !== 'boolean' || | |
+ (result.message && | |
+ typeof result.message !== 'string' && | |
+ typeof result.message !== 'function') | |
+ ) { | |
throw new Error( | |
- 'Unexpected return from a matcher function.\n' + | |
- 'Matcher functions should ' + | |
- 'return an object in the following format:\n' + | |
- ' {message?: string | function, pass: boolean}\n' + | |
- `'${utils.stringify(result)}' was returned`); | |
- | |
+ 'Unexpected return from a matcher function.\n' + | |
+ 'Matcher functions should ' + | |
+ 'return an object in the following format:\n' + | |
+ ' {message?: string | function, pass: boolean}\n' + | |
+ `'${utils.stringify(result)}' was returned` | |
+ ); | |
} | |
}; | |
@@ -288,4 +316,4 @@ expect.setState = state => { | |
}; | |
expect.getState = () => global[GLOBAL_STATE].state; | |
-module.exports = expect; | |
\ No newline at end of file | |
+module.exports = expect; | |
diff --git i/packages/jest-matchers/build/jasmine-utils.js w/packages/jest-matchers/build/jasmine-utils.js | |
index 999675b3..2ed08630 100644 | |
--- i/packages/jest-matchers/build/jasmine-utils.js | |
+++ w/packages/jest-matchers/build/jasmine-utils.js | |
@@ -36,7 +36,7 @@ function isAsymmetric(obj) { | |
} | |
function asymmetricMatch(a, b) { | |
- var asymmetricA = isAsymmetric(a),asymmetricB = isAsymmetric(b); | |
+ var asymmetricA = isAsymmetric(a), asymmetricB = isAsymmetric(b); | |
if (asymmetricA && asymmetricB) { | |
return undefined; | |
@@ -107,8 +107,9 @@ function eq(a, b, aStack, bStack, customTesters) { | |
a.source == b.source && | |
a.global == b.global && | |
a.multiline == b.multiline && | |
- a.ignoreCase == b.ignoreCase);} | |
- | |
+ a.ignoreCase == b.ignoreCase | |
+ ); | |
+ } | |
if (typeof a != 'object' || typeof b != 'object') { | |
return false; | |
@@ -165,18 +166,7 @@ function eq(a, b, aStack, bStack, customTesters) { | |
} | |
} | |
} else { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- } // Objects with different constructors are not equivalent, but `Object`s | |
+ } // Objects with different constructors are not equivalent, but `Object`s // Deep compare objects. | |
// or `Array`s from different frames are. | |
// CUSTOM JEST CHANGE: | |
// TODO(cpojer): fix all tests and this and re-enable this check | |
@@ -186,9 +176,17 @@ function eq(a, b, aStack, bStack, customTesters) { | |
isFunction(bCtor) && bCtor instanceof bCtor)) { | |
return false; | |
} | |
- */ // Deep compare objects. | |
- var aKeys = keys(a, className == '[object Array]'),key;size = aKeys.length; // Ensure that both objects contain the same number of properties before comparing deep equality. | |
- if (keys(b, className == '[object Array]').length !== size) {return false;}while (size--) {key = aKeys[size]; | |
+ */ var aKeys = keys( | |
+ a, | |
+ className == '[object Array]' | |
+ ), | |
+ key; | |
+ size = aKeys.length; // Ensure that both objects contain the same number of properties before comparing deep equality. | |
+ if (keys(b, className == '[object Array]').length !== size) { | |
+ return false; | |
+ } | |
+ while (size--) { | |
+ key = aKeys[size]; | |
// Deep compare each member | |
result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters); | |
@@ -206,7 +204,7 @@ function eq(a, b, aStack, bStack, customTesters) { | |
function keys(obj, isArray) { | |
// CUSTOM JEST CHANGE: don't consider undefined keys. | |
- var allKeys = function (o) { | |
+ var allKeys = (function(o) { | |
var keys = []; | |
for (var key in o) { | |
if (has(o, key)) { | |
@@ -214,7 +212,7 @@ function keys(obj, isArray) { | |
} | |
} | |
return keys; | |
- }(obj); | |
+ })(obj); | |
if (!isArray) { | |
return allKeys; | |
@@ -238,8 +236,8 @@ function has(obj, key) { | |
// CUSTOM JEST CHANGE: | |
// TODO(cpojer): remove the `obj[key] !== undefined` check. | |
return ( | |
- Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined); | |
- | |
+ Object.prototype.hasOwnProperty.call(obj, key) && obj[key] !== undefined | |
+ ); | |
} | |
function isA(typeName, value) { | |
@@ -292,4 +290,5 @@ module.exports = { | |
fnNameFor, | |
hasProperty, | |
isA, | |
- isUndefined }; | |
\ No newline at end of file | |
+ isUndefined, | |
+}; | |
diff --git i/packages/jest-matchers/build/matchers.js w/packages/jest-matchers/build/matchers.js | |
index 66208d15..6549b1ae 100644 | |
--- i/packages/jest-matchers/build/matchers.js | |
+++ w/packages/jest-matchers/build/matchers.js | |
@@ -11,43 +11,38 @@ | |
'use strict'; | |
- | |
- | |
-const diff = require('jest-diff');var _require = | |
-require('jest-regex-util');const escapeStrForRegex = _require.escapeStrForRegex;var _require2 = | |
-require('./utils');const getObjectSubset = _require2.getObjectSubset,getPath = _require2.getPath,hasOwnProperty = _require2.hasOwnProperty;var _require3 = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-matcher-utils');const EXPECTED_COLOR = _require3.EXPECTED_COLOR,RECEIVED_COLOR = _require3.RECEIVED_COLOR,ensureNoExpected = _require3.ensureNoExpected,ensureNumbers = _require3.ensureNumbers,getType = _require3.getType,matcherHint = _require3.matcherHint,printReceived = _require3.printReceived,printExpected = _require3.printExpected,printWithType = _require3.printWithType;var _require4 = | |
-require('./jasmine-utils');const equals = _require4.equals; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+const diff = require('jest-diff'); | |
+var _require = require('jest-regex-util'); | |
+const escapeStrForRegex = _require.escapeStrForRegex; | |
+var _require2 = require('./utils'); | |
+const getObjectSubset = _require2.getObjectSubset, | |
+ getPath = _require2.getPath, | |
+ hasOwnProperty = _require2.hasOwnProperty; | |
+var _require3 = require('jest-matcher-utils'); | |
+const EXPECTED_COLOR = _require3.EXPECTED_COLOR, | |
+ RECEIVED_COLOR = _require3.RECEIVED_COLOR, | |
+ ensureNoExpected = _require3.ensureNoExpected, | |
+ ensureNumbers = _require3.ensureNumbers, | |
+ getType = _require3.getType, | |
+ matcherHint = _require3.matcherHint, | |
+ printReceived = _require3.printReceived, | |
+ printExpected = _require3.printExpected, | |
+ printWithType = _require3.printWithType; | |
+var _require4 = require('./jasmine-utils'); | |
+const equals = _require4.equals; | |
const IteratorSymbol = Symbol.iterator; | |
const hasIterator = object => !!(object != null && object[IteratorSymbol]); | |
const iterableEquality = (a, b) => { | |
if ( | |
- typeof a !== 'object' || | |
- typeof b !== 'object' || | |
- Array.isArray(a) || | |
- Array.isArray(b) || | |
- !hasIterator(a) || | |
- !hasIterator(b)) | |
- { | |
+ typeof a !== 'object' || | |
+ typeof b !== 'object' || | |
+ Array.isArray(a) || | |
+ Array.isArray(b) || | |
+ !hasIterator(a) || | |
+ !hasIterator(b) | |
+ ) { | |
return undefined; | |
} | |
if (a.constructor !== b.constructor) { | |
@@ -67,150 +62,154 @@ const iterableEquality = (a, b) => { | |
return true; | |
}; | |
const isObjectWithKeys = a => | |
-a !== null && | |
-typeof a === 'object' && | |
-!(a instanceof Array) && | |
-!(a instanceof Date); | |
+ a !== null && | |
+ typeof a === 'object' && | |
+ !(a instanceof Array) && | |
+ !(a instanceof Date); | |
const subsetEquality = (object, subset) => { | |
if (!isObjectWithKeys(object) || !isObjectWithKeys(subset)) { | |
return undefined; | |
} | |
return Object.keys(subset).every( | |
- key => | |
- hasOwnProperty(object, key) && | |
- equals(object[key], subset[key], [iterableEquality, subsetEquality])); | |
- | |
+ key => | |
+ hasOwnProperty(object, key) && | |
+ equals(object[key], subset[key], [iterableEquality, subsetEquality]) | |
+ ); | |
}; | |
const matchers = { | |
toBe(received, expected) { | |
const pass = received === expected; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBe') + | |
- '\n\n' + | |
- `Expected value to not be (using ===):\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}` : | |
- () => { | |
- const diffString = diff(expected, received, { | |
- expand: this.expand }); | |
- | |
- return ( | |
- matcherHint('.toBe') + | |
- '\n\n' + | |
- `Expected value to be (using ===):\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}` + ( | |
- diffString ? `\n\nDifference:\n\n${diffString}` : '')); | |
- | |
- }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBe') + | |
+ '\n\n' + | |
+ `Expected value to not be (using ===):\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}` | |
+ : () => { | |
+ const diffString = diff(expected, received, { | |
+ expand: this.expand, | |
+ }); | |
+ | |
+ return ( | |
+ matcherHint('.toBe') + | |
+ '\n\n' + | |
+ `Expected value to be (using ===):\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}` + | |
+ (diffString ? `\n\nDifference:\n\n${diffString}` : '') | |
+ ); | |
+ }; | |
// Passing the the actual and expected objects so that a custom reporter | |
// could access them, for example in order to display a custom visual diff, | |
// or create a different error message | |
- return { actual: received, expected, message, name: 'toBe', pass }; | |
+ return {actual: received, expected, message, name: 'toBe', pass}; | |
}, | |
- toBeCloseTo(actual, expected) {let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; | |
+ toBeCloseTo(actual, expected) { | |
+ let precision = arguments.length > 2 && arguments[2] !== undefined | |
+ ? arguments[2] | |
+ : 2; | |
ensureNumbers(actual, expected, '.toBeCloseTo'); | |
const pass = Math.abs(expected - actual) < Math.pow(10, -precision) / 2; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeCloseTo', 'received', 'expected, precision') + | |
- '\n\n' + | |
- `Expected value not to be close to (with ${printExpected(precision)}-digit precision):\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeCloseTo', 'received', 'expected, precision') + | |
- '\n\n' + | |
- `Expected value to be close to (with ${printExpected(precision)}-digit precision):\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeCloseTo', 'received', 'expected, precision') + | |
+ '\n\n' + | |
+ `Expected value not to be close to (with ${printExpected(precision)}-digit precision):\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeCloseTo', 'received', 'expected, precision') + | |
+ '\n\n' + | |
+ `Expected value to be close to (with ${printExpected(precision)}-digit precision):\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toBeDefined(actual, expected) { | |
ensureNoExpected(expected, '.toBeDefined'); | |
const pass = actual !== void 0; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeDefined', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be defined, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeDefined', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be defined, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeDefined', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be defined, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeDefined', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be defined, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeFalsy(actual, expected) { | |
ensureNoExpected(expected, '.toBeFalsy'); | |
const pass = !actual; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeFalsy', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be falsy, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeFalsy', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be falsy, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeFalsy', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be falsy, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeFalsy', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be falsy, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeGreaterThan(actual, expected) { | |
ensureNumbers(actual, expected, '.toBeGreaterThan'); | |
const pass = actual > expected; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeGreaterThan') + | |
- '\n\n' + | |
- `Expected value not to be greater than:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeGreaterThan') + | |
- '\n\n' + | |
- `Expected value to be greater than:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeGreaterThan') + | |
+ '\n\n' + | |
+ `Expected value not to be greater than:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeGreaterThan') + | |
+ '\n\n' + | |
+ `Expected value to be greater than:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeGreaterThanOrEqual(actual, expected) { | |
ensureNumbers(actual, expected, '.toBeGreaterThanOrEqual'); | |
const pass = actual >= expected; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeGreaterThanOrEqual') + | |
- '\n\n' + | |
- `Expected value not to be greater than or equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeGreaterThanOrEqual') + | |
- '\n\n' + | |
- `Expected value to be greater than or equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeGreaterThanOrEqual') + | |
+ '\n\n' + | |
+ `Expected value not to be greater than or equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeGreaterThanOrEqual') + | |
+ '\n\n' + | |
+ `Expected value to be greater than or equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeInstanceOf(received, constructor) { | |
@@ -218,144 +217,144 @@ const matchers = { | |
if (constType !== 'function') { | |
throw new Error( | |
- matcherHint('[.not].toBeInstanceOf', 'value', 'constructor') + | |
- `\n\n` + | |
- `Expected constructor to be a function. Instead got:\n` + | |
- ` ${printExpected(constType)}`); | |
- | |
+ matcherHint('[.not].toBeInstanceOf', 'value', 'constructor') + | |
+ `\n\n` + | |
+ `Expected constructor to be a function. Instead got:\n` + | |
+ ` ${printExpected(constType)}` | |
+ ); | |
} | |
const pass = received instanceof constructor; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeInstanceOf', 'value', 'constructor') + | |
- '\n\n' + | |
- `Expected value not to be an instance of:\n` + | |
- ` ${printExpected(constructor.name || constructor)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}\n` : | |
- () => | |
- matcherHint('.toBeInstanceOf', 'value', 'constructor') + | |
- '\n\n' + | |
- `Expected value to be an instance of:\n` + | |
- ` ${printExpected(constructor.name || constructor)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}\n` + | |
- `Constructor:\n` + | |
- ` ${printReceived(received.constructor && received.constructor.name)}`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeInstanceOf', 'value', 'constructor') + | |
+ '\n\n' + | |
+ `Expected value not to be an instance of:\n` + | |
+ ` ${printExpected(constructor.name || constructor)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}\n` | |
+ : () => | |
+ matcherHint('.toBeInstanceOf', 'value', 'constructor') + | |
+ '\n\n' + | |
+ `Expected value to be an instance of:\n` + | |
+ ` ${printExpected(constructor.name || constructor)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}\n` + | |
+ `Constructor:\n` + | |
+ ` ${printReceived(received.constructor && received.constructor.name)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toBeLessThan(actual, expected) { | |
ensureNumbers(actual, expected, '.toBeLessThan'); | |
const pass = actual < expected; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeLessThan') + | |
- '\n\n' + | |
- `Expected value not to be less than:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeLessThan') + | |
- '\n\n' + | |
- `Expected value to be less than:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeLessThan') + | |
+ '\n\n' + | |
+ `Expected value not to be less than:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeLessThan') + | |
+ '\n\n' + | |
+ `Expected value to be less than:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeLessThanOrEqual(actual, expected) { | |
ensureNumbers(actual, expected, '.toBeLessThanOrEqual'); | |
const pass = actual <= expected; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeLessThanOrEqual') + | |
- '\n\n' + | |
- `Expected value not to be less than or equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeLessThanOrEqual') + | |
- '\n\n' + | |
- `Expected value to be less than or equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeLessThanOrEqual') + | |
+ '\n\n' + | |
+ `Expected value not to be less than or equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeLessThanOrEqual') + | |
+ '\n\n' + | |
+ `Expected value to be less than or equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeNaN(actual, expected) { | |
ensureNoExpected(expected, '.toBeNaN'); | |
const pass = Number.isNaN(actual); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeNaN', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be NaN, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeNaN', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be NaN, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeNaN', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be NaN, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeNaN', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be NaN, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeNull(actual, expected) { | |
ensureNoExpected(expected, '.toBeNull'); | |
const pass = actual === null; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeNull', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be null, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeNull', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be null, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeNull', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be null, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeNull', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be null, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeTruthy(actual, expected) { | |
ensureNoExpected(expected, '.toBeTruthy'); | |
const pass = !!actual; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeTruthy', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be truthy, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeTruthy', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be truthy, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeTruthy', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be truthy, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeTruthy', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be truthy, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ return {message, pass}; | |
}, | |
toBeUndefined(actual, expected) { | |
ensureNoExpected(expected, '.toBeUndefined'); | |
const pass = actual === void 0; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toBeUndefined', 'received', '') + | |
- '\n\n' + | |
- `Expected value not to be undefined, instead received\n` + | |
- ` ${printReceived(actual)}` : | |
- () => | |
- matcherHint('.toBeUndefined', 'received', '') + | |
- '\n\n' + | |
- `Expected value to be undefined, instead received\n` + | |
- ` ${printReceived(actual)}`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toBeUndefined', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value not to be undefined, instead received\n` + | |
+ ` ${printReceived(actual)}` | |
+ : () => | |
+ matcherHint('.toBeUndefined', 'received', '') + | |
+ '\n\n' + | |
+ `Expected value to be undefined, instead received\n` + | |
+ ` ${printReceived(actual)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toContain(collection, value) { | |
@@ -371,33 +370,33 @@ const matchers = { | |
converted = Array.from(collection); | |
} catch (e) { | |
throw new Error( | |
- matcherHint('[.not].toContainEqual', 'collection', 'value') + | |
- '\n\n' + | |
- `Expected ${RECEIVED_COLOR('collection')} to be an array-like structure.\n` + | |
- printWithType('Received', collection, printReceived)); | |
- | |
+ matcherHint('[.not].toContainEqual', 'collection', 'value') + | |
+ '\n\n' + | |
+ `Expected ${RECEIVED_COLOR('collection')} to be an array-like structure.\n` + | |
+ printWithType('Received', collection, printReceived) | |
+ ); | |
} | |
} | |
// At this point, we're either a string or an Array, | |
// which was converted from an array-like structure. | |
const pass = converted.indexOf(value) != -1; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toContain', collectionType, 'value') + | |
- '\n\n' + | |
- `Expected ${collectionType}:\n` + | |
- ` ${printReceived(collection)}\n` + | |
- `Not to contain value:\n` + | |
- ` ${printExpected(value)}\n` : | |
- () => | |
- matcherHint('.toContain', collectionType, 'value') + | |
- '\n\n' + | |
- `Expected ${collectionType}:\n` + | |
- ` ${printReceived(collection)}\n` + | |
- `To contain value:\n` + | |
- ` ${printExpected(value)}`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toContain', collectionType, 'value') + | |
+ '\n\n' + | |
+ `Expected ${collectionType}:\n` + | |
+ ` ${printReceived(collection)}\n` + | |
+ `Not to contain value:\n` + | |
+ ` ${printExpected(value)}\n` | |
+ : () => | |
+ matcherHint('.toContain', collectionType, 'value') + | |
+ '\n\n' + | |
+ `Expected ${collectionType}:\n` + | |
+ ` ${printReceived(collection)}\n` + | |
+ `To contain value:\n` + | |
+ ` ${printExpected(value)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toContainEqual(collection, value) { | |
@@ -410,107 +409,108 @@ const matchers = { | |
converted = Array.from(collection); | |
} catch (e) { | |
throw new Error( | |
- matcherHint('[.not].toContainEqual', 'collection', 'value') + | |
- '\n\n' + | |
- `Expected ${RECEIVED_COLOR('collection')} to be an array-like structure.\n` + | |
- printWithType('Received', collection, printReceived)); | |
- | |
+ matcherHint('[.not].toContainEqual', 'collection', 'value') + | |
+ '\n\n' + | |
+ `Expected ${RECEIVED_COLOR('collection')} to be an array-like structure.\n` + | |
+ printWithType('Received', collection, printReceived) | |
+ ); | |
} | |
} | |
const pass = | |
- converted.findIndex(item => equals(item, value, [iterableEquality])) !== | |
- -1; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toContainEqual', collectionType, 'value') + | |
- '\n\n' + | |
- `Expected ${collectionType}:\n` + | |
- ` ${printReceived(collection)}\n` + | |
- `Not to contain a value equal to:\n` + | |
- ` ${printExpected(value)}\n` : | |
- () => | |
- matcherHint('.toContainEqual', collectionType, 'value') + | |
- '\n\n' + | |
- `Expected ${collectionType}:\n` + | |
- ` ${printReceived(collection)}\n` + | |
- `To contain a value equal to:\n` + | |
- ` ${printExpected(value)}`; | |
- | |
- return { message, pass }; | |
+ converted.findIndex(item => equals(item, value, [iterableEquality])) !== | |
+ -1; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toContainEqual', collectionType, 'value') + | |
+ '\n\n' + | |
+ `Expected ${collectionType}:\n` + | |
+ ` ${printReceived(collection)}\n` + | |
+ `Not to contain a value equal to:\n` + | |
+ ` ${printExpected(value)}\n` | |
+ : () => | |
+ matcherHint('.toContainEqual', collectionType, 'value') + | |
+ '\n\n' + | |
+ `Expected ${collectionType}:\n` + | |
+ ` ${printReceived(collection)}\n` + | |
+ `To contain a value equal to:\n` + | |
+ ` ${printExpected(value)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toEqual(received, expected) { | |
const pass = equals(received, expected, [iterableEquality]); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toEqual') + | |
- '\n\n' + | |
- `Expected value to not equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}` : | |
- () => { | |
- const diffString = diff(expected, received, { | |
- expand: this.expand }); | |
- | |
- return ( | |
- matcherHint('.toEqual') + | |
- '\n\n' + | |
- `Expected value to equal:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}` + ( | |
- diffString ? `\n\nDifference:\n\n${diffString}` : '')); | |
- | |
- }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toEqual') + | |
+ '\n\n' + | |
+ `Expected value to not equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}` | |
+ : () => { | |
+ const diffString = diff(expected, received, { | |
+ expand: this.expand, | |
+ }); | |
+ | |
+ return ( | |
+ matcherHint('.toEqual') + | |
+ '\n\n' + | |
+ `Expected value to equal:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}` + | |
+ (diffString ? `\n\nDifference:\n\n${diffString}` : '') | |
+ ); | |
+ }; | |
// Passing the the actual and expected objects so that a custom reporter | |
// could access them, for example in order to display a custom visual diff, | |
// or create a different error message | |
- return { actual: received, expected, message, name: 'toEqual', pass }; | |
+ return {actual: received, expected, message, name: 'toEqual', pass}; | |
}, | |
toHaveLength(received, length) { | |
if ( | |
- typeof received !== 'string' && ( | |
- !received || typeof received.length !== 'number')) | |
- { | |
+ typeof received !== 'string' && | |
+ (!received || typeof received.length !== 'number') | |
+ ) { | |
throw new Error( | |
- matcherHint('[.not].toHaveLength', 'received', 'length') + | |
- '\n\n' + | |
- `Expected value to have a 'length' property that is a number. ` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}\n` + ( | |
- received ? | |
- `received.length:\n ${printReceived(received.length)}` : | |
- '')); | |
- | |
+ matcherHint('[.not].toHaveLength', 'received', 'length') + | |
+ '\n\n' + | |
+ `Expected value to have a 'length' property that is a number. ` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}\n` + | |
+ (received | |
+ ? `received.length:\n ${printReceived(received.length)}` | |
+ : '') | |
+ ); | |
} | |
const pass = received.length === length; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toHaveLength', 'received', 'length') + | |
- '\n\n' + | |
- `Expected value to not have length:\n` + | |
- ` ${printExpected(length)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}\n` + | |
- `received.length:\n` + | |
- ` ${printReceived(received.length)}` : | |
- () => | |
- matcherHint('.toHaveLength', 'received', 'length') + | |
- '\n\n' + | |
- `Expected value to have length:\n` + | |
- ` ${printExpected(length)}\n` + | |
- `Received:\n` + | |
- ` ${printReceived(received)}\n` + | |
- `received.length:\n` + | |
- ` ${printReceived(received.length)}`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toHaveLength', 'received', 'length') + | |
+ '\n\n' + | |
+ `Expected value to not have length:\n` + | |
+ ` ${printExpected(length)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}\n` + | |
+ `received.length:\n` + | |
+ ` ${printReceived(received.length)}` | |
+ : () => | |
+ matcherHint('.toHaveLength', 'received', 'length') + | |
+ '\n\n' + | |
+ `Expected value to have length:\n` + | |
+ ` ${printExpected(length)}\n` + | |
+ `Received:\n` + | |
+ ` ${printReceived(received)}\n` + | |
+ `received.length:\n` + | |
+ ` ${printReceived(received.length)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toHaveProperty(object, keyPath, value) { | |
@@ -518,40 +518,41 @@ const matchers = { | |
if (!object && typeof object !== 'string' && typeof object !== 'number') { | |
throw new Error( | |
- matcherHint('[.not].toHaveProperty', 'object', 'path', { | |
- secondArgument: valuePassed ? 'value' : null }) + | |
- | |
- '\n\n' + | |
- `Expected ${RECEIVED_COLOR('object')} to be an object. Received:\n` + | |
- ` ${getType(object)}: ${printReceived(object)}`); | |
- | |
+ matcherHint('[.not].toHaveProperty', 'object', 'path', { | |
+ secondArgument: valuePassed ? 'value' : null, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected ${RECEIVED_COLOR('object')} to be an object. Received:\n` + | |
+ ` ${getType(object)}: ${printReceived(object)}` | |
+ ); | |
} | |
if (getType(keyPath) !== 'string') { | |
throw new Error( | |
- matcherHint('[.not].toHaveProperty', 'object', 'path', { | |
- secondArgument: valuePassed ? 'value' : null }) + | |
- | |
- '\n\n' + | |
- `Expected ${EXPECTED_COLOR('path')} to be a string. Received:\n` + | |
- ` ${getType(keyPath)}: ${printReceived(keyPath)}`); | |
- | |
+ matcherHint('[.not].toHaveProperty', 'object', 'path', { | |
+ secondArgument: valuePassed ? 'value' : null, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected ${EXPECTED_COLOR('path')} to be a string. Received:\n` + | |
+ ` ${getType(keyPath)}: ${printReceived(keyPath)}` | |
+ ); | |
} | |
- const result = getPath(object, keyPath);const | |
- lastTraversedObject = result.lastTraversedObject,hasEndProp = result.hasEndProp; | |
+ const result = getPath(object, keyPath); | |
+ const lastTraversedObject = result.lastTraversedObject, | |
+ hasEndProp = result.hasEndProp; | |
let diffString; | |
if (valuePassed && hasOwnProperty(result, 'value')) { | |
diffString = diff(value, result.value, { | |
- expand: this.expand }); | |
- | |
+ expand: this.expand, | |
+ }); | |
} | |
- const pass = valuePassed ? | |
- equals(result.value, value, [iterableEquality]) : | |
- hasEndProp; | |
+ const pass = valuePassed | |
+ ? equals(result.value, value, [iterableEquality]) | |
+ : hasEndProp; | |
if (hasOwnProperty(result, 'value')) { | |
// we don't diff numbers. So instead we'll show the object that contains the resulting value. | |
@@ -560,126 +561,127 @@ const matchers = { | |
} | |
const traversedPath = result.traversedPath.join('.'); | |
- const message = pass ? | |
- matcherHint('.not.toHaveProperty', 'object', 'path', { | |
- secondArgument: valuePassed ? 'value' : null }) + | |
- | |
- '\n\n' + | |
- `Expected the object:\n` + | |
- ` ${printReceived(object)}\n` + | |
- `Not to have a nested property:\n` + | |
- ` ${printExpected(keyPath)}\n` + ( | |
- valuePassed ? `With a value of:\n ${printExpected(value)}\n` : '') : | |
- matcherHint('.toHaveProperty', 'object', 'path', { | |
- secondArgument: valuePassed ? 'value' : null }) + | |
- | |
- '\n\n' + | |
- `Expected the object:\n` + | |
- ` ${printReceived(object)}\n` + | |
- `To have a nested property:\n` + | |
- ` ${printExpected(keyPath)}\n` + ( | |
- valuePassed ? `With a value of:\n ${printExpected(value)}\n` : '') + ( | |
- traversedPath ? | |
- `Received:\n ${RECEIVED_COLOR('object')}.${traversedPath}: ${printReceived(lastTraversedObject)}` : | |
- '') + ( | |
- diffString ? `\nDifference:\n\n${diffString}` : ''); | |
+ const message = pass | |
+ ? matcherHint('.not.toHaveProperty', 'object', 'path', { | |
+ secondArgument: valuePassed ? 'value' : null, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected the object:\n` + | |
+ ` ${printReceived(object)}\n` + | |
+ `Not to have a nested property:\n` + | |
+ ` ${printExpected(keyPath)}\n` + | |
+ (valuePassed ? `With a value of:\n ${printExpected(value)}\n` : '') | |
+ : matcherHint('.toHaveProperty', 'object', 'path', { | |
+ secondArgument: valuePassed ? 'value' : null, | |
+ }) + | |
+ '\n\n' + | |
+ `Expected the object:\n` + | |
+ ` ${printReceived(object)}\n` + | |
+ `To have a nested property:\n` + | |
+ ` ${printExpected(keyPath)}\n` + | |
+ (valuePassed ? `With a value of:\n ${printExpected(value)}\n` : '') + | |
+ (traversedPath | |
+ ? `Received:\n ${RECEIVED_COLOR('object')}.${traversedPath}: ${printReceived(lastTraversedObject)}` | |
+ : '') + | |
+ (diffString ? `\nDifference:\n\n${diffString}` : ''); | |
if (pass === undefined) { | |
throw new Error('pass must be initialized'); | |
} | |
- return { message, pass }; | |
+ return {message, pass}; | |
}, | |
toMatch(received, expected) { | |
if (typeof received !== 'string') { | |
throw new Error( | |
- matcherHint('[.not].toMatch', 'string', 'expected') + | |
- '\n\n' + | |
- `${RECEIVED_COLOR('string')} value must be a string.\n` + | |
- printWithType('Received', received, printReceived)); | |
- | |
+ matcherHint('[.not].toMatch', 'string', 'expected') + | |
+ '\n\n' + | |
+ `${RECEIVED_COLOR('string')} value must be a string.\n` + | |
+ printWithType('Received', received, printReceived) | |
+ ); | |
} | |
if (!(expected instanceof RegExp) && !(typeof expected === 'string')) { | |
throw new Error( | |
- matcherHint('[.not].toMatch', 'string', 'expected') + | |
- '\n\n' + | |
- `${EXPECTED_COLOR('expected')} value must be a string or a regular expression.\n` + | |
- printWithType('Expected', expected, printExpected)); | |
- | |
+ matcherHint('[.not].toMatch', 'string', 'expected') + | |
+ '\n\n' + | |
+ `${EXPECTED_COLOR('expected')} value must be a string or a regular expression.\n` + | |
+ printWithType('Expected', expected, printExpected) | |
+ ); | |
} | |
const pass = new RegExp( | |
- typeof expected === 'string' ? escapeStrForRegex(expected) : expected). | |
- test(received); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toMatch') + | |
- `\n\nExpected value not to match:\n` + | |
- ` ${printExpected(expected)}` + | |
- `\nReceived:\n` + | |
- ` ${printReceived(received)}` : | |
- () => | |
- matcherHint('.toMatch') + | |
- `\n\nExpected value to match:\n` + | |
- ` ${printExpected(expected)}` + | |
- `\nReceived:\n` + | |
- ` ${printReceived(received)}`; | |
- | |
- return { message, pass }; | |
+ typeof expected === 'string' ? escapeStrForRegex(expected) : expected | |
+ ).test(received); | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toMatch') + | |
+ `\n\nExpected value not to match:\n` + | |
+ ` ${printExpected(expected)}` + | |
+ `\nReceived:\n` + | |
+ ` ${printReceived(received)}` | |
+ : () => | |
+ matcherHint('.toMatch') + | |
+ `\n\nExpected value to match:\n` + | |
+ ` ${printExpected(expected)}` + | |
+ `\nReceived:\n` + | |
+ ` ${printReceived(received)}`; | |
+ | |
+ return {message, pass}; | |
}, | |
toMatchObject(receivedObject, expectedObject) { | |
if (typeof receivedObject !== 'object' || receivedObject === null) { | |
throw new Error( | |
- matcherHint('[.not].toMatchObject', 'object', 'expected') + | |
- '\n\n' + | |
- `${RECEIVED_COLOR('received')} value must be an object.\n` + | |
- printWithType('Received', receivedObject, printReceived)); | |
- | |
+ matcherHint('[.not].toMatchObject', 'object', 'expected') + | |
+ '\n\n' + | |
+ `${RECEIVED_COLOR('received')} value must be an object.\n` + | |
+ printWithType('Received', receivedObject, printReceived) | |
+ ); | |
} | |
if (typeof expectedObject !== 'object' || expectedObject === null) { | |
throw new Error( | |
- matcherHint('[.not].toMatchObject', 'object', 'expected') + | |
- '\n\n' + | |
- `${EXPECTED_COLOR('expected')} value must be an object.\n` + | |
- printWithType('Expected', expectedObject, printExpected)); | |
- | |
+ matcherHint('[.not].toMatchObject', 'object', 'expected') + | |
+ '\n\n' + | |
+ `${EXPECTED_COLOR('expected')} value must be an object.\n` + | |
+ printWithType('Expected', expectedObject, printExpected) | |
+ ); | |
} | |
const pass = equals(receivedObject, expectedObject, [ | |
- iterableEquality, | |
- subsetEquality]); | |
- | |
- | |
- const message = pass ? | |
- () => | |
- matcherHint('.not.toMatchObject') + | |
- `\n\nExpected value not to match object:\n` + | |
- ` ${printExpected(expectedObject)}` + | |
- `\nReceived:\n` + | |
- ` ${printReceived(receivedObject)}` : | |
- () => { | |
- const diffString = diff( | |
- expectedObject, | |
- getObjectSubset(receivedObject, expectedObject), | |
- { | |
- expand: this.expand }); | |
- | |
- | |
- return ( | |
- matcherHint('.toMatchObject') + | |
- `\n\nExpected value to match object:\n` + | |
- ` ${printExpected(expectedObject)}` + | |
- `\nReceived:\n` + | |
- ` ${printReceived(receivedObject)}` + ( | |
- diffString ? `\nDifference:\n${diffString}` : '')); | |
- | |
- }; | |
- | |
- return { message, pass }; | |
- } }; | |
- | |
+ iterableEquality, | |
+ subsetEquality, | |
+ ]); | |
+ | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not.toMatchObject') + | |
+ `\n\nExpected value not to match object:\n` + | |
+ ` ${printExpected(expectedObject)}` + | |
+ `\nReceived:\n` + | |
+ ` ${printReceived(receivedObject)}` | |
+ : () => { | |
+ const diffString = diff( | |
+ expectedObject, | |
+ getObjectSubset(receivedObject, expectedObject), | |
+ { | |
+ expand: this.expand, | |
+ } | |
+ ); | |
+ | |
+ return ( | |
+ matcherHint('.toMatchObject') + | |
+ `\n\nExpected value to match object:\n` + | |
+ ` ${printExpected(expectedObject)}` + | |
+ `\nReceived:\n` + | |
+ ` ${printReceived(receivedObject)}` + | |
+ (diffString ? `\nDifference:\n${diffString}` : '') | |
+ ); | |
+ }; | |
+ | |
+ return {message, pass}; | |
+ }, | |
+}; | |
-module.exports = matchers; | |
\ No newline at end of file | |
+module.exports = matchers; | |
diff --git i/packages/jest-matchers/build/spyMatchers.js w/packages/jest-matchers/build/spyMatchers.js | |
index 3c05e2bf..33338917 100644 | |
--- i/packages/jest-matchers/build/spyMatchers.js | |
+++ w/packages/jest-matchers/build/spyMatchers.js | |
@@ -10,27 +10,25 @@ | |
'use strict'; | |
- | |
- | |
const CALL_PRINT_LIMIT = 3; | |
-const LAST_CALL_PRINT_LIMIT = 1;var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-matcher-utils');const ensureExpectedIsNumber = _require.ensureExpectedIsNumber,ensureNoExpected = _require.ensureNoExpected,EXPECTED_COLOR = _require.EXPECTED_COLOR,matcherHint = _require.matcherHint,pluralize = _require.pluralize,printExpected = _require.printExpected,printReceived = _require.printReceived,printWithType = _require.printWithType,RECEIVED_COLOR = _require.RECEIVED_COLOR;var _require2 = | |
-require('./jasmine-utils');const equals = _require2.equals; | |
+const LAST_CALL_PRINT_LIMIT = 1; | |
+var _require = require('jest-matcher-utils'); | |
+const ensureExpectedIsNumber = _require.ensureExpectedIsNumber, | |
+ ensureNoExpected = _require.ensureNoExpected, | |
+ EXPECTED_COLOR = _require.EXPECTED_COLOR, | |
+ matcherHint = _require.matcherHint, | |
+ pluralize = _require.pluralize, | |
+ printExpected = _require.printExpected, | |
+ printReceived = _require.printReceived, | |
+ printWithType = _require.printWithType, | |
+ RECEIVED_COLOR = _require.RECEIVED_COLOR; | |
+var _require2 = require('./jasmine-utils'); | |
+const equals = _require2.equals; | |
const RECEIVED_NAME = { | |
'mock function': 'jest.fn()', | |
- spy: 'spy' }; | |
- | |
+ spy: 'spy', | |
+}; | |
const createToBeCalledMatcher = matcherName => (received, expected) => { | |
ensureNoExpected(expected, matcherName); | |
@@ -38,84 +36,98 @@ const createToBeCalledMatcher = matcherName => (received, expected) => { | |
const receivedIsSpy = isSpy(received); | |
const type = receivedIsSpy ? 'spy' : 'mock function'; | |
- const count = receivedIsSpy ? | |
- received.calls.count() : | |
- received.mock.calls.length; | |
- const calls = receivedIsSpy ? | |
- received.calls.all().map(x => x.args) : | |
- received.mock.calls; | |
+ const count = receivedIsSpy | |
+ ? received.calls.count() | |
+ : received.mock.calls.length; | |
+ const calls = receivedIsSpy | |
+ ? received.calls.all().map(x => x.args) | |
+ : received.mock.calls; | |
const pass = count > 0; | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + matcherName, RECEIVED_NAME[type], '') + | |
- '\n\n' + | |
- `Expected ${type} not to be called ` + | |
- formatReceivedCalls(calls, CALL_PRINT_LIMIT, { sameSentence: true }) : | |
- () => | |
- matcherHint(matcherName, RECEIVED_NAME[type], '') + | |
- '\n\n' + | |
- `Expected ${type} to have been called.`; | |
- | |
- return { message, pass }; | |
-}; | |
- | |
-const createToBeCalledWithMatcher = matcherName => function ( | |
-received) | |
- | |
-{for (var _len = arguments.length, expected = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {expected[_key - 1] = arguments[_key];} | |
- ensureMock(received, matcherName); | |
- | |
- const receivedIsSpy = isSpy(received); | |
- const type = receivedIsSpy ? 'spy' : 'mock function'; | |
- const calls = receivedIsSpy ? | |
- received.calls.all().map(x => x.args) : | |
- received.mock.calls; | |
- const pass = calls.some(call => equals(call, expected)); | |
- | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + matcherName, RECEIVED_NAME[type]) + | |
- '\n\n' + | |
- `Expected ${type} not to have been called with:\n` + | |
- ` ${printExpected(expected)}` : | |
- () => | |
- matcherHint(matcherName, RECEIVED_NAME[type]) + | |
- '\n\n' + | |
- `Expected ${type} to have been called with:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- formatReceivedCalls(calls, CALL_PRINT_LIMIT); | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + matcherName, RECEIVED_NAME[type], '') + | |
+ '\n\n' + | |
+ `Expected ${type} not to be called ` + | |
+ formatReceivedCalls(calls, CALL_PRINT_LIMIT, {sameSentence: true}) | |
+ : () => | |
+ matcherHint(matcherName, RECEIVED_NAME[type], '') + | |
+ '\n\n' + | |
+ `Expected ${type} to have been called.`; | |
+ | |
+ return {message, pass}; | |
}; | |
-const createLastCalledWithMatcher = matcherName => function ( | |
-received) | |
+const createToBeCalledWithMatcher = matcherName => | |
+ function(received) { | |
+ for ( | |
+ var _len = arguments.length, | |
+ expected = Array(_len > 1 ? _len - 1 : 0), | |
+ _key = 1; | |
+ _key < _len; | |
+ _key++ | |
+ ) { | |
+ expected[_key - 1] = arguments[_key]; | |
+ } | |
+ ensureMock(received, matcherName); | |
-{for (var _len2 = arguments.length, expected = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {expected[_key2 - 1] = arguments[_key2];} | |
- ensureMock(received, matcherName); | |
+ const receivedIsSpy = isSpy(received); | |
+ const type = receivedIsSpy ? 'spy' : 'mock function'; | |
+ const calls = receivedIsSpy | |
+ ? received.calls.all().map(x => x.args) | |
+ : received.mock.calls; | |
+ const pass = calls.some(call => equals(call, expected)); | |
+ | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + matcherName, RECEIVED_NAME[type]) + | |
+ '\n\n' + | |
+ `Expected ${type} not to have been called with:\n` + | |
+ ` ${printExpected(expected)}` | |
+ : () => | |
+ matcherHint(matcherName, RECEIVED_NAME[type]) + | |
+ '\n\n' + | |
+ `Expected ${type} to have been called with:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ formatReceivedCalls(calls, CALL_PRINT_LIMIT); | |
+ | |
+ return {message, pass}; | |
+ }; | |
+ | |
+const createLastCalledWithMatcher = matcherName => | |
+ function(received) { | |
+ for ( | |
+ var _len2 = arguments.length, | |
+ expected = Array(_len2 > 1 ? _len2 - 1 : 0), | |
+ _key2 = 1; | |
+ _key2 < _len2; | |
+ _key2++ | |
+ ) { | |
+ expected[_key2 - 1] = arguments[_key2]; | |
+ } | |
+ ensureMock(received, matcherName); | |
- const receivedIsSpy = isSpy(received); | |
- const type = receivedIsSpy ? 'spy' : 'mock function'; | |
- const calls = receivedIsSpy ? | |
- received.calls.all().map(x => x.args) : | |
- received.mock.calls; | |
- const pass = equals(calls[calls.length - 1], expected); | |
- | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + matcherName, RECEIVED_NAME[type]) + | |
- '\n\n' + | |
- `Expected ${type} to not have been last called with:\n` + | |
- ` ${printExpected(expected)}` : | |
- () => | |
- matcherHint(matcherName, RECEIVED_NAME[type]) + | |
- '\n\n' + | |
- `Expected ${type} to have been last called with:\n` + | |
- ` ${printExpected(expected)}\n` + | |
- formatReceivedCalls(calls, LAST_CALL_PRINT_LIMIT, { isLast: true }); | |
- | |
- return { message, pass }; | |
-}; | |
+ const receivedIsSpy = isSpy(received); | |
+ const type = receivedIsSpy ? 'spy' : 'mock function'; | |
+ const calls = receivedIsSpy | |
+ ? received.calls.all().map(x => x.args) | |
+ : received.mock.calls; | |
+ const pass = equals(calls[calls.length - 1], expected); | |
+ | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + matcherName, RECEIVED_NAME[type]) + | |
+ '\n\n' + | |
+ `Expected ${type} to not have been last called with:\n` + | |
+ ` ${printExpected(expected)}` | |
+ : () => | |
+ matcherHint(matcherName, RECEIVED_NAME[type]) + | |
+ '\n\n' + | |
+ `Expected ${type} to have been last called with:\n` + | |
+ ` ${printExpected(expected)}\n` + | |
+ formatReceivedCalls(calls, LAST_CALL_PRINT_LIMIT, {isLast: true}); | |
+ | |
+ return {message, pass}; | |
+ }; | |
const spyMatchers = { | |
lastCalledWith: createLastCalledWithMatcher('.lastCalledWith'), | |
@@ -129,51 +141,51 @@ const spyMatchers = { | |
const receivedIsSpy = isSpy(received); | |
const type = receivedIsSpy ? 'spy' : 'mock function'; | |
- const count = receivedIsSpy ? | |
- received.calls.count() : | |
- received.mock.calls.length; | |
+ const count = receivedIsSpy | |
+ ? received.calls.count() | |
+ : received.mock.calls.length; | |
const pass = count === expected; | |
- const message = pass ? | |
- () => | |
- matcherHint( | |
- '.not' + matcherName, | |
- RECEIVED_NAME[type], | |
- String(expected)) + | |
- | |
- `\n\n` + | |
- `Expected ${type} not to be called ` + | |
- `${EXPECTED_COLOR(pluralize('time', expected))}, but it was` + | |
- ` called exactly ${RECEIVED_COLOR(pluralize('time', count))}.` : | |
- () => | |
- matcherHint(matcherName, RECEIVED_NAME[type], String(expected)) + | |
- '\n\n' + | |
- `Expected ${type} to have been called ` + | |
- `${EXPECTED_COLOR(pluralize('time', expected))},` + | |
- ` but it was called ${RECEIVED_COLOR(pluralize('time', count))}.`; | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint( | |
+ '.not' + matcherName, | |
+ RECEIVED_NAME[type], | |
+ String(expected) | |
+ ) + | |
+ `\n\n` + | |
+ `Expected ${type} not to be called ` + | |
+ `${EXPECTED_COLOR(pluralize('time', expected))}, but it was` + | |
+ ` called exactly ${RECEIVED_COLOR(pluralize('time', count))}.` | |
+ : () => | |
+ matcherHint(matcherName, RECEIVED_NAME[type], String(expected)) + | |
+ '\n\n' + | |
+ `Expected ${type} to have been called ` + | |
+ `${EXPECTED_COLOR(pluralize('time', expected))},` + | |
+ ` but it was called ${RECEIVED_COLOR(pluralize('time', count))}.`; | |
+ | |
+ return {message, pass}; | |
}, | |
toHaveBeenCalledWith: createToBeCalledWithMatcher('.toHaveBeenCalledWith'), | |
toHaveBeenLastCalledWith: createLastCalledWithMatcher( | |
- '.toHaveBeenLastCalledWith') }; | |
- | |
- | |
+ '.toHaveBeenLastCalledWith' | |
+ ), | |
+}; | |
const isSpy = spy => spy.calls && typeof spy.calls.count === 'function'; | |
const ensureMock = (mockOrSpy, matcherName) => { | |
if ( | |
- !mockOrSpy || | |
- (mockOrSpy.calls === undefined || mockOrSpy.calls.all === undefined) && | |
- mockOrSpy._isMockFunction !== true) | |
- { | |
+ !mockOrSpy || | |
+ ((mockOrSpy.calls === undefined || mockOrSpy.calls.all === undefined) && | |
+ mockOrSpy._isMockFunction !== true) | |
+ ) { | |
throw new Error( | |
- matcherHint('[.not]' + matcherName, 'jest.fn()', '') + | |
- '\n\n' + | |
- `${RECEIVED_COLOR('jest.fn()')} value must be a mock function ` + | |
- `or spy.\n` + | |
- printWithType('Received', mockOrSpy, printReceived)); | |
- | |
+ matcherHint('[.not]' + matcherName, 'jest.fn()', '') + | |
+ '\n\n' + | |
+ `${RECEIVED_COLOR('jest.fn()')} value must be a mock function ` + | |
+ `or spy.\n` + | |
+ printWithType('Received', mockOrSpy, printReceived) | |
+ ); | |
} | |
}; | |
@@ -181,22 +193,22 @@ const formatReceivedCalls = (calls, limit, options) => { | |
if (calls.length) { | |
const but = options && options.sameSentence ? 'but' : 'But'; | |
const count = calls.length - limit; | |
- const printedCalls = calls. | |
- slice(-limit). | |
- reverse(). | |
- map(printReceived). | |
- join(', '); | |
+ const printedCalls = calls | |
+ .slice(-limit) | |
+ .reverse() | |
+ .map(printReceived) | |
+ .join(', '); | |
return ( | |
`${but} it was ${options && options.isLast ? 'last ' : ''}called ` + | |
`with:\n ` + | |
- printedCalls + ( | |
- count > 0 ? | |
- '\nand ' + RECEIVED_COLOR(pluralize('more call', count)) + '.' : | |
- '')); | |
- | |
+ printedCalls + | |
+ (count > 0 | |
+ ? '\nand ' + RECEIVED_COLOR(pluralize('more call', count)) + '.' | |
+ : '') | |
+ ); | |
} else { | |
return `But it was ${RECEIVED_COLOR('not called')}.`; | |
} | |
}; | |
-module.exports = spyMatchers; | |
\ No newline at end of file | |
+module.exports = spyMatchers; | |
diff --git i/packages/jest-matchers/build/toThrowMatchers.js w/packages/jest-matchers/build/toThrowMatchers.js | |
index 2931acf8..687ec425 100644 | |
--- i/packages/jest-matchers/build/toThrowMatchers.js | |
+++ w/packages/jest-matchers/build/toThrowMatchers.js | |
@@ -9,40 +9,34 @@ | |
*/ | |
/* eslint-disable max-len */ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('jest-regex-util');const escapeStrForRegex = _require.escapeStrForRegex;var _require2 = | |
- | |
- | |
- | |
-require('jest-message-util');const formatStackTrace = _require2.formatStackTrace,separateMessageFromStack = _require2.separateMessageFromStack;var _require3 = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-matcher-utils');const RECEIVED_BG = _require3.RECEIVED_BG,RECEIVED_COLOR = _require3.RECEIVED_COLOR,getType = _require3.getType,highlightTrailingWhitespace = _require3.highlightTrailingWhitespace,matcherHint = _require3.matcherHint,printExpected = _require3.printExpected,printWithType = _require3.printWithType;var _require4 = | |
-require('./jasmine-utils');const equals = _require4.equals; | |
- | |
-const createMatcher = matcherName => ( | |
-actual, | |
-expected) => | |
-{ | |
+'use strict'; | |
+var _require = require('jest-regex-util'); | |
+const escapeStrForRegex = _require.escapeStrForRegex; | |
+var _require2 = require('jest-message-util'); | |
+const formatStackTrace = _require2.formatStackTrace, | |
+ separateMessageFromStack = _require2.separateMessageFromStack; | |
+var _require3 = require('jest-matcher-utils'); | |
+const RECEIVED_BG = _require3.RECEIVED_BG, | |
+ RECEIVED_COLOR = _require3.RECEIVED_COLOR, | |
+ getType = _require3.getType, | |
+ highlightTrailingWhitespace = _require3.highlightTrailingWhitespace, | |
+ matcherHint = _require3.matcherHint, | |
+ printExpected = _require3.printExpected, | |
+ printWithType = _require3.printWithType; | |
+var _require4 = require('./jasmine-utils'); | |
+const equals = _require4.equals; | |
+ | |
+const createMatcher = matcherName => (actual, expected) => { | |
const value = expected; | |
let error; | |
if (typeof actual !== 'function') { | |
throw new Error( | |
- matcherHint(matcherName, 'function', getType(value)) + | |
- '\n\n' + | |
- 'Received value must be a function, but instead ' + | |
- `"${getType(actual)}" was found`); | |
- | |
+ matcherHint(matcherName, 'function', getType(value)) + | |
+ '\n\n' + | |
+ 'Received value must be a function, but instead ' + | |
+ `"${getType(actual)}" was found` | |
+ ); | |
} | |
try { | |
@@ -64,136 +58,125 @@ expected) => | |
} else if (expected === undefined) { | |
const pass = error !== undefined; | |
return { | |
- message: pass ? | |
- () => | |
- matcherHint('.not' + matcherName, 'function', '') + | |
- '\n\n' + | |
- 'Expected the function not to throw an error.\n' + | |
- printActualErrorMessage(error) : | |
- () => | |
- matcherHint(matcherName, 'function', getType(value)) + | |
- '\n\n' + | |
- 'Expected the function to throw an error.\n' + | |
- printActualErrorMessage(error), | |
- pass }; | |
- | |
+ message: pass | |
+ ? () => | |
+ matcherHint('.not' + matcherName, 'function', '') + | |
+ '\n\n' + | |
+ 'Expected the function not to throw an error.\n' + | |
+ printActualErrorMessage(error) | |
+ : () => | |
+ matcherHint(matcherName, 'function', getType(value)) + | |
+ '\n\n' + | |
+ 'Expected the function to throw an error.\n' + | |
+ printActualErrorMessage(error), | |
+ pass, | |
+ }; | |
} else { | |
throw new Error( | |
- matcherHint('.not' + matcherName, 'function', getType(value)) + | |
- '\n\n' + | |
- 'Unexpected argument passed.\nExpected: ' + | |
- `${printExpected('string')}, ${printExpected('Error (type)')} or ${printExpected('regexp')}.\n` + | |
- printWithType('Got', String(expected), printExpected)); | |
- | |
+ matcherHint('.not' + matcherName, 'function', getType(value)) + | |
+ '\n\n' + | |
+ 'Unexpected argument passed.\nExpected: ' + | |
+ `${printExpected('string')}, ${printExpected('Error (type)')} or ${printExpected('regexp')}.\n` + | |
+ printWithType('Got', String(expected), printExpected) | |
+ ); | |
} | |
}; | |
const matchers = { | |
toThrow: createMatcher('.toThrow'), | |
- toThrowError: createMatcher('.toThrowError') }; | |
- | |
+ toThrowError: createMatcher('.toThrowError'), | |
+}; | |
-const toThrowMatchingStringOrRegexp = ( | |
-name, | |
-error, | |
-pattern, | |
-value) => | |
-{ | |
+const toThrowMatchingStringOrRegexp = (name, error, pattern, value) => { | |
if (error && !error.message && !error.name) { | |
error = new Error(error); | |
} | |
const pass = !!(error && error.message.match(pattern)); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + name, 'function', getType(value)) + | |
- '\n\n' + | |
- `Expected the function not to throw an error matching:\n` + | |
- ` ${printExpected(value)}\n` + | |
- printActualErrorMessage(error) : | |
- () => | |
- matcherHint(name, 'function', getType(value)) + | |
- '\n\n' + | |
- `Expected the function to throw an error matching:\n` + | |
- ` ${printExpected(value)}\n` + | |
- printActualErrorMessage(error); | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + name, 'function', getType(value)) + | |
+ '\n\n' + | |
+ `Expected the function not to throw an error matching:\n` + | |
+ ` ${printExpected(value)}\n` + | |
+ printActualErrorMessage(error) | |
+ : () => | |
+ matcherHint(name, 'function', getType(value)) + | |
+ '\n\n' + | |
+ `Expected the function to throw an error matching:\n` + | |
+ ` ${printExpected(value)}\n` + | |
+ printActualErrorMessage(error); | |
+ | |
+ return {message, pass}; | |
}; | |
-const toThrowMatchingErrorInstance = ( | |
-name, | |
-error, | |
-expectedError) => | |
-{ | |
+const toThrowMatchingErrorInstance = (name, error, expectedError) => { | |
if (error && !error.message && !error.name) { | |
error = new Error(error); | |
} | |
const pass = equals(error, expectedError); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + name, 'function', 'error') + | |
- '\n\n' + | |
- `Expected the function not to throw an error matching:\n` + | |
- ` ${printExpected(expectedError)}\n` + | |
- printActualErrorMessage(error) : | |
- () => | |
- matcherHint(name, 'function', 'error') + | |
- '\n\n' + | |
- `Expected the function to throw an error matching:\n` + | |
- ` ${printExpected(expectedError)}\n` + | |
- printActualErrorMessage(error); | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + name, 'function', 'error') + | |
+ '\n\n' + | |
+ `Expected the function not to throw an error matching:\n` + | |
+ ` ${printExpected(expectedError)}\n` + | |
+ printActualErrorMessage(error) | |
+ : () => | |
+ matcherHint(name, 'function', 'error') + | |
+ '\n\n' + | |
+ `Expected the function to throw an error matching:\n` + | |
+ ` ${printExpected(expectedError)}\n` + | |
+ printActualErrorMessage(error); | |
+ | |
+ return {message, pass}; | |
}; | |
-const toThrowMatchingError = ( | |
-name, | |
-error, | |
-ErrorClass) => | |
-{ | |
+const toThrowMatchingError = (name, error, ErrorClass) => { | |
const pass = !!(error && error instanceof ErrorClass); | |
- const message = pass ? | |
- () => | |
- matcherHint('.not' + name, 'function', 'type') + | |
- '\n\n' + | |
- `Expected the function not to throw an error of type:\n` + | |
- ` ${printExpected(ErrorClass.name)}\n` + | |
- printActualErrorMessage(error) : | |
- () => | |
- matcherHint(name, 'function', 'type') + | |
- '\n\n' + | |
- `Expected the function to throw an error of type:\n` + | |
- ` ${printExpected(ErrorClass.name)}\n` + | |
- printActualErrorMessage(error); | |
- | |
- return { message, pass }; | |
+ const message = pass | |
+ ? () => | |
+ matcherHint('.not' + name, 'function', 'type') + | |
+ '\n\n' + | |
+ `Expected the function not to throw an error of type:\n` + | |
+ ` ${printExpected(ErrorClass.name)}\n` + | |
+ printActualErrorMessage(error) | |
+ : () => | |
+ matcherHint(name, 'function', 'type') + | |
+ '\n\n' + | |
+ `Expected the function to throw an error of type:\n` + | |
+ ` ${printExpected(ErrorClass.name)}\n` + | |
+ printActualErrorMessage(error); | |
+ | |
+ return {message, pass}; | |
}; | |
const printActualErrorMessage = error => { | |
- if (error) {var _separateMessageFromS = | |
- separateMessageFromStack(error.stack);const message = _separateMessageFromS.message,stack = _separateMessageFromS.stack; | |
+ if (error) { | |
+ var _separateMessageFromS = separateMessageFromStack(error.stack); | |
+ const message = _separateMessageFromS.message, | |
+ stack = _separateMessageFromS.stack; | |
return ( | |
`Instead, it threw:\n` + | |
RECEIVED_COLOR( | |
- ' ' + | |
- highlightTrailingWhitespace(message, RECEIVED_BG) + | |
- formatStackTrace( | |
- stack, | |
- { | |
- rootDir: process.cwd(), | |
- testMatch: [] }, | |
- | |
- { | |
- noStackTrace: false }))); | |
- | |
- | |
- | |
- | |
+ ' ' + | |
+ highlightTrailingWhitespace(message, RECEIVED_BG) + | |
+ formatStackTrace( | |
+ stack, | |
+ { | |
+ rootDir: process.cwd(), | |
+ testMatch: [], | |
+ }, | |
+ { | |
+ noStackTrace: false, | |
+ } | |
+ ) | |
+ ) | |
+ ); | |
} | |
return `But it didn't throw anything.`; | |
}; | |
-module.exports = matchers; | |
\ No newline at end of file | |
+module.exports = matchers; | |
diff --git i/packages/jest-matchers/build/utils.js w/packages/jest-matchers/build/utils.js | |
index 9d57a094..175db462 100644 | |
--- i/packages/jest-matchers/build/utils.js | |
+++ w/packages/jest-matchers/build/utils.js | |
@@ -10,20 +10,10 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const hasOwnProperty = (object, value) => | |
-Object.prototype.hasOwnProperty.call(object, value); | |
+ Object.prototype.hasOwnProperty.call(object, value); | |
-const getPath = ( | |
-object, | |
-propertyPath) => | |
-{ | |
+const getPath = (object, propertyPath) => { | |
if (!Array.isArray(propertyPath)) { | |
propertyPath = propertyPath.split('.'); | |
} | |
@@ -40,8 +30,8 @@ propertyPath) => | |
return { | |
hasEndProp: false, | |
lastTraversedObject: object, | |
- traversedPath: [] }; | |
- | |
+ traversedPath: [], | |
+ }; | |
} else { | |
const result = getPath(newObject, propertyPath.slice(1)); | |
result.lastTraversedObject || (result.lastTraversedObject = object); | |
@@ -59,8 +49,8 @@ propertyPath) => | |
return { | |
lastTraversedObject: null, | |
traversedPath: [], | |
- value: object }; | |
- | |
+ value: object, | |
+ }; | |
} | |
}; | |
@@ -74,17 +64,17 @@ const getObjectSubset = (object, subset) => { | |
} else if (object instanceof Date) { | |
return object; | |
} else if ( | |
- typeof object === 'object' && | |
- object !== null && | |
- typeof subset === 'object' && | |
- subset !== null) | |
- { | |
+ typeof object === 'object' && | |
+ object !== null && | |
+ typeof subset === 'object' && | |
+ subset !== null | |
+ ) { | |
const trimmed = {}; | |
- Object.keys(subset). | |
- filter(key => object.hasOwnProperty(key)). | |
- forEach( | |
- key => trimmed[key] = getObjectSubset(object[key], subset[key])); | |
- | |
+ Object.keys(subset) | |
+ .filter(key => object.hasOwnProperty(key)) | |
+ .forEach( | |
+ key => (trimmed[key] = getObjectSubset(object[key], subset[key])) | |
+ ); | |
if (Object.keys(trimmed).length > 0) { | |
return trimmed; | |
@@ -96,4 +86,5 @@ const getObjectSubset = (object, subset) => { | |
module.exports = { | |
getObjectSubset, | |
getPath, | |
- hasOwnProperty }; | |
\ No newline at end of file | |
+ hasOwnProperty, | |
+}; | |
diff --git i/packages/jest-message-util/build/index.js w/packages/jest-message-util/build/index.js | |
index 40524937..70a4c194 100644 | |
--- i/packages/jest-message-util/build/index.js | |
+++ w/packages/jest-message-util/build/index.js | |
@@ -10,23 +10,11 @@ | |
'use strict'; | |
- | |
- | |
- | |
const chalk = require('chalk'); | |
const micromatch = require('micromatch'); | |
const path = require('path'); | |
const slash = require('slash'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
// filter for noisy stack trace lines | |
/* eslint-disable max-len */ | |
const JASMINE_IGNORE = /^\s+at(?:(?:.*?vendor\/|jasmine\-)|\s+jasmine\.buildExpectationResult)/; | |
@@ -49,24 +37,19 @@ const trim = string => (string || '').replace(/^\s+/, '').replace(/\s+$/, ''); | |
// want to trim those, because they may have pointers to the column/character | |
// which will get misaligned. | |
const trimPaths = string => | |
-string.match(STACK_PATH_REGEXP) ? trim(string) : string; | |
+ string.match(STACK_PATH_REGEXP) ? trim(string) : string; | |
// ExecError is an error thrown outside of the test suite (not inside an `it` or | |
// `before/after each` hooks). If it's thrown, none of the tests in the file | |
// are executed. | |
-const formatExecError = ( | |
-testResult, | |
-config, | |
-options, | |
-testPath) => | |
-{ | |
+const formatExecError = (testResult, config, options, testPath) => { | |
let error = testResult.testExecError; | |
if (!error || typeof error === 'number') { | |
error = new Error(`Expected an Error, but "${String(error)}" was thrown`); | |
error.stack = ''; | |
- }var _error = | |
- | |
- error;let message = _error.message,stack = _error.stack; | |
+ } | |
+ var _error = error; | |
+ let message = _error.message, stack = _error.stack; | |
if (typeof error === 'string' || !error) { | |
error || (error = 'EMPTY ERROR'); | |
@@ -83,9 +66,9 @@ testPath) => | |
} | |
message = message.split(/\n/).map(line => MESSAGE_INDENT + line).join('\n'); | |
- stack = stack && !options.noStackTrace ? | |
- '\n' + formatStackTrace(stack, config, options, testPath) : | |
- ''; | |
+ stack = stack && !options.noStackTrace | |
+ ? '\n' + formatStackTrace(stack, config, options, testPath) | |
+ : ''; | |
if (message.match(/^\s*$/) && stack.match(/^\s*$/)) { | |
// this can happen if an empty object is thrown. | |
@@ -99,8 +82,8 @@ testPath) => | |
'\n\n' + | |
message + | |
stack + | |
- '\n'); | |
- | |
+ '\n' | |
+ ); | |
}; | |
const removeInternalStackEntries = (lines, options) => { | |
@@ -123,12 +106,7 @@ const removeInternalStackEntries = (lines, options) => { | |
}); | |
}; | |
-const formatPaths = ( | |
-config, | |
-options, | |
-relativeTestPath, | |
-line) => | |
-{ | |
+const formatPaths = (config, options, relativeTestPath, line) => { | |
// Extract the file path from the trace line. | |
const match = line.match(/(^\s*at .*?\(?)([^()]+)(:[0-9]+:[0-9]+\)?.*$)/); | |
if (!match) { | |
@@ -138,42 +116,32 @@ line) => | |
let filePath = slash(path.relative(config.rootDir, match[2])); | |
// highlight paths from the current test file | |
if ( | |
- config.testMatch && | |
- config.testMatch.length && | |
- micromatch(filePath, config.testMatch) || | |
- filePath === relativeTestPath) | |
- { | |
+ (config.testMatch && | |
+ config.testMatch.length && | |
+ micromatch(filePath, config.testMatch)) || | |
+ filePath === relativeTestPath | |
+ ) { | |
filePath = chalk.reset.cyan(filePath); | |
} | |
return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]); | |
}; | |
-const formatStackTrace = ( | |
-stack, | |
-config, | |
-options, | |
-testPath) => | |
-{ | |
+const formatStackTrace = (stack, config, options, testPath) => { | |
let lines = stack.split(/\n/); | |
- const relativeTestPath = testPath ? | |
- slash(path.relative(config.rootDir, testPath)) : | |
- null; | |
+ const relativeTestPath = testPath | |
+ ? slash(path.relative(config.rootDir, testPath)) | |
+ : null; | |
lines = removeInternalStackEntries(lines, options); | |
- return lines. | |
- map(trimPaths). | |
- map(formatPaths.bind(null, config, options, relativeTestPath)). | |
- map(line => STACK_INDENT + line). | |
- join('\n'); | |
+ return lines | |
+ .map(trimPaths) | |
+ .map(formatPaths.bind(null, config, options, relativeTestPath)) | |
+ .map(line => STACK_INDENT + line) | |
+ .join('\n'); | |
}; | |
-const formatResultsErrors = ( | |
-testResults, | |
-config, | |
-options, | |
-testPath) => | |
-{ | |
+const formatResultsErrors = (testResults, config, options, testPath) => { | |
const failedResults = testResults.reduce((errors, result) => { | |
- result.failureMessages.forEach(content => errors.push({ content, result })); | |
+ result.failureMessages.forEach(content => errors.push({content, result})); | |
return errors; | |
}, []); | |
@@ -181,32 +149,35 @@ testPath) => | |
return null; | |
} | |
- return failedResults. | |
- map((_ref) => {let result = _ref.result,content = _ref.content;var _separateMessageFromS = | |
- separateMessageFromStack(content);let message = _separateMessageFromS.message,stack = _separateMessageFromS.stack; | |
- stack = options.noStackTrace ? | |
- '' : | |
- STACK_TRACE_COLOR( | |
- formatStackTrace(stack, config, options, testPath)) + | |
- '\n'; | |
- | |
- message = message. | |
- split(/\n/). | |
- map(line => MESSAGE_INDENT + line). | |
- join('\n'); | |
- | |
- const title = | |
- chalk.bold.red( | |
- TITLE_INDENT + | |
- TITLE_BULLET + | |
- result.ancestorTitles.join(ANCESTRY_SEPARATOR) + ( | |
- result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + | |
- result.title) + | |
- '\n'; | |
- | |
- return title + '\n' + message + '\n' + stack; | |
- }). | |
- join('\n'); | |
+ return failedResults | |
+ .map(_ref => { | |
+ let result = _ref.result, content = _ref.content; | |
+ var _separateMessageFromS = separateMessageFromStack(content); | |
+ let message = _separateMessageFromS.message, | |
+ stack = _separateMessageFromS.stack; | |
+ stack = options.noStackTrace | |
+ ? '' | |
+ : STACK_TRACE_COLOR( | |
+ formatStackTrace(stack, config, options, testPath) | |
+ ) + '\n'; | |
+ | |
+ message = message | |
+ .split(/\n/) | |
+ .map(line => MESSAGE_INDENT + line) | |
+ .join('\n'); | |
+ | |
+ const title = | |
+ chalk.bold.red( | |
+ TITLE_INDENT + | |
+ TITLE_BULLET + | |
+ result.ancestorTitles.join(ANCESTRY_SEPARATOR) + | |
+ (result.ancestorTitles.length ? ANCESTRY_SEPARATOR : '') + | |
+ result.title | |
+ ) + '\n'; | |
+ | |
+ return title + '\n' + message + '\n' + stack; | |
+ }) | |
+ .join('\n'); | |
}; | |
// jasmine and worker farm sometimes don't give us access to the actual | |
@@ -214,7 +185,7 @@ testPath) => | |
// to format it. | |
const separateMessageFromStack = content => { | |
if (!content) { | |
- return { message: '', stack: '' }; | |
+ return {message: '', stack: ''}; | |
} | |
const messageMatch = content.match(/(^(.|\n)*?(?=\n\s*at\s.*\:\d*\:\d*))/); | |
@@ -225,11 +196,12 @@ const separateMessageFromStack = content => { | |
if (message.startsWith(ERROR_TEXT)) { | |
message = message.substr(ERROR_TEXT.length); | |
} | |
- return { message, stack }; | |
+ return {message, stack}; | |
}; | |
module.exports = { | |
formatExecError, | |
formatResultsErrors, | |
formatStackTrace, | |
- separateMessageFromStack }; | |
\ No newline at end of file | |
+ separateMessageFromStack, | |
+}; | |
diff --git i/packages/jest-mock/build/index.js w/packages/jest-mock/build/index.js | |
index c215a67b..0b43ba04 100644 | |
--- i/packages/jest-mock/build/index.js | |
+++ w/packages/jest-mock/build/index.js | |
@@ -10,32 +10,6 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const MOCK_CONSTRUCTOR_NAME = 'mockConstructor'; | |
// $FlowFixMe | |
@@ -87,8 +61,8 @@ const RESERVED_KEYWORDS = Object.assign(Object.create(null), { | |
void: true, | |
while: true, | |
with: true, | |
- yield: true }); | |
- | |
+ yield: true, | |
+}); | |
function isA(typeName, value) { | |
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; | |
@@ -102,11 +76,11 @@ function getType(ref) { | |
} else if (isA('Object', ref)) { | |
return 'object'; | |
} else if ( | |
- isA('Number', ref) || | |
- isA('String', ref) || | |
- isA('Boolean', ref) || | |
- isA('Symbol', ref)) | |
- { | |
+ isA('Number', ref) || | |
+ isA('String', ref) || | |
+ isA('Boolean', ref) || | |
+ isA('Symbol', ref) | |
+ ) { | |
return 'constant'; | |
} else if (isA('Map', ref) || isA('WeakMap', ref) || isA('Set', ref)) { | |
return 'collection'; | |
@@ -123,18 +97,18 @@ function getType(ref) { | |
function isReadonlyProp(object, prop) { | |
return ( | |
- (prop === 'arguments' || | |
- prop === 'caller' || | |
- prop === 'callee' || | |
- prop === 'name' || | |
- prop === 'length') && ( | |
- isA('Function', object) || isA('AsyncFunction', object)) || | |
- (prop === 'source' || | |
- prop === 'global' || | |
- prop === 'ignoreCase' || | |
- prop === 'multiline') && | |
- isA('RegExp', object)); | |
- | |
+ ((prop === 'arguments' || | |
+ prop === 'caller' || | |
+ prop === 'callee' || | |
+ prop === 'name' || | |
+ prop === 'length') && | |
+ (isA('Function', object) || isA('AsyncFunction', object))) || | |
+ ((prop === 'source' || | |
+ prop === 'global' || | |
+ prop === 'ignoreCase' || | |
+ prop === 'multiline') && | |
+ isA('RegExp', object)) | |
+ ); | |
} | |
function getSlots(object) { | |
@@ -164,11 +138,6 @@ function getSlots(object) { | |
} | |
class ModuleMockerClass { | |
- | |
- | |
- | |
- | |
- | |
/** | |
* @see README.md | |
* @param global Global object of the test environment, used to create | |
@@ -205,15 +174,15 @@ class ModuleMockerClass { | |
isReturnValueLastSet: false, | |
mockImpl: undefined, | |
specificMockImpls: [], | |
- specificReturnValues: [] }; | |
- | |
+ specificReturnValues: [], | |
+ }; | |
} | |
_defaultMockState() { | |
return { | |
calls: [], | |
- instances: [] }; | |
- | |
+ instances: [], | |
+ }; | |
} | |
_makeComponent(metadata, restore) { | |
@@ -224,23 +193,23 @@ class ModuleMockerClass { | |
} else if (metadata.type === 'regexp') { | |
return new this._environmentGlobal.RegExp(''); | |
} else if ( | |
- metadata.type === 'constant' || | |
- metadata.type === 'collection' || | |
- metadata.type === 'null' || | |
- metadata.type === 'undefined') | |
- { | |
+ metadata.type === 'constant' || | |
+ metadata.type === 'collection' || | |
+ metadata.type === 'null' || | |
+ metadata.type === 'undefined' | |
+ ) { | |
return metadata.value; | |
} else if (metadata.type === 'function') { | |
/* eslint-disable prefer-const */ | |
let f; | |
/* eslint-enable prefer-const */ | |
- const prototype = metadata.members && | |
- metadata.members.prototype && | |
- metadata.members.prototype.members || {}; | |
+ const prototype = (metadata.members && | |
+ metadata.members.prototype && | |
+ metadata.members.prototype.members) || {}; | |
const prototypeSlots = getSlots(prototype); | |
const mocker = this; | |
- const mockConstructor = function () { | |
+ const mockConstructor = function() { | |
const mockState = mocker._ensureMockState(f); | |
const mockConfig = mocker._ensureMockConfig(f); | |
mockState.instances.push(this); | |
@@ -260,8 +229,8 @@ class ModuleMockerClass { | |
// Run the mock constructor implementation | |
return ( | |
- mockConfig.mockImpl && mockConfig.mockImpl.apply(this, arguments)); | |
- | |
+ mockConfig.mockImpl && mockConfig.mockImpl.apply(this, arguments) | |
+ ); | |
} | |
let returnValue; | |
@@ -311,8 +280,8 @@ class ModuleMockerClass { | |
configurable: false, | |
enumerable: true, | |
get: () => this._ensureMockState(f), | |
- set: val => this._mockState.set(f, val) }); | |
- | |
+ set: val => this._mockState.set(f, val), | |
+ }); | |
f.mockClear = () => { | |
this._mockState.delete(f); | |
@@ -357,9 +326,9 @@ class ModuleMockerClass { | |
}; | |
f.mockReturnThis = () => | |
- f.mockImplementation(function () { | |
- return this; | |
- }); | |
+ f.mockImplementation(function() { | |
+ return this; | |
+ }); | |
if (metadata.mockImpl) { | |
f.mockImplementation(metadata.mockImpl); | |
@@ -374,10 +343,7 @@ class ModuleMockerClass { | |
} | |
} | |
- _createMockFunction( | |
- metadata, | |
- mockConstructor) | |
- { | |
+ _createMockFunction(metadata, mockConstructor) { | |
let name = metadata.name; | |
// Special case functions named `mockConstructor` to guard for infinite | |
// loops. | |
@@ -410,45 +376,42 @@ class ModuleMockerClass { | |
} | |
const body = | |
- 'return function ' + | |
- name + | |
- '() {' + | |
- 'return ' + | |
- MOCK_CONSTRUCTOR_NAME + | |
- '.apply(this,arguments);' + | |
- '}' + | |
- bindCall; | |
+ 'return function ' + | |
+ name + | |
+ '() {' + | |
+ 'return ' + | |
+ MOCK_CONSTRUCTOR_NAME + | |
+ '.apply(this,arguments);' + | |
+ '}' + | |
+ bindCall; | |
const createConstructor = new this._environmentGlobal.Function( | |
- MOCK_CONSTRUCTOR_NAME, | |
- body); | |
+ MOCK_CONSTRUCTOR_NAME, | |
+ body | |
+ ); | |
return createConstructor(mockConstructor); | |
} | |
- _generateMock( | |
- metadata, | |
- callbacks, | |
- refs) | |
- { | |
+ _generateMock(metadata, callbacks, refs) { | |
const mock = this._makeComponent(metadata); | |
if (metadata.refID != null) { | |
refs[metadata.refID] = mock; | |
} | |
getSlots(metadata.members).forEach(slot => { | |
- const slotMetadata = metadata.members && metadata.members[slot] || {}; | |
+ const slotMetadata = (metadata.members && metadata.members[slot]) || {}; | |
if (slotMetadata.ref != null) { | |
- callbacks.push(() => mock[slot] = refs[slotMetadata.ref]); | |
+ callbacks.push(() => (mock[slot] = refs[slotMetadata.ref])); | |
} else { | |
mock[slot] = this._generateMock(slotMetadata, callbacks, refs); | |
} | |
}); | |
if ( | |
- metadata.type !== 'undefined' && | |
- metadata.type !== 'null' && | |
- mock.prototype) | |
- { | |
+ metadata.type !== 'undefined' && | |
+ metadata.type !== 'null' && | |
+ mock.prototype | |
+ ) { | |
mock.prototype.constructor = mock; | |
} | |
@@ -476,7 +439,7 @@ class ModuleMockerClass { | |
const refs = _refs || new Map(); | |
const ref = refs.get(component); | |
if (ref != null) { | |
- return { ref }; | |
+ return {ref}; | |
} | |
const type = getType(component); | |
@@ -484,13 +447,13 @@ class ModuleMockerClass { | |
return null; | |
} | |
- const metadata = { type }; | |
+ const metadata = {type}; | |
if ( | |
- type === 'constant' || | |
- type === 'collection' || | |
- type === 'undefined' || | |
- type === 'null') | |
- { | |
+ type === 'constant' || | |
+ type === 'collection' || | |
+ type === 'undefined' || | |
+ type === 'null' | |
+ ) { | |
metadata.value = component; | |
return metadata; | |
} else if (type === 'function') { | |
@@ -509,18 +472,18 @@ class ModuleMockerClass { | |
if (type !== 'undefined') { | |
getSlots(component).forEach(slot => { | |
if ( | |
- type === 'function' && | |
- component._isMockFunction && | |
- slot.match(/^mock/)) | |
- { | |
+ type === 'function' && | |
+ component._isMockFunction && | |
+ slot.match(/^mock/) | |
+ ) { | |
return; | |
} | |
if ( | |
- !component.hasOwnProperty && component[slot] !== undefined || | |
- component.hasOwnProperty && component.hasOwnProperty(slot) || | |
- type === 'object' && component[slot] != Object.prototype[slot]) | |
- { | |
+ (!component.hasOwnProperty && component[slot] !== undefined) || | |
+ (component.hasOwnProperty && component.hasOwnProperty(slot)) || | |
+ (type === 'object' && component[slot] != Object.prototype[slot]) | |
+ ) { | |
const slotMetadata = this.getMetadata(component[slot], refs); | |
if (slotMetadata) { | |
if (!members) { | |
@@ -556,7 +519,7 @@ class ModuleMockerClass { | |
} | |
fn(implementation) { | |
- const fn = this._makeComponent({ type: 'function' }); | |
+ const fn = this._makeComponent({type: 'function'}); | |
if (implementation) { | |
fn.mockImplementation(implementation); | |
} | |
@@ -569,14 +532,14 @@ class ModuleMockerClass { | |
if (!this.isMockFunction(original)) { | |
if (typeof original !== 'function') { | |
throw new Error( | |
- 'Cannot spyOn the ' + methodName + ' property; it is not a function'); | |
- | |
+ 'Cannot spyOn the ' + methodName + ' property; it is not a function' | |
+ ); | |
} | |
- object[methodName] = this._makeComponent({ type: 'function' }, () => { | |
+ object[methodName] = this._makeComponent({type: 'function'}, () => { | |
object[methodName] = original; | |
}); | |
- object[methodName].mockImplementation(function () { | |
+ object[methodName].mockImplementation(function() { | |
return original.apply(this, arguments); | |
}); | |
} | |
@@ -591,8 +554,7 @@ class ModuleMockerClass { | |
resetAllMocks() { | |
this._mockConfigRegistry = new WeakMap(); | |
this._mockState = new WeakMap(); | |
- }} | |
- | |
- | |
+ } | |
+} | |
-module.exports = new ModuleMockerClass(global); | |
\ No newline at end of file | |
+module.exports = new ModuleMockerClass(global); | |
diff --git i/packages/jest-phabricator/build/index.js w/packages/jest-phabricator/build/index.js | |
index 66420232..3b08fa8e 100644 | |
--- i/packages/jest-phabricator/build/index.js | |
+++ w/packages/jest-phabricator/build/index.js | |
@@ -7,19 +7,9 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-util');const formatTestResults = _require.formatTestResults; | |
+'use strict'; | |
+var _require = require('jest-util'); | |
+const formatTestResults = _require.formatTestResults; | |
function summarize(coverageMap) { | |
const summaries = Object.create(null); | |
@@ -47,7 +37,7 @@ function summarize(coverageMap) { | |
return summaries; | |
} | |
-module.exports = function (results) { | |
+module.exports = function(results) { | |
const coverageMap = results.coverageMap && summarize(results.coverageMap); | |
const formatter = (coverage, reporter) => coverageMap; | |
@@ -72,6 +62,6 @@ module.exports = function (results) { | |
startTime: results.startTime, | |
success: results.success, | |
testResults: results.testResults, | |
- wasInterrupted: results.wasInterrupted }; | |
- | |
-}; | |
\ No newline at end of file | |
+ wasInterrupted: results.wasInterrupted, | |
+ }; | |
+}; | |
diff --git i/packages/jest-regex-util/build/index.js w/packages/jest-regex-util/build/index.js | |
index a4c2ec10..8e7132ca 100644 | |
--- i/packages/jest-regex-util/build/index.js | |
+++ w/packages/jest-regex-util/build/index.js | |
@@ -22,7 +22,7 @@ const escapePathForRegex = dir => { | |
}; | |
const escapeStrForRegex = string => | |
-string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&'); | |
+ string.replace(/[[\]{}()*+?.\\^$|]/g, '\\$&'); | |
const replacePathSepForRegex = string => { | |
if (path.sep === '\\') { | |
@@ -34,4 +34,5 @@ const replacePathSepForRegex = string => { | |
module.exports = { | |
escapePathForRegex, | |
escapeStrForRegex, | |
- replacePathSepForRegex }; | |
\ No newline at end of file | |
+ replacePathSepForRegex, | |
+}; | |
diff --git i/packages/jest-repl/build/cli/args.js w/packages/jest-repl/build/cli/args.js | |
index f663e012..51d08816 100644 | |
--- i/packages/jest-repl/build/cli/args.js | |
+++ w/packages/jest-repl/build/cli/args.js | |
@@ -18,11 +18,12 @@ const options = Object.assign({}, Runtime.getCLIOptions(), { | |
replname: { | |
alias: 'r', | |
description: 'The "name" of the file given to transformers to be ' + | |
- 'transformed. For example, "repl.ts" if using a Typescript transformer.', | |
- type: 'string' } }); | |
- | |
- | |
+ 'transformed. For example, "repl.ts" if using a Typescript transformer.', | |
+ type: 'string', | |
+ }, | |
+}); | |
module.exports = { | |
options, | |
- usage }; | |
\ No newline at end of file | |
+ usage, | |
+}; | |
diff --git i/packages/jest-repl/build/cli/index.js w/packages/jest-repl/build/cli/index.js | |
index eedb84f9..08e6e789 100644 | |
--- i/packages/jest-repl/build/cli/index.js | |
+++ w/packages/jest-repl/build/cli/index.js | |
@@ -16,13 +16,14 @@ const Runtime = require('jest-runtime'); | |
const args = require('./args'); | |
const path = require('path'); | |
-const yargs = require('yargs');var _require = | |
-require('jest-util');const validateCLIOptions = _require.validateCLIOptions; | |
+const yargs = require('yargs'); | |
+var _require = require('jest-util'); | |
+const validateCLIOptions = _require.validateCLIOptions; | |
const REPL_SCRIPT = path.resolve(__dirname, './repl.js'); | |
const VERSION = require('../../package.json').version; | |
-module.exports = function () { | |
+module.exports = function() { | |
const argv = yargs.usage(args.usage).options(args.options).argv; | |
validateCLIOptions(argv, args.options); | |
@@ -30,4 +31,4 @@ module.exports = function () { | |
argv._ = [REPL_SCRIPT]; | |
Runtime.runCLI(argv, [`Jest REPL v${VERSION}`]); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-repl/build/cli/repl.js w/packages/jest-repl/build/cli/repl.js | |
index f9399515..bd36bd23 100644 | |
--- i/packages/jest-repl/build/cli/repl.js | |
+++ w/packages/jest-repl/build/cli/repl.js | |
@@ -11,12 +11,6 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
const path = require('path'); | |
const repl = require('repl'); | |
const vm = require('vm'); | |
@@ -28,10 +22,10 @@ const evalCommand = (cmd, context, filename, callback, config) => { | |
try { | |
if (transformer) { | |
cmd = transformer.process( | |
- cmd, | |
- jestGlobalConfig.replname || 'jest.js', | |
- jestProjectConfig); | |
- | |
+ cmd, | |
+ jestGlobalConfig.replname || 'jest.js', | |
+ jestProjectConfig | |
+ ); | |
} | |
result = vm.runInThisContext(cmd); | |
} catch (e) { | |
@@ -43,12 +37,12 @@ const evalCommand = (cmd, context, filename, callback, config) => { | |
const isRecoverableError = error => { | |
if (error && error.name === 'SyntaxError') { | |
return [ | |
- 'Unterminated template', | |
- 'Missing } in template expression', | |
- 'Unexpected end of input', | |
- 'missing ) after argument list', | |
- 'Unexpected token']. | |
- some(exception => error.message.includes(exception)); | |
+ 'Unterminated template', | |
+ 'Missing } in template expression', | |
+ 'Unexpected end of input', | |
+ 'missing ) after argument list', | |
+ 'Unexpected token', | |
+ ].some(exception => error.message.includes(exception)); | |
} | |
return false; | |
}; | |
@@ -66,8 +60,8 @@ if (jestProjectConfig.transform) { | |
transformer = require(transformerPath); | |
if (typeof transformer.process !== 'function') { | |
throw new TypeError( | |
- 'Jest: a transformer must export a `process` function.'); | |
- | |
+ 'Jest: a transformer must export a `process` function.' | |
+ ); | |
} | |
} | |
} | |
@@ -75,8 +69,8 @@ if (jestProjectConfig.transform) { | |
const replInstance = repl.start({ | |
eval: evalCommand, | |
prompt: '\u203A ', | |
- useGlobal: true }); | |
- | |
+ useGlobal: true, | |
+}); | |
replInstance.context.require = moduleName => { | |
if (/(\/|\\|\.)/.test(moduleName)) { | |
@@ -84,4 +78,4 @@ replInstance.context.require = moduleName => { | |
} | |
/* $FlowFixMe */ | |
return require(moduleName); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-resolve-dependencies/build/index.js w/packages/jest-resolve-dependencies/build/index.js | |
index aa8a3573..689935b2 100644 | |
--- i/packages/jest-resolve-dependencies/build/index.js | |
+++ w/packages/jest-resolve-dependencies/build/index.js | |
@@ -8,22 +8,19 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
-require('jest-regex-util');const replacePathSepForRegex = _require.replacePathSepForRegex; | |
+'use strict'; | |
+var _require = require('jest-regex-util'); | |
+const replacePathSepForRegex = _require.replacePathSepForRegex; | |
const snapshotDirRegex = new RegExp( | |
-replacePathSepForRegex('\/__snapshots__\/')); | |
+ replacePathSepForRegex('\/__snapshots__\/') | |
+); | |
const snapshotFileRegex = new RegExp( | |
-replacePathSepForRegex('__snapshots__\/(.*)\.snap')); | |
+ replacePathSepForRegex('__snapshots__\/(.*)\.snap') | |
+); | |
-const isSnapshotPath = path => | |
-!!path.match(snapshotDirRegex); | |
+const isSnapshotPath = path => !!path.match(snapshotDirRegex); | |
function compact(array) { | |
const result = []; | |
@@ -41,9 +38,6 @@ function compact(array) { | |
* to retrieve a list of all transitive inverse dependencies. | |
*/ | |
class DependencyResolver { | |
- | |
- | |
- | |
constructor(resolver, hasteFS) { | |
this._resolver = resolver; | |
this._hasteFS = hasteFS; | |
@@ -55,42 +49,38 @@ class DependencyResolver { | |
return []; | |
} | |
return compact( | |
- dependencies.map(dependency => { | |
- if (this._resolver.isCoreModule(dependency)) { | |
- return null; | |
- } | |
- try { | |
- return this._resolver.resolveModule(file, dependency, options); | |
- } catch (e) {} | |
- return this._resolver.getMockModule(file, dependency) || null; | |
- })); | |
- | |
+ dependencies.map(dependency => { | |
+ if (this._resolver.isCoreModule(dependency)) { | |
+ return null; | |
+ } | |
+ try { | |
+ return this._resolver.resolveModule(file, dependency, options); | |
+ } catch (e) {} | |
+ return this._resolver.getMockModule(file, dependency) || null; | |
+ }) | |
+ ); | |
} | |
- resolveInverse( | |
- paths, | |
- filter, | |
- options) | |
- { | |
+ resolveInverse(paths, filter, options) { | |
const collectModules = (relatedPaths, moduleMap, changed) => { | |
const visitedModules = new Set(); | |
while (changed.size) { | |
changed = new Set( | |
- moduleMap. | |
- filter( | |
- module => | |
- !visitedModules.has(module.file) && | |
- module.dependencies.some(dep => dep && changed.has(dep))). | |
- | |
- map(module => { | |
- const file = module.file; | |
- if (filter(file)) { | |
- relatedPaths.add(file); | |
- } | |
- visitedModules.add(file); | |
- return module.file; | |
- })); | |
- | |
+ moduleMap | |
+ .filter( | |
+ module => | |
+ !visitedModules.has(module.file) && | |
+ module.dependencies.some(dep => dep && changed.has(dep)) | |
+ ) | |
+ .map(module => { | |
+ const file = module.file; | |
+ if (filter(file)) { | |
+ relatedPaths.add(file); | |
+ } | |
+ visitedModules.add(file); | |
+ return module.file; | |
+ }) | |
+ ); | |
} | |
return relatedPaths; | |
}; | |
@@ -105,9 +95,9 @@ class DependencyResolver { | |
if (this._hasteFS.exists(path)) { | |
// /path/to/__snapshots__/test.js.snap is always adjacent to | |
// /path/to/test.js | |
- const modulePath = isSnapshotPath(path) ? | |
- path.replace(snapshotFileRegex, '$1') : | |
- path; | |
+ const modulePath = isSnapshotPath(path) | |
+ ? path.replace(snapshotFileRegex, '$1') | |
+ : path; | |
changed.add(modulePath); | |
if (filter(modulePath)) { | |
relatedPaths.add(modulePath); | |
@@ -117,10 +107,11 @@ class DependencyResolver { | |
const modules = this._hasteFS.getAllFiles().map(file => ({ | |
dependencies: this.resolve(file, options), | |
- file })); | |
+ file, | |
+ })); | |
return Array.from(collectModules(relatedPaths, modules, changed)); | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = DependencyResolver; | |
\ No newline at end of file | |
+module.exports = DependencyResolver; | |
diff --git i/packages/jest-resolve/build/__mocks__/userResolver.js w/packages/jest-resolve/build/__mocks__/userResolver.js | |
index 35e8699a..de581637 100644 | |
--- i/packages/jest-resolve/build/__mocks__/userResolver.js | |
+++ w/packages/jest-resolve/build/__mocks__/userResolver.js | |
@@ -10,4 +10,4 @@ | |
module.exports = function userResolver(path, options) { | |
return 'module'; | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-resolve/build/defaultResolver.js w/packages/jest-resolve/build/defaultResolver.js | |
index 32f98652..9f6611ce 100644 | |
--- i/packages/jest-resolve/build/defaultResolver.js | |
+++ w/packages/jest-resolve/build/defaultResolver.js | |
@@ -10,19 +10,9 @@ | |
'use strict'; | |
- | |
- | |
const resolve = require('resolve'); | |
const browserResolve = require('browser-resolve'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
function defaultResolver(path, options) { | |
const resv = options.browser ? browserResolve : resolve; | |
@@ -30,8 +20,8 @@ function defaultResolver(path, options) { | |
basedir: options.basedir, | |
extensions: options.extensions, | |
moduleDirectory: options.moduleDirectory, | |
- paths: options.paths }); | |
- | |
+ paths: options.paths, | |
+ }); | |
} | |
-module.exports = defaultResolver; | |
\ No newline at end of file | |
+module.exports = defaultResolver; | |
diff --git i/packages/jest-resolve/build/index.js w/packages/jest-resolve/build/index.js | |
index e3dda786..72244e5f 100644 | |
--- i/packages/jest-resolve/build/index.js | |
+++ w/packages/jest-resolve/build/index.js | |
@@ -10,71 +10,31 @@ | |
'use strict'; | |
- | |
- | |
- | |
const nodeModulesPaths = require('resolve/lib/node-modules-paths'); | |
const path = require('path'); | |
const isBuiltinModule = require('is-builtin-module'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const NATIVE_PLATFORM = 'native'; | |
-const nodePaths = process.env.NODE_PATH ? | |
-process.env.NODE_PATH.split(path.delimiter) : | |
-null; | |
+const nodePaths = process.env.NODE_PATH | |
+ ? process.env.NODE_PATH.split(path.delimiter) | |
+ : null; | |
class Resolver { | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor(moduleMap, options) { | |
this._options = { | |
browser: options.browser, | |
defaultPlatform: options.defaultPlatform, | |
extensions: options.extensions, | |
- hasCoreModules: options.hasCoreModules === undefined ? | |
- true : | |
- options.hasCoreModules, | |
+ hasCoreModules: options.hasCoreModules === undefined | |
+ ? true | |
+ : options.hasCoreModules, | |
moduleDirectories: options.moduleDirectories || ['node_modules'], | |
moduleNameMapper: options.moduleNameMapper, | |
modulePaths: options.modulePaths, | |
platforms: options.platforms, | |
- resolver: options.resolver }; | |
+ resolver: options.resolver, | |
+ }; | |
this._moduleMap = moduleMap; | |
this._moduleIDCache = Object.create(null); | |
@@ -93,17 +53,13 @@ class Resolver { | |
browser: options.browser, | |
extensions: options.extensions, | |
moduleDirectory: options.moduleDirectory, | |
- paths: paths ? (nodePaths || []).concat(paths) : nodePaths }); | |
- | |
+ paths: paths ? (nodePaths || []).concat(paths) : nodePaths, | |
+ }); | |
} catch (e) {} | |
return null; | |
} | |
- resolveModule( | |
- from, | |
- moduleName, | |
- options) | |
- { | |
+ resolveModule(from, moduleName, options) { | |
const dirname = path.dirname(from); | |
const paths = this._options.modulePaths; | |
const moduleDirectory = this._options.moduleDirectories; | |
@@ -126,7 +82,7 @@ class Resolver { | |
// 1. Check if the module is a haste module. | |
let module = this.getModule(moduleName); | |
if (module) { | |
- return this._moduleNameCache[key] = module; | |
+ return (this._moduleNameCache[key] = module); | |
} | |
// 2. Check if the module is a node module and resolve it based on | |
@@ -136,7 +92,7 @@ class Resolver { | |
// up resolution when we build a dependency graph because we don't have | |
// to look at modules that may not exist and aren't mocked. | |
const skipResolution = | |
- options && options.skipNodeResolution && !moduleName.includes(path.sep); | |
+ options && options.skipNodeResolution && !moduleName.includes(path.sep); | |
if (!skipResolution) { | |
module = Resolver.findNodeModule(moduleName, { | |
@@ -145,11 +101,11 @@ class Resolver { | |
extensions, | |
moduleDirectory, | |
paths, | |
- resolver: this._options.resolver }); | |
- | |
+ resolver: this._options.resolver, | |
+ }); | |
if (module) { | |
- return this._moduleNameCache[key] = module; | |
+ return (this._moduleNameCache[key] = module); | |
} | |
} | |
@@ -159,9 +115,9 @@ class Resolver { | |
module = this.getPackage(parts.shift()); | |
if (module) { | |
try { | |
- return this._moduleNameCache[key] = require.resolve( | |
- path.join.apply(path, [path.dirname(module)].concat(parts))); | |
- | |
+ return (this._moduleNameCache[key] = require.resolve( | |
+ path.join.apply(path, [path.dirname(module)].concat(parts)) | |
+ )); | |
} catch (ignoredError) {} | |
} | |
@@ -170,7 +126,8 @@ class Resolver { | |
// current module name available. | |
const relativePath = path.relative(dirname, from); | |
const err = new Error( | |
- `Cannot find module '${moduleName}' from '${relativePath || '.'}'`); | |
+ `Cannot find module '${moduleName}' from '${relativePath || '.'}'` | |
+ ); | |
err.code = 'MODULE_NOT_FOUND'; | |
throw err; | |
@@ -182,10 +139,10 @@ class Resolver { | |
getModule(name) { | |
return this._moduleMap.getModule( | |
- name, | |
- this._options.defaultPlatform, | |
- this._supportsNativePlatform()); | |
- | |
+ name, | |
+ this._options.defaultPlatform, | |
+ this._supportsNativePlatform() | |
+ ); | |
} | |
getModulePath(from, moduleName) { | |
@@ -197,10 +154,10 @@ class Resolver { | |
getPackage(name) { | |
return this._moduleMap.getPackage( | |
- name, | |
- this._options.defaultPlatform, | |
- this._supportsNativePlatform()); | |
- | |
+ name, | |
+ this._options.defaultPlatform, | |
+ this._supportsNativePlatform() | |
+ ); | |
} | |
getMockModule(from, name) { | |
@@ -219,7 +176,7 @@ class Resolver { | |
getModulePaths(from) { | |
if (!this._modulePathCache[from]) { | |
const moduleDirectory = this._options.moduleDirectories; | |
- const paths = nodeModulesPaths(from, { moduleDirectory }); | |
+ const paths = nodeModulesPaths(from, {moduleDirectory}); | |
if (paths[paths.length - 1] === undefined) { | |
// circumvent node-resolve bug that adds `undefined` as last item. | |
paths.pop(); | |
@@ -229,11 +186,7 @@ class Resolver { | |
return this._modulePathCache[from]; | |
} | |
- getModuleID( | |
- virtualMocks, | |
- from, | |
- _moduleName) | |
- { | |
+ getModuleID(virtualMocks, from, _moduleName) { | |
const moduleName = _moduleName || ''; | |
const key = from + path.delimiter + moduleName; | |
@@ -247,51 +200,43 @@ class Resolver { | |
const sep = path.delimiter; | |
const id = | |
- moduleType + | |
- sep + ( | |
- absolutePath ? absolutePath + sep : '') + ( | |
- mockPath ? mockPath + sep : ''); | |
+ moduleType + | |
+ sep + | |
+ (absolutePath ? absolutePath + sep : '') + | |
+ (mockPath ? mockPath + sep : ''); | |
- return this._moduleIDCache[key] = id; | |
+ return (this._moduleIDCache[key] = id); | |
} | |
_getModuleType(moduleName) { | |
return this.isCoreModule(moduleName) ? 'node' : 'user'; | |
} | |
- _getAbsolutPath( | |
- virtualMocks, | |
- from, | |
- moduleName) | |
- { | |
+ _getAbsolutPath(virtualMocks, from, moduleName) { | |
if (this.isCoreModule(moduleName)) { | |
return moduleName; | |
} | |
- return this._isModuleResolved(from, moduleName) ? | |
- this.getModule(moduleName) : | |
- this._getVirtualMockPath(virtualMocks, from, moduleName); | |
+ return this._isModuleResolved(from, moduleName) | |
+ ? this.getModule(moduleName) | |
+ : this._getVirtualMockPath(virtualMocks, from, moduleName); | |
} | |
_getMockPath(from, moduleName) { | |
- return !this.isCoreModule(moduleName) ? | |
- this.getMockModule(from, moduleName) : | |
- null; | |
+ return !this.isCoreModule(moduleName) | |
+ ? this.getMockModule(from, moduleName) | |
+ : null; | |
} | |
- _getVirtualMockPath( | |
- virtualMocks, | |
- from, | |
- moduleName) | |
- { | |
+ _getVirtualMockPath(virtualMocks, from, moduleName) { | |
const virtualMockPath = this.getModulePath(from, moduleName); | |
- return virtualMocks[virtualMockPath] ? | |
- virtualMockPath : | |
- moduleName ? this.resolveModule(from, moduleName) : from; | |
+ return virtualMocks[virtualMockPath] | |
+ ? virtualMockPath | |
+ : moduleName ? this.resolveModule(from, moduleName) : from; | |
} | |
_isModuleResolved(from, moduleName) { | |
return !!(this.getModule(moduleName) || | |
- this.getMockModule(from, moduleName)); | |
+ this.getMockModule(from, moduleName)); | |
} | |
_resolveStubModuleName(from, moduleName) { | |
@@ -302,16 +247,18 @@ class Resolver { | |
const moduleNameMapper = this._options.moduleNameMapper; | |
if (moduleNameMapper) { | |
- for (const _ref of moduleNameMapper) {const mappedModuleName = _ref.moduleName;const regex = _ref.regex; | |
+ for (const _ref of moduleNameMapper) { | |
+ const mappedModuleName = _ref.moduleName; | |
+ const regex = _ref.regex; | |
if (regex.test(moduleName)) { | |
const matches = moduleName.match(regex); | |
if (!matches) { | |
moduleName = mappedModuleName; | |
} else { | |
moduleName = mappedModuleName.replace( | |
- /\$([0-9]+)/g, | |
- (_, index) => matches[parseInt(index, 10)]); | |
- | |
+ /\$([0-9]+)/g, | |
+ (_, index) => matches[parseInt(index, 10)] | |
+ ); | |
} | |
return ( | |
this.getModule(moduleName) || | |
@@ -320,9 +267,9 @@ class Resolver { | |
browser: this._options.browser, | |
extensions, | |
moduleDirectory, | |
- paths })); | |
- | |
- | |
+ paths, | |
+ }) | |
+ ); | |
} | |
} | |
} | |
@@ -331,7 +278,7 @@ class Resolver { | |
_supportsNativePlatform() { | |
return (this._options.platforms || []).indexOf(NATIVE_PLATFORM) !== -1; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = Resolver; | |
\ No newline at end of file | |
+module.exports = Resolver; | |
diff --git i/packages/jest-runtime/build/ScriptTransformer.js w/packages/jest-runtime/build/ScriptTransformer.js | |
index af7d148f..c16db3f0 100644 | |
--- i/packages/jest-runtime/build/ScriptTransformer.js | |
+++ w/packages/jest-runtime/build/ScriptTransformer.js | |
@@ -9,13 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const createDirectory = require('jest-util').createDirectory; | |
const crypto = require('crypto'); | |
const fs = require('graceful-fs'); | |
@@ -28,35 +21,18 @@ const slash = require('slash'); | |
const VERSION = require('../package.json').version; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const cache = new Map(); | |
const configToJsonMap = new Map(); | |
// Cache regular expressions to test whether the file needs to be preprocessed | |
const ignoreCache = new WeakMap(); | |
class ScriptTransformer { | |
- | |
- | |
- | |
- | |
constructor(config) { | |
this._config = config; | |
this._transformCache = new Map(); | |
} | |
- _getCacheKey( | |
- fileData, | |
- filename, | |
- instrument, | |
- mapCoverage) | |
- { | |
+ _getCacheKey(fileData, filename, instrument, mapCoverage) { | |
if (!configToJsonMap.has(this._config)) { | |
// We only need this set of config options that can likely influence | |
// cached output instead of all config options. | |
@@ -67,44 +43,42 @@ class ScriptTransformer { | |
if (transformer && typeof transformer.getCacheKey === 'function') { | |
return transformer.getCacheKey(fileData, filename, configString, { | |
- instrument }); | |
- | |
+ instrument, | |
+ }); | |
} else { | |
- return crypto. | |
- createHash('md5'). | |
- update(fileData). | |
- update(configString). | |
- update(instrument ? 'instrument' : ''). | |
- update(mapCoverage ? 'mapCoverage' : ''). | |
- digest('hex'); | |
+ return crypto | |
+ .createHash('md5') | |
+ .update(fileData) | |
+ .update(configString) | |
+ .update(instrument ? 'instrument' : '') | |
+ .update(mapCoverage ? 'mapCoverage' : '') | |
+ .digest('hex'); | |
} | |
} | |
- _getFileCachePath( | |
- filename, | |
- content, | |
- instrument, | |
- mapCoverage) | |
- { | |
+ _getFileCachePath(filename, content, instrument, mapCoverage) { | |
const baseCacheDir = getCacheFilePath( | |
- this._config.cacheDirectory, | |
- 'jest-transform-cache-' + this._config.name, | |
- VERSION); | |
+ this._config.cacheDirectory, | |
+ 'jest-transform-cache-' + this._config.name, | |
+ VERSION | |
+ ); | |
const cacheKey = this._getCacheKey( | |
- content, | |
- filename, | |
- instrument, | |
- mapCoverage); | |
+ content, | |
+ filename, | |
+ instrument, | |
+ mapCoverage | |
+ ); | |
// Create sub folders based on the cacheKey to avoid creating one | |
// directory with many files. | |
const cacheDir = path.join(baseCacheDir, cacheKey[0] + cacheKey[1]); | |
const cachePath = slash( | |
- path.join( | |
- cacheDir, | |
- path.basename(filename, path.extname(filename)) + '_' + cacheKey)); | |
- | |
+ path.join( | |
+ cacheDir, | |
+ path.basename(filename, path.extname(filename)) + '_' + cacheKey | |
+ ) | |
+ ); | |
createDirectory(cacheDir); | |
@@ -137,8 +111,8 @@ class ScriptTransformer { | |
transform = require(transformPath); | |
if (typeof transform.process !== 'function') { | |
throw new TypeError( | |
- 'Jest: a transform must export a `process` function.'); | |
- | |
+ 'Jest: a transform must export a `process` function.' | |
+ ); | |
} | |
if (typeof transform.createTransformer === 'function') { | |
transform = transform.createTransformer(); | |
@@ -159,55 +133,52 @@ class ScriptTransformer { | |
babelrc: false, | |
filename, | |
plugins: [ | |
- [ | |
- babelPluginIstanbul, | |
- { | |
- // files outside `cwd` will not be instrumented | |
- cwd: this._config.rootDir, | |
- exclude: [], | |
- useInlineSourceMaps: false }]], | |
- | |
- | |
- | |
- retainLines: true }). | |
- code; | |
+ [ | |
+ babelPluginIstanbul, | |
+ { | |
+ // files outside `cwd` will not be instrumented | |
+ cwd: this._config.rootDir, | |
+ exclude: [], | |
+ useInlineSourceMaps: false, | |
+ }, | |
+ ], | |
+ ], | |
+ | |
+ retainLines: true, | |
+ }).code; | |
} | |
- transformSource( | |
- filename, | |
- content, | |
- instrument, | |
- mapCoverage) | |
- { | |
+ transformSource(filename, content, instrument, mapCoverage) { | |
const transform = this._getTransformer(filename); | |
const cacheFilePath = this._getFileCachePath( | |
- filename, | |
- content, | |
- instrument, | |
- mapCoverage); | |
+ filename, | |
+ content, | |
+ instrument, | |
+ mapCoverage | |
+ ); | |
let sourceMapPath = cacheFilePath + '.map'; | |
// Ignore cache if `config.cache` is set (--no-cache) | |
- let code = this._config.cache ? | |
- readCacheFile(filename, cacheFilePath) : | |
- null; | |
+ let code = this._config.cache | |
+ ? readCacheFile(filename, cacheFilePath) | |
+ : null; | |
if (code) { | |
return { | |
code, | |
- sourceMapPath }; | |
- | |
+ sourceMapPath, | |
+ }; | |
} | |
let transformed = { | |
code: content, | |
- map: null }; | |
- | |
+ map: null, | |
+ }; | |
if (transform && shouldTransform(filename, this._config)) { | |
const processed = transform.process(content, filename, this._config, { | |
- instrument }); | |
- | |
+ instrument, | |
+ }); | |
if (typeof processed === 'string') { | |
transformed.code = processed; | |
@@ -239,9 +210,9 @@ class ScriptTransformer { | |
} | |
if (instrument && transformed.map && mapCoverage) { | |
- const sourceMapContent = typeof transformed.map === 'string' ? | |
- transformed.map : | |
- JSON.stringify(transformed.map); | |
+ const sourceMapContent = typeof transformed.map === 'string' | |
+ ? transformed.map | |
+ : JSON.stringify(transformed.map); | |
writeCacheFile(sourceMapPath, sourceMapContent); | |
} else { | |
sourceMapPath = null; | |
@@ -251,34 +222,30 @@ class ScriptTransformer { | |
return { | |
code, | |
- sourceMapPath }; | |
- | |
+ sourceMapPath, | |
+ }; | |
} | |
- _transformAndBuildScript( | |
- filename, | |
- options, | |
- instrument, | |
- fileSource) | |
- { | |
+ _transformAndBuildScript(filename, options, instrument, fileSource) { | |
const isInternalModule = !!(options && options.isInternalModule); | |
const content = stripShebang( | |
- fileSource || fs.readFileSync(filename, 'utf8')); | |
+ fileSource || fs.readFileSync(filename, 'utf8') | |
+ ); | |
let wrappedCode; | |
let sourceMapPath = null; | |
const willTransform = | |
- !isInternalModule && ( | |
- shouldTransform(filename, this._config) || instrument); | |
+ !isInternalModule && | |
+ (shouldTransform(filename, this._config) || instrument); | |
try { | |
if (willTransform) { | |
const transformedSource = this.transformSource( | |
- filename, | |
- content, | |
- instrument, | |
- !!(options && options.mapCoverage)); | |
- | |
+ filename, | |
+ content, | |
+ instrument, | |
+ !!(options && options.mapCoverage) | |
+ ); | |
wrappedCode = wrap(transformedSource.code); | |
sourceMapPath = transformedSource.sourceMapPath; | |
@@ -287,9 +254,9 @@ class ScriptTransformer { | |
} | |
return { | |
- script: new vm.Script(wrappedCode, { displayErrors: true, filename }), | |
- sourceMapPath }; | |
- | |
+ script: new vm.Script(wrappedCode, {displayErrors: true, filename}), | |
+ sourceMapPath, | |
+ }; | |
} catch (e) { | |
if (e.codeFrame) { | |
e.stack = e.codeFrame; | |
@@ -299,32 +266,30 @@ class ScriptTransformer { | |
} | |
} | |
- transform( | |
- filename, | |
- options, | |
- fileSource) | |
- { | |
+ transform(filename, options, fileSource) { | |
const instrument = shouldInstrument(filename, options, this._config); | |
const scriptCacheKey = getScriptCacheKey( | |
- filename, | |
- this._config, | |
- instrument); | |
+ filename, | |
+ this._config, | |
+ instrument | |
+ ); | |
let result = cache.get(scriptCacheKey); | |
if (result) { | |
return result; | |
} else { | |
result = this._transformAndBuildScript( | |
- filename, | |
- options, | |
- instrument, | |
- fileSource); | |
+ filename, | |
+ options, | |
+ instrument, | |
+ fileSource | |
+ ); | |
cache.set(scriptCacheKey, result); | |
return result; | |
} | |
- }} | |
- | |
+ } | |
+} | |
const removeFile = path => { | |
try { | |
@@ -347,10 +312,10 @@ const writeCacheFile = (cachePath, fileData) => { | |
fs.writeFileSync(cachePath, fileData, 'utf8'); | |
} catch (e) { | |
e.message = | |
- 'jest: failed to cache transform results in: ' + | |
- cachePath + | |
- '\nFailure message: ' + | |
- e.message; | |
+ 'jest: failed to cache transform results in: ' + | |
+ cachePath + | |
+ '\nFailure message: ' + | |
+ e.message; | |
removeFile(cachePath); | |
throw e; | |
} | |
@@ -389,9 +354,9 @@ const shouldTransform = (filename, config) => { | |
ignoreCache.set(config, null); | |
} else { | |
ignoreCache.set( | |
- config, | |
- new RegExp(config.transformIgnorePatterns.join('|'))); | |
- | |
+ config, | |
+ new RegExp(config.transformIgnorePatterns.join('|')) | |
+ ); | |
} | |
} | |
@@ -399,18 +364,18 @@ const shouldTransform = (filename, config) => { | |
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false; | |
return ( | |
!!config.transform && | |
- !!config.transform.length && ( | |
- !config.transformIgnorePatterns.length || !isIgnored)); | |
- | |
+ !!config.transform.length && | |
+ (!config.transformIgnorePatterns.length || !isIgnored) | |
+ ); | |
}; | |
const wrap = content => | |
-'({"' + | |
-ScriptTransformer.EVAL_RESULT_VARIABLE + | |
-'":function(module,exports,require,__dirname,__filename,global,jest){' + | |
-content + | |
-'\n}});'; | |
+ '({"' + | |
+ ScriptTransformer.EVAL_RESULT_VARIABLE + | |
+ '":function(module,exports,require,__dirname,__filename,global,jest){' + | |
+ content + | |
+ '\n}});'; | |
ScriptTransformer.EVAL_RESULT_VARIABLE = 'Object.<anonymous>'; | |
-module.exports = ScriptTransformer; | |
\ No newline at end of file | |
+module.exports = ScriptTransformer; | |
diff --git i/packages/jest-runtime/build/__mocks__/createRuntime.js w/packages/jest-runtime/build/__mocks__/createRuntime.js | |
index bee2e6cd..ff461782 100644 | |
--- i/packages/jest-runtime/build/__mocks__/createRuntime.js | |
+++ w/packages/jest-runtime/build/__mocks__/createRuntime.js | |
@@ -10,39 +10,40 @@ const path = require('path'); | |
module.exports = function createRuntime(filename, config) { | |
const NodeEnvironment = require('jest-environment-node'); | |
- const Runtime = require('../');var _require = | |
- | |
- require('jest-config');const normalize = _require.normalize; | |
+ const Runtime = require('../'); | |
+ var _require = require('jest-config'); | |
+ const normalize = _require.normalize; | |
config = normalize( | |
- Object.assign( | |
- { | |
- name: 'Runtime-' + filename.replace(/\W/, '-') + '-tests', | |
- rootDir: path.resolve(path.dirname(filename), 'test_root') }, | |
- | |
- config), | |
- | |
- {}). | |
- options; | |
+ Object.assign( | |
+ { | |
+ name: 'Runtime-' + filename.replace(/\W/, '-') + '-tests', | |
+ rootDir: path.resolve(path.dirname(filename), 'test_root'), | |
+ }, | |
+ config | |
+ ), | |
+ {} | |
+ ).options; | |
const environment = new NodeEnvironment(config); | |
environment.global.console = console; | |
- return Runtime.createHasteMap(config, { maxWorkers: 1, resetCache: false }). | |
- build(). | |
- then(hasteMap => { | |
- const runtime = new Runtime( | |
- config, | |
- environment, | |
- Runtime.createResolver(config, hasteMap.moduleMap)); | |
- | |
- | |
- runtime.__mockRootPath = path.join(config.rootDir, 'root.js'); | |
- runtime.__mockSubdirPath = path.join( | |
- config.rootDir, | |
- 'subdir2', | |
- 'module_dir', | |
- 'moduleDirModule.js'); | |
- | |
- return runtime; | |
- }); | |
-}; | |
\ No newline at end of file | |
+ return Runtime.createHasteMap(config, {maxWorkers: 1, resetCache: false}) | |
+ .build() | |
+ .then(hasteMap => { | |
+ const runtime = new Runtime( | |
+ config, | |
+ environment, | |
+ Runtime.createResolver(config, hasteMap.moduleMap) | |
+ ); | |
+ | |
+ runtime.__mockRootPath = path.join(config.rootDir, 'root.js'); | |
+ runtime.__mockSubdirPath = path.join( | |
+ config.rootDir, | |
+ 'subdir2', | |
+ 'module_dir', | |
+ 'moduleDirModule.js' | |
+ ); | |
+ | |
+ return runtime; | |
+ }); | |
+}; | |
diff --git i/packages/jest-runtime/build/cli/args.js w/packages/jest-runtime/build/cli/args.js | |
index 37465c58..4a0ed3b8 100644 | |
--- i/packages/jest-runtime/build/cli/args.js | |
+++ w/packages/jest-runtime/build/cli/args.js | |
@@ -16,31 +16,36 @@ const options = { | |
cache: { | |
default: true, | |
description: 'Whether to use the preprocessor cache. Disable ' + | |
- 'the cache using --no-cache.', | |
- type: 'boolean' }, | |
+ 'the cache using --no-cache.', | |
+ type: 'boolean', | |
+ }, | |
config: { | |
alias: 'c', | |
description: 'The path to a Jest config file.', | |
- type: 'string' }, | |
+ type: 'string', | |
+ }, | |
debug: { | |
description: 'Print debugging info about your jest config.', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
version: { | |
alias: 'v', | |
description: 'Print the version and exit', | |
- type: 'boolean' }, | |
+ type: 'boolean', | |
+ }, | |
watchman: { | |
default: true, | |
description: 'Whether to use watchman for file crawling. Disable using ' + | |
- '--no-watchman.', | |
- type: 'boolean' } }; | |
- | |
- | |
+ '--no-watchman.', | |
+ type: 'boolean', | |
+ }, | |
+}; | |
module.exports = { | |
options, | |
- usage }; | |
\ No newline at end of file | |
+ usage, | |
+}; | |
diff --git i/packages/jest-runtime/build/cli/index.js w/packages/jest-runtime/build/cli/index.js | |
index 9b9cbe2b..0a3cd125 100644 | |
--- i/packages/jest-runtime/build/cli/index.js | |
+++ w/packages/jest-runtime/build/cli/index.js | |
@@ -10,16 +10,15 @@ | |
'use strict'; | |
- | |
- | |
- | |
const args = require('./args'); | |
const chalk = require('chalk'); | |
const os = require('os'); | |
const path = require('path'); | |
-const yargs = require('yargs');var _require = | |
- | |
-require('jest-util');const Console = _require.Console,setGlobal = _require.setGlobal,validateCLIOptions = _require.validateCLIOptions; | |
+const yargs = require('yargs'); | |
+var _require = require('jest-util'); | |
+const Console = _require.Console, | |
+ setGlobal = _require.setGlobal, | |
+ validateCLIOptions = _require.validateCLIOptions; | |
const readConfig = require('jest-config').readConfig; | |
const Runtime = require('../'); | |
@@ -64,31 +63,33 @@ function run(cliArgv, cliInfo) { | |
// Always disable automocking in scripts. | |
const config = Object.assign({}, options.config, { | |
automock: false, | |
- unmockedModulePathPatterns: null }); | |
+ unmockedModulePathPatterns: null, | |
+ }); | |
Runtime.createContext(config, { | |
maxWorkers: os.cpus().length - 1, | |
- watchman: globalConfig.watchman }). | |
- | |
- then(hasteMap => { | |
- /* $FlowFixMe */ | |
- const Environment = require(config.testEnvironment); | |
- const environment = new Environment(config); | |
- setGlobal( | |
- environment.global, | |
- 'console', | |
- new Console(process.stdout, process.stderr)); | |
- | |
- environment.global.jestProjectConfig = config; | |
- environment.global.jestGlobalConfig = globalConfig; | |
- | |
- const runtime = new Runtime(config, environment, hasteMap.resolver); | |
- runtime.requireModule(filePath); | |
- }). | |
- catch(e => { | |
- console.error(chalk.red(e)); | |
- process.on('exit', () => process.exit(1)); | |
- }); | |
+ watchman: globalConfig.watchman, | |
+ }) | |
+ .then(hasteMap => { | |
+ /* $FlowFixMe */ | |
+ const Environment = require(config.testEnvironment); | |
+ const environment = new Environment(config); | |
+ setGlobal( | |
+ environment.global, | |
+ 'console', | |
+ new Console(process.stdout, process.stderr) | |
+ ); | |
+ | |
+ environment.global.jestProjectConfig = config; | |
+ environment.global.jestGlobalConfig = globalConfig; | |
+ | |
+ const runtime = new Runtime(config, environment, hasteMap.resolver); | |
+ runtime.requireModule(filePath); | |
+ }) | |
+ .catch(e => { | |
+ console.error(chalk.red(e)); | |
+ process.on('exit', () => process.exit(1)); | |
+ }); | |
} | |
-exports.run = run; | |
\ No newline at end of file | |
+exports.run = run; | |
diff --git i/packages/jest-runtime/build/index.js w/packages/jest-runtime/build/index.js | |
index 1f662c8c..dc32bb51 100644 | |
--- i/packages/jest-runtime/build/index.js | |
+++ w/packages/jest-runtime/build/index.js | |
@@ -8,69 +8,71 @@ | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
const HasteMap = require('jest-haste-map'); | |
const Resolver = require('jest-resolve'); | |
-const ScriptTransformer = require('./ScriptTransformer');var _require = | |
- | |
-require('jest-util');const createDirectory = _require.createDirectory;var _require2 = | |
-require('jest-regex-util');const escapePathForRegex = _require2.escapePathForRegex; | |
+const ScriptTransformer = require('./ScriptTransformer'); | |
+var _require = require('jest-util'); | |
+const createDirectory = _require.createDirectory; | |
+var _require2 = require('jest-regex-util'); | |
+const escapePathForRegex = _require2.escapePathForRegex; | |
const fs = require('graceful-fs'); | |
const path = require('path'); | |
const shouldInstrument = require('./shouldInstrument'); | |
const stripBOM = require('strip-bom'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const NODE_MODULES = path.sep + 'node_modules' + path.sep; | |
const SNAPSHOT_EXTENSION = 'snap'; | |
const getModuleNameMapper = config => { | |
if ( | |
- Array.isArray(config.moduleNameMapper) && | |
- config.moduleNameMapper.length) | |
- { | |
- return config.moduleNameMapper.map((_ref) => {var _ref2 = _slicedToArray(_ref, 2);let regex = _ref2[0],moduleName = _ref2[1]; | |
- return { moduleName, regex: new RegExp(regex) }; | |
+ Array.isArray(config.moduleNameMapper) && | |
+ config.moduleNameMapper.length | |
+ ) { | |
+ return config.moduleNameMapper.map(_ref => { | |
+ var _ref2 = _slicedToArray(_ref, 2); | |
+ let regex = _ref2[0], moduleName = _ref2[1]; | |
+ return {moduleName, regex: new RegExp(regex)}; | |
}); | |
} | |
return null; | |
@@ -79,51 +81,21 @@ const getModuleNameMapper = config => { | |
const mockParentModule = { | |
exports: {}, | |
filename: 'mock.js', | |
- id: 'mockParent' }; | |
- | |
+ id: 'mockParent', | |
+}; | |
const unmockRegExpCache = new WeakMap(); | |
class Runtime { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- constructor( | |
- config, | |
- environment, | |
- resolver, | |
- cacheFS, | |
- coverageOptions) | |
- { | |
+ constructor(config, environment, resolver, cacheFS, coverageOptions) { | |
this._cacheFS = cacheFS || Object.create(null); | |
this._config = config; | |
this._coverageOptions = coverageOptions || { | |
collectCoverage: false, | |
collectCoverageFrom: [], | |
collectCoverageOnlyFrom: null, | |
- mapCoverage: false }; | |
+ mapCoverage: false, | |
+ }; | |
this._currentlyExecutingModulePath = ''; | |
this._environment = environment; | |
@@ -147,12 +119,13 @@ class Runtime { | |
this._unmockList = unmockRegExpCache.get(config); | |
if ( | |
- !this._unmockList && | |
- config.automock && | |
- config.unmockedModulePathPatterns) | |
- { | |
+ !this._unmockList && | |
+ config.automock && | |
+ config.unmockedModulePathPatterns | |
+ ) { | |
this._unmockList = new RegExp( | |
- config.unmockedModulePathPatterns.join('|')); | |
+ config.unmockedModulePathPatterns.join('|') | |
+ ); | |
unmockRegExpCache.set(config, this._unmockList); | |
} | |
@@ -161,8 +134,9 @@ class Runtime { | |
config.setupFiles.forEach(filePath => { | |
if (filePath && filePath.includes(NODE_MODULES)) { | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- filePath); | |
+ this._virtualMocks, | |
+ filePath | |
+ ); | |
this._transitiveShouldMock[moduleID] = false; | |
} | |
@@ -178,60 +152,46 @@ class Runtime { | |
} | |
} | |
- static shouldInstrument( | |
- filename, | |
- options, | |
- config) | |
- { | |
+ static shouldInstrument(filename, options, config) { | |
return shouldInstrument( | |
- filename, | |
- { | |
- collectCoverage: options.collectCoverage, | |
- collectCoverageFrom: options.collectCoverageFrom, | |
- collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, | |
- mapCoverage: options.mapCoverage }, | |
- | |
- config); | |
- | |
+ filename, | |
+ { | |
+ collectCoverage: options.collectCoverage, | |
+ collectCoverageFrom: options.collectCoverageFrom, | |
+ collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, | |
+ mapCoverage: options.mapCoverage, | |
+ }, | |
+ config | |
+ ); | |
} | |
- static createContext( | |
- config, | |
- options) | |
- | |
- | |
- | |
- | |
- | |
- { | |
+ static createContext(config, options) { | |
createDirectory(config.cacheDirectory); | |
const instance = Runtime.createHasteMap(config, { | |
console: options.console, | |
maxWorkers: options.maxWorkers, | |
resetCache: !config.cache, | |
watch: options.watch, | |
- watchman: options.watchman }); | |
- | |
- return instance.build().then( | |
- hasteMap => ({ | |
- config, | |
- hasteFS: hasteMap.hasteFS, | |
- moduleMap: hasteMap.moduleMap, | |
- resolver: Runtime.createResolver(config, hasteMap.moduleMap) }), | |
- | |
- error => { | |
- throw error; | |
+ watchman: options.watchman, | |
}); | |
+ return instance.build().then( | |
+ hasteMap => ({ | |
+ config, | |
+ hasteFS: hasteMap.hasteFS, | |
+ moduleMap: hasteMap.moduleMap, | |
+ resolver: Runtime.createResolver(config, hasteMap.moduleMap), | |
+ }), | |
+ error => { | |
+ throw error; | |
+ } | |
+ ); | |
} | |
- static createHasteMap( | |
- config, | |
- options) | |
- { | |
+ static createHasteMap(config, options) { | |
const ignorePattern = new RegExp( | |
- [config.cacheDirectory].concat(config.modulePathIgnorePatterns).join('|')); | |
- | |
+ [config.cacheDirectory].concat(config.modulePathIgnorePatterns).join('|') | |
+ ); | |
return new HasteMap({ | |
cacheDirectory: config.cacheDirectory, | |
@@ -239,7 +199,7 @@ class Runtime { | |
extensions: [SNAPSHOT_EXTENSION].concat(config.moduleFileExtensions), | |
hasteImplModulePath: config.haste.hasteImplModulePath, | |
ignorePattern, | |
- maxWorkers: options && options.maxWorkers || 1, | |
+ maxWorkers: (options && options.maxWorkers) || 1, | |
mocksPattern: escapePathForRegex(path.sep + '__mocks__' + path.sep), | |
name: config.name, | |
platforms: config.haste.platforms || ['ios', 'android'], | |
@@ -248,8 +208,8 @@ class Runtime { | |
retainAllFiles: false, | |
roots: config.roots, | |
useWatchman: options && options.watchman, | |
- watch: options && options.watch }); | |
- | |
+ watch: options && options.watch, | |
+ }); | |
} | |
static createResolver(config, moduleMap) { | |
@@ -262,8 +222,8 @@ class Runtime { | |
moduleNameMapper: getModuleNameMapper(config), | |
modulePaths: config.modulePaths, | |
platforms: config.haste.platforms, | |
- resolver: config.resolver }); | |
- | |
+ resolver: config.resolver, | |
+ }); | |
} | |
static runCLI(args, info) { | |
@@ -274,34 +234,31 @@ class Runtime { | |
return require('./cli/args').options; | |
} | |
- requireModule( | |
- from, | |
- moduleName, | |
- options) | |
- { | |
+ requireModule(from, moduleName, options) { | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
let modulePath; | |
- const moduleRegistry = !options || !options.isInternalModule ? | |
- this._moduleRegistry : | |
- this._internalModuleRegistry; | |
+ const moduleRegistry = !options || !options.isInternalModule | |
+ ? this._moduleRegistry | |
+ : this._internalModuleRegistry; | |
// Some old tests rely on this mocking behavior. Ideally we'll change this | |
// to be more explicit. | |
const moduleResource = moduleName && this._resolver.getModule(moduleName); | |
const manualMock = | |
- moduleName && this._resolver.getMockModule(from, moduleName); | |
+ moduleName && this._resolver.getMockModule(from, moduleName); | |
if ( | |
- (!options || !options.isInternalModule) && | |
- !moduleResource && | |
- manualMock && | |
- manualMock !== this._isCurrentlyExecutingManualMock && | |
- this._explicitShouldMock[moduleID] !== false) | |
- { | |
+ (!options || !options.isInternalModule) && | |
+ !moduleResource && | |
+ manualMock && | |
+ manualMock !== this._isCurrentlyExecutingManualMock && | |
+ this._explicitShouldMock[moduleID] !== false | |
+ ) { | |
modulePath = manualMock; | |
} | |
@@ -321,13 +278,14 @@ class Runtime { | |
const localModule = { | |
exports: {}, | |
filename: modulePath, | |
- id: modulePath }; | |
+ id: modulePath, | |
+ }; | |
moduleRegistry[modulePath] = localModule; | |
if (path.extname(modulePath) === '.json') { | |
localModule.exports = this._environment.global.JSON.parse( | |
- stripBOM(fs.readFileSync(modulePath, 'utf8'))); | |
- | |
+ stripBOM(fs.readFileSync(modulePath, 'utf8')) | |
+ ); | |
} else if (path.extname(modulePath) === '.node') { | |
// $FlowFixMe | |
localModule.exports = require(modulePath); | |
@@ -339,22 +297,22 @@ class Runtime { | |
} | |
requireInternalModule(from, to) { | |
- return this.requireModule(from, to, { isInternalModule: true }); | |
+ return this.requireModule(from, to, {isInternalModule: true}); | |
} | |
requireMock(from, moduleName) { | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
- | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
if (this._mockRegistry[moduleID]) { | |
return this._mockRegistry[moduleID]; | |
} | |
if (moduleID in this._mockFactories) { | |
- return this._mockRegistry[moduleID] = this._mockFactories[moduleID](); | |
+ return (this._mockRegistry[moduleID] = this._mockFactories[moduleID]()); | |
} | |
let manualMock = this._resolver.getMockModule(from, moduleName); | |
@@ -378,9 +336,10 @@ class Runtime { | |
const moduleDir = path.dirname(modulePath); | |
const moduleFileName = path.basename(modulePath); | |
const potentialManualMock = path.join( | |
- moduleDir, | |
- '__mocks__', | |
- moduleFileName); | |
+ moduleDir, | |
+ '__mocks__', | |
+ moduleFileName | |
+ ); | |
if (fs.existsSync(potentialManualMock)) { | |
manualMock = true; | |
@@ -392,7 +351,8 @@ class Runtime { | |
const localModule = { | |
exports: {}, | |
filename: modulePath, | |
- id: modulePath }; | |
+ id: modulePath, | |
+ }; | |
this._execModule(localModule); | |
this._mockRegistry[moduleID] = localModule.exports; | |
@@ -421,9 +381,9 @@ class Runtime { | |
Object.keys(envGlobal).forEach(key => { | |
const globalMock = envGlobal[key]; | |
if ( | |
- typeof globalMock === 'object' && globalMock !== null || | |
- typeof globalMock === 'function') | |
- { | |
+ (typeof globalMock === 'object' && globalMock !== null) || | |
+ typeof globalMock === 'function' | |
+ ) { | |
globalMock._isMockFunction && globalMock.mockClear(); | |
} | |
}); | |
@@ -447,20 +407,16 @@ class Runtime { | |
}, {}); | |
} | |
- setMock( | |
- from, | |
- moduleName, | |
- mockFactory, | |
- options) | |
- { | |
+ setMock(from, moduleName, mockFactory, options) { | |
if (options && options.virtual) { | |
const mockPath = this._resolver.getModulePath(from, moduleName); | |
this._virtualMocks[mockPath] = true; | |
} | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
this._explicitShouldMock[moduleID] = true; | |
this._mockFactories[moduleID] = mockFactory; | |
@@ -498,34 +454,35 @@ class Runtime { | |
localModule.require = this._createRequireImplementation(filename, options); | |
const transformedFile = this._scriptTransformer.transform( | |
- filename, | |
- { | |
- collectCoverage: this._coverageOptions.collectCoverage, | |
- collectCoverageFrom: this._coverageOptions.collectCoverageFrom, | |
- collectCoverageOnlyFrom: this._coverageOptions.collectCoverageOnlyFrom, | |
- isInternalModule, | |
- mapCoverage: this._coverageOptions.mapCoverage }, | |
- | |
- this._cacheFS[filename]); | |
- | |
+ filename, | |
+ { | |
+ collectCoverage: this._coverageOptions.collectCoverage, | |
+ collectCoverageFrom: this._coverageOptions.collectCoverageFrom, | |
+ collectCoverageOnlyFrom: this._coverageOptions.collectCoverageOnlyFrom, | |
+ isInternalModule, | |
+ mapCoverage: this._coverageOptions.mapCoverage, | |
+ }, | |
+ this._cacheFS[filename] | |
+ ); | |
if (transformedFile.sourceMapPath) { | |
this._sourceMapRegistry[filename] = transformedFile.sourceMapPath; | |
} | |
const wrapper = this._environment.runScript(transformedFile.script)[ | |
- ScriptTransformer.EVAL_RESULT_VARIABLE]; | |
+ ScriptTransformer.EVAL_RESULT_VARIABLE | |
+ ]; | |
wrapper.call( | |
- localModule.exports, // module context | |
- localModule, // module object | |
- localModule.exports, // module exports | |
- localModule.require, // require implementation | |
- dirname, // __dirname | |
- filename, // __filename | |
- this._environment.global, // global object | |
- this._createRuntimeFor(filename)); | |
- | |
+ localModule.exports, // module context | |
+ localModule, // module object | |
+ localModule.exports, // module exports | |
+ localModule.require, // require implementation | |
+ dirname, // __dirname | |
+ filename, // __filename | |
+ this._environment.global, // global object | |
+ this._createRuntimeFor(filename) | |
+ ); | |
this._isCurrentlyExecutingManualMock = origCurrExecutingManualMock; | |
this._currentlyExecutingModulePath = lastExecutingModulePath; | |
@@ -537,9 +494,7 @@ class Runtime { | |
if (!(modulePath in this._mockMetaDataCache)) { | |
// This allows us to handle circular dependencies while generating an | |
// automock | |
- this._mockMetaDataCache[modulePath] = this._moduleMocker.getMetadata( | |
- {}); | |
- | |
+ this._mockMetaDataCache[modulePath] = this._moduleMocker.getMetadata({}); | |
// In order to avoid it being possible for automocking to potentially | |
// cause side-effects within the module environment, we need to execute | |
@@ -559,15 +514,15 @@ class Runtime { | |
const mockMetadata = this._moduleMocker.getMetadata(moduleExports); | |
if (mockMetadata == null) { | |
throw new Error( | |
- `Failed to get mock metadata: ${modulePath}\n\n` + | |
- `See: http://facebook.github.io/jest/docs/manual-mocks.html#content`); | |
- | |
+ `Failed to get mock metadata: ${modulePath}\n\n` + | |
+ `See: http://facebook.github.io/jest/docs/manual-mocks.html#content` | |
+ ); | |
} | |
this._mockMetaDataCache[modulePath] = mockMetadata; | |
} | |
return this._moduleMocker.generateFromMetadata( | |
- this._mockMetaDataCache[modulePath]); | |
- | |
+ this._mockMetaDataCache[modulePath] | |
+ ); | |
} | |
_shouldMock(from, moduleName) { | |
@@ -578,9 +533,10 @@ class Runtime { | |
const explicitShouldMock = this._explicitShouldMock; | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
const key = from + path.delimiter + moduleID; | |
@@ -589,10 +545,10 @@ class Runtime { | |
} | |
if ( | |
- !this._shouldAutoMock || | |
- this._resolver.isCoreModule(moduleName) || | |
- this._shouldUnmockTransitiveDependenciesCache[key]) | |
- { | |
+ !this._shouldAutoMock || | |
+ this._resolver.isCoreModule(moduleName) || | |
+ this._shouldUnmockTransitiveDependenciesCache[key] | |
+ ) { | |
return false; | |
} | |
@@ -619,28 +575,29 @@ class Runtime { | |
// transitive unmocking for package managers that store flat packages (npm3) | |
const currentModuleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from); | |
+ this._virtualMocks, | |
+ from | |
+ ); | |
if ( | |
- this._transitiveShouldMock[currentModuleID] === false || | |
- from.includes(NODE_MODULES) && | |
- modulePath.includes(NODE_MODULES) && ( | |
- this._unmockList && this._unmockList.test(from) || | |
- explicitShouldMock[currentModuleID] === false)) | |
- { | |
+ this._transitiveShouldMock[currentModuleID] === false || | |
+ (from.includes(NODE_MODULES) && | |
+ modulePath.includes(NODE_MODULES) && | |
+ ((this._unmockList && this._unmockList.test(from)) || | |
+ explicitShouldMock[currentModuleID] === false)) | |
+ ) { | |
this._transitiveShouldMock[moduleID] = false; | |
this._shouldUnmockTransitiveDependenciesCache[key] = true; | |
return false; | |
} | |
- return this._shouldMockModuleCache[moduleID] = true; | |
+ return (this._shouldMockModuleCache[moduleID] = true); | |
} | |
_createRequireImplementation(from, options) { | |
- const moduleRequire = options && options.isInternalModule ? | |
- moduleName => this.requireInternalModule(from, moduleName) : | |
- this.requireModuleOrMock.bind(this, from); | |
+ const moduleRequire = options && options.isInternalModule | |
+ ? moduleName => this.requireInternalModule(from, moduleName) | |
+ : this.requireModuleOrMock.bind(this, from); | |
moduleRequire.cache = Object.create(null); | |
moduleRequire.extensions = Object.create(null); | |
moduleRequire.requireActual = this.requireModule.bind(this, from); | |
@@ -660,36 +617,35 @@ class Runtime { | |
}; | |
const unmock = moduleName => { | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
this._explicitShouldMock[moduleID] = false; | |
return runtime; | |
}; | |
const deepUnmock = moduleName => { | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
this._explicitShouldMock[moduleID] = false; | |
this._transitiveShouldMock[moduleID] = false; | |
return runtime; | |
}; | |
- const mock = ( | |
- moduleName, | |
- mockFactory, | |
- options) => | |
- { | |
+ const mock = (moduleName, mockFactory, options) => { | |
if (mockFactory !== undefined) { | |
return setMockFactory(moduleName, mockFactory, options); | |
} | |
const moduleID = this._resolver.getModuleID( | |
- this._virtualMocks, | |
- from, | |
- moduleName); | |
+ this._virtualMocks, | |
+ from, | |
+ moduleName | |
+ ); | |
this._explicitShouldMock[moduleID] = true; | |
return runtime; | |
@@ -723,7 +679,7 @@ class Runtime { | |
const runtime = { | |
addMatchers: matchers => | |
- this._environment.global.jasmine.addMatchers(matchers), | |
+ this._environment.global.jasmine.addMatchers(matchers), | |
autoMockOff: disableAutomock, | |
autoMockOn: enableAutomock, | |
@@ -736,8 +692,7 @@ class Runtime { | |
enableAutomock, | |
fn, | |
genMockFn: fn, | |
- genMockFromModule: moduleName => | |
- this._generateMock(from, moduleName), | |
+ genMockFromModule: moduleName => this._generateMock(from, moduleName), | |
genMockFunction: fn, | |
isMockFunction: this._moduleMocker.isMockFunction, | |
@@ -750,22 +705,22 @@ class Runtime { | |
runAllTicks: () => this._environment.fakeTimers.runAllTicks(), | |
runAllTimers: () => this._environment.fakeTimers.runAllTimers(), | |
runOnlyPendingTimers: () => | |
- this._environment.fakeTimers.runOnlyPendingTimers(), | |
+ this._environment.fakeTimers.runOnlyPendingTimers(), | |
runTimersToTime: msToRun => | |
- this._environment.fakeTimers.runTimersToTime(msToRun), | |
+ this._environment.fakeTimers.runTimersToTime(msToRun), | |
- setMock: (moduleName, mock) => | |
- setMockFactory(moduleName, () => mock), | |
+ setMock: (moduleName, mock) => setMockFactory(moduleName, () => mock), | |
spyOn, | |
unmock, | |
useFakeTimers, | |
- useRealTimers }; | |
+ useRealTimers, | |
+ }; | |
return runtime; | |
- }} | |
- | |
+ } | |
+} | |
Runtime.ScriptTransformer = ScriptTransformer; | |
-module.exports = Runtime; | |
\ No newline at end of file | |
+module.exports = Runtime; | |
diff --git i/packages/jest-runtime/build/shouldInstrument.js w/packages/jest-runtime/build/shouldInstrument.js | |
index 3c8beba3..6a1d3106 100644 | |
--- i/packages/jest-runtime/build/shouldInstrument.js | |
+++ w/packages/jest-runtime/build/shouldInstrument.js | |
@@ -7,24 +7,17 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
-require('jest-regex-util');const escapePathForRegex = _require.escapePathForRegex; | |
+'use strict'; | |
+var _require = require('jest-regex-util'); | |
+const escapePathForRegex = _require.escapePathForRegex; | |
const micromatch = require('micromatch'); | |
const path = require('path'); | |
const MOCKS_PATTERN = new RegExp( | |
-escapePathForRegex(path.sep + '__mocks__' + path.sep)); | |
- | |
+ escapePathForRegex(path.sep + '__mocks__' + path.sep) | |
+); | |
-const shouldInstrument = ( | |
-filename, | |
-options, | |
-config) => | |
-{ | |
+const shouldInstrument = (filename, options, config) => { | |
if (!options.collectCoverage) { | |
return false; | |
} | |
@@ -34,38 +27,38 @@ config) => | |
} | |
if ( | |
- config.testMatch && | |
- config.testMatch.length && | |
- micromatch.any(filename, config.testMatch)) | |
- { | |
+ config.testMatch && | |
+ config.testMatch.length && | |
+ micromatch.any(filename, config.testMatch) | |
+ ) { | |
return false; | |
} | |
if ( | |
- // This configuration field contains an object in the form of: | |
- // {'path/to/file.js': true} | |
- options.collectCoverageOnlyFrom && | |
- !options.collectCoverageOnlyFrom[filename]) | |
- { | |
+ // This configuration field contains an object in the form of: | |
+ // {'path/to/file.js': true} | |
+ options.collectCoverageOnlyFrom && | |
+ !options.collectCoverageOnlyFrom[filename] | |
+ ) { | |
return false; | |
} | |
if ( | |
- // still cover if `only` is specified | |
- !options.collectCoverageOnlyFrom && | |
- options.collectCoverageFrom && | |
- !micromatch( | |
- [path.relative(config.rootDir, filename)], | |
- options.collectCoverageFrom). | |
- length) | |
- { | |
+ // still cover if `only` is specified | |
+ !options.collectCoverageOnlyFrom && | |
+ options.collectCoverageFrom && | |
+ !micromatch( | |
+ [path.relative(config.rootDir, filename)], | |
+ options.collectCoverageFrom | |
+ ).length | |
+ ) { | |
return false; | |
} | |
if ( | |
- config.coveragePathIgnorePatterns && | |
- config.coveragePathIgnorePatterns.some(pattern => filename.match(pattern))) | |
- { | |
+ config.coveragePathIgnorePatterns && | |
+ config.coveragePathIgnorePatterns.some(pattern => filename.match(pattern)) | |
+ ) { | |
return false; | |
} | |
@@ -76,4 +69,4 @@ config) => | |
return true; | |
}; | |
-module.exports = shouldInstrument; | |
\ No newline at end of file | |
+module.exports = shouldInstrument; | |
diff --git i/packages/jest-snapshot/build/State.js w/packages/jest-snapshot/build/State.js | |
index b4f3d10c..35c0b791 100644 | |
--- i/packages/jest-snapshot/build/State.js | |
+++ w/packages/jest-snapshot/build/State.js | |
@@ -8,46 +8,25 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('./utils');const saveSnapshotFile = _require.saveSnapshotFile,getSnapshotData = _require.getSnapshotData,getSnapshotPath = _require.getSnapshotPath,keyToTestName = _require.keyToTestName,serialize = _require.serialize,testNameToKey = _require.testNameToKey,unescape = _require.unescape; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const saveSnapshotFile = _require.saveSnapshotFile, | |
+ getSnapshotData = _require.getSnapshotData, | |
+ getSnapshotPath = _require.getSnapshotPath, | |
+ keyToTestName = _require.keyToTestName, | |
+ serialize = _require.serialize, | |
+ testNameToKey = _require.testNameToKey, | |
+ unescape = _require.unescape; | |
const fs = require('fs'); | |
- | |
- | |
- | |
- | |
- | |
- | |
class SnapshotState { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
constructor(testPath, options) { | |
- this._snapshotPath = options.snapshotPath || getSnapshotPath(testPath);var _getSnapshotData = | |
- getSnapshotData( | |
- this._snapshotPath, | |
- options.updateSnapshot);const data = _getSnapshotData.data,dirty = _getSnapshotData.dirty; | |
+ this._snapshotPath = options.snapshotPath || getSnapshotPath(testPath); | |
+ var _getSnapshotData = getSnapshotData( | |
+ this._snapshotPath, | |
+ options.updateSnapshot | |
+ ); | |
+ const data = _getSnapshotData.data, dirty = _getSnapshotData.dirty; | |
this._snapshotData = data; | |
this._dirty = dirty; | |
@@ -79,8 +58,8 @@ class SnapshotState { | |
const isEmpty = Object.keys(this._snapshotData).length === 0; | |
const status = { | |
deleted: false, | |
- saved: false }; | |
- | |
+ saved: false, | |
+ }; | |
if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) { | |
saveSnapshotFile(this._snapshotData, this._snapshotPath); | |
@@ -140,10 +119,10 @@ class SnapshotState { | |
// * The update flag is set to 'none'. | |
// * There's no snapshot file or a file without this snapshot on a CI environment. | |
if ( | |
- hasSnapshot && this._updateSnapshot === 'all' || | |
- (!hasSnapshot || !fs.existsSync(this._snapshotPath)) && ( | |
- this._updateSnapshot === 'new' || this._updateSnapshot === 'all')) | |
- { | |
+ (hasSnapshot && this._updateSnapshot === 'all') || | |
+ ((!hasSnapshot || !fs.existsSync(this._snapshotPath)) && | |
+ (this._updateSnapshot === 'new' || this._updateSnapshot === 'all')) | |
+ ) { | |
if (this._updateSnapshot === 'all') { | |
if (!pass) { | |
if (hasSnapshot) { | |
@@ -164,8 +143,8 @@ class SnapshotState { | |
actual: '', | |
count, | |
expected: '', | |
- pass: true }; | |
- | |
+ pass: true, | |
+ }; | |
} else { | |
if (!pass) { | |
this.unmatched++; | |
@@ -173,19 +152,19 @@ class SnapshotState { | |
actual: unescape(receivedSerialized), | |
count, | |
expected: expected ? unescape(expected) : null, | |
- pass: false }; | |
- | |
+ pass: false, | |
+ }; | |
} else { | |
this.matched++; | |
return { | |
actual: '', | |
count, | |
expected: '', | |
- pass: true }; | |
- | |
+ pass: true, | |
+ }; | |
} | |
} | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = SnapshotState; | |
\ No newline at end of file | |
+module.exports = SnapshotState; | |
diff --git i/packages/jest-snapshot/build/index.js w/packages/jest-snapshot/build/index.js | |
index 30e0f672..e8075d24 100644 | |
--- i/packages/jest-snapshot/build/index.js | |
+++ w/packages/jest-snapshot/build/index.js | |
@@ -9,57 +9,55 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
- | |
const diff = require('jest-diff'); | |
const fs = require('fs'); | |
const path = require('path'); | |
-const SnapshotState = require('./State');var _require = | |
-require('./plugins');const addSerializer = _require.addSerializer,getSerializers = _require.getSerializers;var _require2 = | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('jest-matcher-utils');const EXPECTED_COLOR = _require2.EXPECTED_COLOR,ensureNoExpected = _require2.ensureNoExpected,matcherHint = _require2.matcherHint,RECEIVED_COLOR = _require2.RECEIVED_COLOR;var _require3 = | |
-require('./utils');const SNAPSHOT_EXTENSION = _require3.SNAPSHOT_EXTENSION; | |
+const SnapshotState = require('./State'); | |
+var _require = require('./plugins'); | |
+const addSerializer = _require.addSerializer, | |
+ getSerializers = _require.getSerializers; | |
+var _require2 = require('jest-matcher-utils'); | |
+const EXPECTED_COLOR = _require2.EXPECTED_COLOR, | |
+ ensureNoExpected = _require2.ensureNoExpected, | |
+ matcherHint = _require2.matcherHint, | |
+ RECEIVED_COLOR = _require2.RECEIVED_COLOR; | |
+var _require3 = require('./utils'); | |
+const SNAPSHOT_EXTENSION = _require3.SNAPSHOT_EXTENSION; | |
const fileExists = (filePath, hasteFS) => | |
-hasteFS.exists(filePath) || fs.existsSync(filePath); | |
+ hasteFS.exists(filePath) || fs.existsSync(filePath); | |
const cleanup = (hasteFS, update) => { | |
const pattern = '\\.' + SNAPSHOT_EXTENSION + '$'; | |
const files = hasteFS.matchFiles(pattern); | |
- const filesRemoved = files. | |
- filter( | |
- snapshotFile => | |
- !fileExists( | |
- path.resolve( | |
- path.dirname(snapshotFile), | |
- '..', | |
- path.basename(snapshotFile, '.' + SNAPSHOT_EXTENSION)), | |
- | |
- hasteFS)). | |
- | |
- | |
- map(snapshotFile => { | |
- if (update === 'all') { | |
- fs.unlinkSync(snapshotFile); | |
- } | |
- }).length; | |
+ const filesRemoved = files | |
+ .filter( | |
+ snapshotFile => | |
+ !fileExists( | |
+ path.resolve( | |
+ path.dirname(snapshotFile), | |
+ '..', | |
+ path.basename(snapshotFile, '.' + SNAPSHOT_EXTENSION) | |
+ ), | |
+ hasteFS | |
+ ) | |
+ ) | |
+ .map(snapshotFile => { | |
+ if (update === 'all') { | |
+ fs.unlinkSync(snapshotFile); | |
+ } | |
+ }).length; | |
return { | |
- filesRemoved }; | |
- | |
+ filesRemoved, | |
+ }; | |
}; | |
-const toMatchSnapshot = function (received, testName) { | |
- this.dontThrow && this.dontThrow();const | |
- | |
- currentTestName = this.currentTestName,isNot = this.isNot,snapshotState = this.snapshotState; | |
+const toMatchSnapshot = function(received, testName) { | |
+ this.dontThrow && this.dontThrow(); | |
+ const currentTestName = this.currentTestName, | |
+ isNot = this.isNot, | |
+ snapshotState = this.snapshotState; | |
if (isNot) { | |
throw new Error('Jest: `.not` cannot be used with `.toMatchSnapshot()`.'); | |
@@ -70,37 +68,37 @@ const toMatchSnapshot = function (received, testName) { | |
} | |
const result = snapshotState.match( | |
- testName || currentTestName || '', | |
- received);const | |
- | |
- count = result.count,pass = result.pass;let | |
- actual = result.actual,expected = result.expected; | |
+ testName || currentTestName || '', | |
+ received | |
+ ); | |
+ const count = result.count, pass = result.pass; | |
+ let actual = result.actual, expected = result.expected; | |
let report; | |
if (pass) { | |
- return { message: '', pass: true }; | |
+ return {message: '', pass: true}; | |
} else if (!expected) { | |
report = () => | |
- `New snapshot was ${RECEIVED_COLOR('not written')}. The update flag ` + | |
- `must be explicitly passed to write a new snapshot.\n\n` + | |
- `This is likely because this test is run in a continuous integration ` + | |
- `(CI) environment in which snapshots are not written by default.`; | |
+ `New snapshot was ${RECEIVED_COLOR('not written')}. The update flag ` + | |
+ `must be explicitly passed to write a new snapshot.\n\n` + | |
+ `This is likely because this test is run in a continuous integration ` + | |
+ `(CI) environment in which snapshots are not written by default.`; | |
} else { | |
expected = (expected || '').trim(); | |
actual = (actual || '').trim(); | |
const diffMessage = diff(expected, actual, { | |
aAnnotation: 'Snapshot', | |
bAnnotation: 'Received', | |
- expand: snapshotState.expand }); | |
- | |
+ expand: snapshotState.expand, | |
+ }); | |
report = () => | |
- `${RECEIVED_COLOR('Received value')} does not match ` + | |
- `${EXPECTED_COLOR('stored snapshot ' + count)}.\n\n` + ( | |
- diffMessage || | |
- RECEIVED_COLOR('- ' + (expected || '')) + | |
- '\n' + | |
- EXPECTED_COLOR('+ ' + actual)); | |
+ `${RECEIVED_COLOR('Received value')} does not match ` + | |
+ `${EXPECTED_COLOR('stored snapshot ' + count)}.\n\n` + | |
+ (diffMessage || | |
+ RECEIVED_COLOR('- ' + (expected || '')) + | |
+ '\n' + | |
+ EXPECTED_COLOR('+ ' + actual)); | |
} | |
// Passing the the actual and expected objects so that a custom reporter | |
// could access them, for example in order to display a custom visual diff, | |
@@ -109,21 +107,21 @@ const toMatchSnapshot = function (received, testName) { | |
actual, | |
expected, | |
message: () => | |
- matcherHint('.toMatchSnapshot', 'value', '') + '\n\n' + report(), | |
+ matcherHint('.toMatchSnapshot', 'value', '') + '\n\n' + report(), | |
name: 'toMatchSnapshot', | |
pass: false, | |
- report }; | |
- | |
+ report, | |
+ }; | |
}; | |
-const toThrowErrorMatchingSnapshot = function (received, expected) { | |
- this.dontThrow && this.dontThrow();const | |
- isNot = this.isNot; | |
+const toThrowErrorMatchingSnapshot = function(received, expected) { | |
+ this.dontThrow && this.dontThrow(); | |
+ const isNot = this.isNot; | |
if (isNot) { | |
throw new Error( | |
- 'Jest: `.not` cannot be used with `.toThrowErrorMatchingSnapshot()`.'); | |
- | |
+ 'Jest: `.not` cannot be used with `.toThrowErrorMatchingSnapshot()`.' | |
+ ); | |
} | |
ensureNoExpected(expected, '.toThrowErrorMatchingSnapshot'); | |
@@ -138,11 +136,11 @@ const toThrowErrorMatchingSnapshot = function (received, expected) { | |
if (error === undefined) { | |
throw new Error( | |
- matcherHint('.toThrowErrorMatchingSnapshot', '() => {}', '') + | |
- '\n\n' + | |
- `Expected the function to throw an error.\n` + | |
- `But it didn't throw anything.`); | |
- | |
+ matcherHint('.toThrowErrorMatchingSnapshot', '() => {}', '') + | |
+ '\n\n' + | |
+ `Expected the function to throw an error.\n` + | |
+ `But it didn't throw anything.` | |
+ ); | |
} | |
return toMatchSnapshot.call(this, error.message); | |
@@ -155,4 +153,5 @@ module.exports = { | |
cleanup, | |
getSerializers, | |
toMatchSnapshot, | |
- toThrowErrorMatchingSnapshot }; | |
\ No newline at end of file | |
+ toThrowErrorMatchingSnapshot, | |
+}; | |
diff --git i/packages/jest-snapshot/build/plugins.js w/packages/jest-snapshot/build/plugins.js | |
index dde47c33..804802d7 100644 | |
--- i/packages/jest-snapshot/build/plugins.js | |
+++ w/packages/jest-snapshot/build/plugins.js | |
@@ -7,16 +7,12 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require$plugins = | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-require('pretty-format').plugins;const HTMLElement = _require$plugins.HTMLElement,Immutable = _require$plugins.Immutable,ReactElement = _require$plugins.ReactElement,ReactTestComponent = _require$plugins.ReactTestComponent; | |
+'use strict'; | |
+var _require$plugins = require('pretty-format').plugins; | |
+const HTMLElement = _require$plugins.HTMLElement, | |
+ Immutable = _require$plugins.Immutable, | |
+ ReactElement = _require$plugins.ReactElement, | |
+ ReactTestComponent = _require$plugins.ReactTestComponent; | |
let PLUGINS = [HTMLElement, ReactElement, ReactTestComponent].concat(Immutable); | |
@@ -25,4 +21,4 @@ exports.addSerializer = plugin => { | |
PLUGINS = [plugin].concat(PLUGINS); | |
}; | |
-exports.getSerializers = () => PLUGINS; | |
\ No newline at end of file | |
+exports.getSerializers = () => PLUGINS; | |
diff --git i/packages/jest-snapshot/build/utils.js w/packages/jest-snapshot/build/utils.js | |
index fe00030c..db2edde0 100644 | |
--- i/packages/jest-snapshot/build/utils.js | |
+++ w/packages/jest-snapshot/build/utils.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const chalk = require('chalk'); | |
const createDirectory = require('jest-util').createDirectory; | |
const path = require('path'); | |
@@ -25,13 +23,13 @@ const SNAPSHOT_VERSION = '1'; | |
const SNAPSHOT_VERSION_REGEXP = /^\/\/ Jest Snapshot v(.+),/; | |
const SNAPSHOT_GUIDE_LINK = 'https://goo.gl/fbAQLP'; | |
const SNAPSHOT_VERSION_WARNING = chalk.yellow( | |
-`${chalk.bold('Warning')}: Before you upgrade snapshots, ` + | |
-`we recommend that you revert any local changes to tests or other code, ` + | |
-`to ensure that you do not store invalid state.`); | |
- | |
+ `${chalk.bold('Warning')}: Before you upgrade snapshots, ` + | |
+ `we recommend that you revert any local changes to tests or other code, ` + | |
+ `to ensure that you do not store invalid state.` | |
+); | |
const writeSnapshotVersion = () => | |
-`// Jest Snapshot v${SNAPSHOT_VERSION}, ${SNAPSHOT_GUIDE_LINK}`; | |
+ `// Jest Snapshot v${SNAPSHOT_VERSION}, ${SNAPSHOT_GUIDE_LINK}`; | |
const validateSnapshotVersion = snapshotContents => { | |
const versionTest = SNAPSHOT_VERSION_REGEXP.exec(snapshotContents); | |
@@ -39,49 +37,48 @@ const validateSnapshotVersion = snapshotContents => { | |
if (!version) { | |
return new Error( | |
- chalk.red( | |
- `${chalk.bold('Outdated snapshot')}: No snapshot header found. ` + | |
- `Jest 19 introduced versioned snapshots to ensure all developers ` + | |
- `on a project are using the same version of Jest. ` + | |
- `Please update all snapshots during this upgrade of Jest.\n\n`) + | |
- SNAPSHOT_VERSION_WARNING); | |
- | |
+ chalk.red( | |
+ `${chalk.bold('Outdated snapshot')}: No snapshot header found. ` + | |
+ `Jest 19 introduced versioned snapshots to ensure all developers ` + | |
+ `on a project are using the same version of Jest. ` + | |
+ `Please update all snapshots during this upgrade of Jest.\n\n` | |
+ ) + SNAPSHOT_VERSION_WARNING | |
+ ); | |
} | |
if (version < SNAPSHOT_VERSION) { | |
return new Error( | |
- chalk.red( | |
- `${chalk.red.bold('Outdated snapshot')}: The version of the snapshot ` + | |
- `file associated with this test is outdated. The snapshot file ` + | |
- `version ensures that all developers on a project are using ` + | |
- `the same version of Jest. ` + | |
- `Please update all snapshots during this upgrade of Jest.\n\n`) + | |
- | |
- `Expected: v${SNAPSHOT_VERSION}\n` + | |
- `Received: v${version}\n\n` + | |
- SNAPSHOT_VERSION_WARNING); | |
- | |
+ chalk.red( | |
+ `${chalk.red.bold('Outdated snapshot')}: The version of the snapshot ` + | |
+ `file associated with this test is outdated. The snapshot file ` + | |
+ `version ensures that all developers on a project are using ` + | |
+ `the same version of Jest. ` + | |
+ `Please update all snapshots during this upgrade of Jest.\n\n` | |
+ ) + | |
+ `Expected: v${SNAPSHOT_VERSION}\n` + | |
+ `Received: v${version}\n\n` + | |
+ SNAPSHOT_VERSION_WARNING | |
+ ); | |
} | |
if (version > SNAPSHOT_VERSION) { | |
return new Error( | |
- chalk.red( | |
- `${chalk.red.bold('Outdated Jest version')}: The version of this ` + | |
- `snapshot file indicates that this project is meant to be used ` + | |
- `with a newer version of Jest. The snapshot file version ensures ` + | |
- `that all developers on a project are using the same version of ` + | |
- `Jest. Please update your version of Jest and re-run the tests.\n\n`) + | |
- | |
- `Expected: v${SNAPSHOT_VERSION}\n` + | |
- `Received: v${version}`); | |
- | |
+ chalk.red( | |
+ `${chalk.red.bold('Outdated Jest version')}: The version of this ` + | |
+ `snapshot file indicates that this project is meant to be used ` + | |
+ `with a newer version of Jest. The snapshot file version ensures ` + | |
+ `that all developers on a project are using the same version of ` + | |
+ `Jest. Please update your version of Jest and re-run the tests.\n\n` | |
+ ) + | |
+ `Expected: v${SNAPSHOT_VERSION}\n` + | |
+ `Received: v${version}` | |
+ ); | |
} | |
return null; | |
}; | |
-const testNameToKey = (testName, count) => | |
-testName + ' ' + count; | |
+const testNameToKey = (testName, count) => testName + ' ' + count; | |
const keyToTestName = key => { | |
if (!/ \d+$/.test(key)) { | |
@@ -92,10 +89,10 @@ const keyToTestName = key => { | |
}; | |
const getSnapshotPath = testPath => | |
-path.join( | |
-path.join(path.dirname(testPath), '__snapshots__'), | |
-path.basename(testPath) + '.' + SNAPSHOT_EXTENSION); | |
- | |
+ path.join( | |
+ path.join(path.dirname(testPath), '__snapshots__'), | |
+ path.basename(testPath) + '.' + SNAPSHOT_EXTENSION | |
+ ); | |
const getSnapshotData = (snapshotPath, update) => { | |
const data = Object.create(null); | |
@@ -122,24 +119,24 @@ const getSnapshotData = (snapshotPath, update) => { | |
dirty = true; | |
} | |
- return { data, dirty }; | |
+ return {data, dirty}; | |
}; | |
// Extra line breaks at the beginning and at the end of the snapshot are useful | |
// to make the content of the snapshot easier to read | |
const addExtraLineBreaks = string => | |
-string.includes('\n') ? `\n${string}\n` : string; | |
+ string.includes('\n') ? `\n${string}\n` : string; | |
const serialize = data => { | |
return addExtraLineBreaks( | |
- normalizeNewlines( | |
- prettyFormat(data, { | |
- escapeRegex: true, | |
- plugins: getSerializers(), | |
- printFunctionName: false }))); | |
- | |
- | |
- | |
+ normalizeNewlines( | |
+ prettyFormat(data, { | |
+ escapeRegex: true, | |
+ plugins: getSerializers(), | |
+ printFunctionName: false, | |
+ }) | |
+ ) | |
+ ); | |
}; | |
// unescape double quotes | |
@@ -157,26 +154,23 @@ const ensureDirectoryExists = filePath => { | |
const normalizeNewlines = string => string.replace(/\r\n|\r/g, '\n'); | |
-const saveSnapshotFile = ( | |
-snapshotData, | |
-snapshotPath) => | |
-{ | |
- const snapshots = Object.keys(snapshotData). | |
- sort(naturalCompare). | |
- map( | |
- key => | |
- 'exports[' + | |
- printBacktickString(key) + | |
- '] = ' + | |
- printBacktickString(normalizeNewlines(snapshotData[key])) + | |
- ';'); | |
- | |
+const saveSnapshotFile = (snapshotData, snapshotPath) => { | |
+ const snapshots = Object.keys(snapshotData) | |
+ .sort(naturalCompare) | |
+ .map( | |
+ key => | |
+ 'exports[' + | |
+ printBacktickString(key) + | |
+ '] = ' + | |
+ printBacktickString(normalizeNewlines(snapshotData[key])) + | |
+ ';' | |
+ ); | |
ensureDirectoryExists(snapshotPath); | |
fs.writeFileSync( | |
- snapshotPath, | |
- writeSnapshotVersion() + '\n\n' + snapshots.join('\n\n') + '\n'); | |
- | |
+ snapshotPath, | |
+ writeSnapshotVersion() + '\n\n' + snapshots.join('\n\n') + '\n' | |
+ ); | |
}; | |
module.exports = { | |
@@ -191,4 +185,5 @@ module.exports = { | |
saveSnapshotFile, | |
serialize, | |
testNameToKey, | |
- unescape }; | |
\ No newline at end of file | |
+ unescape, | |
+}; | |
diff --git i/packages/jest-test-typescript-parser/build/TypeScriptParser.js w/packages/jest-test-typescript-parser/build/TypeScriptParser.js | |
index a3f919d1..42e0e782 100644 | |
--- i/packages/jest-test-typescript-parser/build/TypeScriptParser.js | |
+++ w/packages/jest-test-typescript-parser/build/TypeScriptParser.js | |
@@ -10,22 +10,26 @@ | |
'use strict'; | |
-const ts = require('typescript');var _require = | |
-require('fs');const readFileSync = _require.readFileSync;var _require2 = | |
-require('jest-editor-support');const Expect = _require2.Expect,ItBlock = _require2.ItBlock,Node = _require2.Node; | |
+const ts = require('typescript'); | |
+var _require = require('fs'); | |
+const readFileSync = _require.readFileSync; | |
+var _require2 = require('jest-editor-support'); | |
+const Expect = _require2.Expect, | |
+ ItBlock = _require2.ItBlock, | |
+ Node = _require2.Node; | |
function parse(file) { | |
const sourceFile = ts.createSourceFile( | |
- file, | |
- readFileSync(file).toString(), | |
- ts.ScriptTarget.ES3); | |
- | |
+ file, | |
+ readFileSync(file).toString(), | |
+ ts.ScriptTarget.ES3 | |
+ ); | |
const itBlocks = []; | |
const expects = []; | |
function searchNodes(node) { | |
- if (node.kind === ts.SyntaxKind.CallExpression) {let | |
- text = node.expression.text; | |
+ if (node.kind === ts.SyntaxKind.CallExpression) { | |
+ let text = node.expression.text; | |
if (!text) { | |
// Property access (it.only) | |
text = node.expression.expression.text; | |
@@ -44,12 +48,12 @@ function parse(file) { | |
if (expectText === 'expect') { | |
const position = getNode(sourceFile, node, new Expect()); | |
if ( | |
- !expects.some( | |
- e => | |
- e.start.line === position.start.line && | |
- e.start.column === position.start.column)) | |
- | |
- { | |
+ !expects.some( | |
+ e => | |
+ e.start.line === position.start.line && | |
+ e.start.column === position.start.column | |
+ ) | |
+ ) { | |
expects.push(position); | |
} | |
} | |
@@ -61,29 +65,28 @@ function parse(file) { | |
ts.forEachChild(sourceFile, searchNodes); | |
return { | |
expects, | |
- itBlocks }; | |
- | |
+ itBlocks, | |
+ }; | |
} | |
-function getNode( | |
-file, | |
-expression, | |
-node) | |
-{ | |
+function getNode(file, expression, node) { | |
const start = file.getLineAndCharacterOfPosition(expression.getStart(file)); | |
// TypeScript parser is 0 based, so we have to increment by 1 to normalize | |
node.start = { | |
column: start.character + 1, | |
- line: start.line + 1 }; | |
+ line: start.line + 1, | |
+ }; | |
const end = file.getLineAndCharacterOfPosition(expression.getEnd()); | |
node.end = { | |
column: end.character + 1, | |
- line: end.line + 1 }; | |
+ line: end.line + 1, | |
+ }; | |
node.file = file.fileName; | |
return node; | |
} | |
module.exports = { | |
- parse }; | |
\ No newline at end of file | |
+ parse, | |
+}; | |
diff --git i/packages/jest-test-typescript-parser/build/index.js w/packages/jest-test-typescript-parser/build/index.js | |
index 18879f4e..e90544f0 100644 | |
--- i/packages/jest-test-typescript-parser/build/index.js | |
+++ w/packages/jest-test-typescript-parser/build/index.js | |
@@ -8,15 +8,13 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
-require('jest-editor-support');const babylonParser = _require.parse,ItBlock = _require.ItBlock,Expect = _require.Expect; | |
+'use strict'; | |
+var _require = require('jest-editor-support'); | |
+const babylonParser = _require.parse, | |
+ ItBlock = _require.ItBlock, | |
+ Expect = _require.Expect; | |
const TypeScriptParser = require('./TypeScriptParser'); | |
- | |
- | |
- | |
- | |
/** | |
* Converts the file into an AST, then passes out a | |
* collection of it and expects. | |
@@ -31,4 +29,5 @@ function parse(file) { | |
module.exports = { | |
TypeScriptParser, | |
- parse }; | |
\ No newline at end of file | |
+ parse, | |
+}; | |
diff --git i/packages/jest-util/build/Console.js w/packages/jest-util/build/Console.js | |
index 6bebba57..71a7d174 100644 | |
--- i/packages/jest-util/build/Console.js | |
+++ w/packages/jest-util/build/Console.js | |
@@ -10,24 +10,13 @@ | |
/* global stream$Writable */ | |
'use strict'; | |
- | |
- | |
const Console = require('console').Console; | |
const clearLine = require('./clearLine'); | |
const format = require('util').format; | |
- | |
- | |
class CustomConsole extends Console { | |
- | |
- | |
- | |
- constructor( | |
- stdout, | |
- stderr, | |
- formatBuffer) | |
- { | |
+ constructor(stdout, stderr, formatBuffer) { | |
super(stdout, stderr); | |
this._formatBuffer = formatBuffer || ((type, message) => message); | |
} | |
@@ -55,7 +44,7 @@ class CustomConsole extends Console { | |
getBuffer() { | |
return null; | |
- }} | |
- | |
+ } | |
+} | |
-module.exports = CustomConsole; | |
\ No newline at end of file | |
+module.exports = CustomConsole; | |
diff --git i/packages/jest-util/build/FakeTimers.js w/packages/jest-util/build/FakeTimers.js | |
index 0ea87f27..252ad231 100644 | |
--- i/packages/jest-util/build/FakeTimers.js | |
+++ w/packages/jest-util/build/FakeTimers.js | |
@@ -7,65 +7,15 @@ | |
* | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
- | |
- | |
-require('jest-message-util');const formatStackTrace = _require.formatStackTrace; | |
+'use strict'; | |
+var _require = require('jest-message-util'); | |
+const formatStackTrace = _require.formatStackTrace; | |
const setGlobal = require('./setGlobal'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const MS_IN_A_YEAR = 31536000000; | |
class FakeTimers { | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- constructor( | |
- global, | |
- moduleMocker, | |
- config, | |
- maxLoops) | |
- { | |
+ constructor(global, moduleMocker, config, maxLoops) { | |
this._global = global; | |
this._config = config; | |
this._maxLoops = maxLoops || 100000; | |
@@ -80,8 +30,8 @@ class FakeTimers { | |
nextTick: global.process && global.process.nextTick, | |
setImmediate: global.setImmediate, | |
setInterval: global.setInterval, | |
- setTimeout: global.setTimeout }; | |
- | |
+ setTimeout: global.setTimeout, | |
+ }; | |
this.reset(); | |
this._createMocks(); | |
@@ -99,7 +49,8 @@ class FakeTimers { | |
clearAllTimers() { | |
this._immediates.forEach(immediate => | |
- this._fakeClearImmediate(immediate.uuid)); | |
+ this._fakeClearImmediate(immediate.uuid) | |
+ ); | |
for (const uuid in this._timers) { | |
delete this._timers[uuid]; | |
@@ -141,11 +92,11 @@ class FakeTimers { | |
if (i === this._maxLoops) { | |
throw new Error( | |
- 'Ran ' + | |
- this._maxLoops + | |
- ' ticks, and there are still more! ' + | |
- "Assuming we've hit an infinite recursion and bailing out..."); | |
- | |
+ 'Ran ' + | |
+ this._maxLoops + | |
+ ' ticks, and there are still more! ' + | |
+ "Assuming we've hit an infinite recursion and bailing out..." | |
+ ); | |
} | |
} | |
@@ -163,11 +114,11 @@ class FakeTimers { | |
if (i === this._maxLoops) { | |
throw new Error( | |
- 'Ran ' + | |
- this._maxLoops + | |
- ' immediates, and there are still more! Assuming ' + | |
- "we've hit an infinite recursion and bailing out..."); | |
- | |
+ 'Ran ' + | |
+ this._maxLoops + | |
+ ' immediates, and there are still more! Assuming ' + | |
+ "we've hit an infinite recursion and bailing out..." | |
+ ); | |
} | |
} | |
@@ -207,11 +158,11 @@ class FakeTimers { | |
if (i === this._maxLoops) { | |
throw new Error( | |
- 'Ran ' + | |
- this._maxLoops + | |
- ' timers, and there are still more! ' + | |
- "Assuming we've hit an infinite recursion and bailing out..."); | |
- | |
+ 'Ran ' + | |
+ this._maxLoops + | |
+ ' timers, and there are still more! ' + | |
+ "Assuming we've hit an infinite recursion and bailing out..." | |
+ ); | |
} | |
} | |
@@ -219,9 +170,9 @@ class FakeTimers { | |
this._checkFakeTimers(); | |
this._immediates.forEach(this._runImmediate, this); | |
const timers = this._timers; | |
- Object.keys(timers). | |
- sort((left, right) => timers[left].expiry - timers[right].expiry). | |
- forEach(this._runTimerHandle, this); | |
+ Object.keys(timers) | |
+ .sort((left, right) => timers[left].expiry - timers[right].expiry) | |
+ .forEach(this._runTimerHandle, this); | |
} | |
runTimersToTime(msToRun) { | |
@@ -252,11 +203,11 @@ class FakeTimers { | |
if (i === this._maxLoops) { | |
throw new Error( | |
- 'Ran ' + | |
- this._maxLoops + | |
- ' timers, and there are still more! ' + | |
- "Assuming we've hit an infinite recursion and bailing out..."); | |
- | |
+ 'Ran ' + | |
+ this._maxLoops + | |
+ ' timers, and there are still more! ' + | |
+ "Assuming we've hit an infinite recursion and bailing out..." | |
+ ); | |
} | |
} | |
@@ -322,18 +273,18 @@ class FakeTimers { | |
_checkFakeTimers() { | |
if (this._global.setTimeout !== this._fakeTimerAPIs.setTimeout) { | |
this._global.console.warn( | |
- `A function to advance timers was called but the timers API is not ` + | |
- `mocked with fake timers. Call \`jest.useFakeTimers()\` in this ` + | |
- `test or enable fake timers globally by setting ` + | |
- `\`"timers": "fake"\` in ` + | |
- `the configuration file. This warning is likely a result of a ` + | |
- `default configuration change in Jest 15.\n\n` + | |
- `Release Blog Post: https://facebook.github.io/jest/blog/2016/09/01/jest-15.html\n` + | |
- `Stack Trace:\n` + | |
- formatStackTrace(new Error().stack, this._config, { | |
- noStackTrace: false })); | |
- | |
- | |
+ `A function to advance timers was called but the timers API is not ` + | |
+ `mocked with fake timers. Call \`jest.useFakeTimers()\` in this ` + | |
+ `test or enable fake timers globally by setting ` + | |
+ `\`"timers": "fake"\` in ` + | |
+ `the configuration file. This warning is likely a result of a ` + | |
+ `default configuration change in Jest 15.\n\n` + | |
+ `Release Blog Post: https://facebook.github.io/jest/blog/2016/09/01/jest-15.html\n` + | |
+ `Stack Trace:\n` + | |
+ formatStackTrace(new Error().stack, this._config, { | |
+ noStackTrace: false, | |
+ }) | |
+ ); | |
} | |
} | |
@@ -347,8 +298,8 @@ class FakeTimers { | |
nextTick: fn(this._fakeNextTick.bind(this)), | |
setImmediate: fn(this._fakeSetImmediate.bind(this)), | |
setInterval: fn(this._fakeSetInterval.bind(this)), | |
- setTimeout: fn(this._fakeSetTimeout.bind(this)) }; | |
- | |
+ setTimeout: fn(this._fakeSetTimeout.bind(this)), | |
+ }; | |
} | |
_fakeClearTimer(uuid) { | |
@@ -375,8 +326,8 @@ class FakeTimers { | |
this._ticks.push({ | |
callback: () => callback.apply(null, args), | |
- uuid }); | |
- | |
+ uuid, | |
+ }); | |
const cancelledTicks = this._cancelledTicks; | |
this._timerAPIs.nextTick(() => { | |
@@ -405,8 +356,8 @@ class FakeTimers { | |
this._immediates.push({ | |
callback: () => callback.apply(null, args), | |
- uuid: String(uuid) }); | |
- | |
+ uuid: String(uuid), | |
+ }); | |
const cancelledImmediates = this._cancelledImmediates; | |
this._timerAPIs.setImmediate(() => { | |
@@ -440,8 +391,8 @@ class FakeTimers { | |
callback: () => callback.apply(null, args), | |
expiry: this._now + intervalDelay, | |
interval: intervalDelay, | |
- type: 'interval' }; | |
- | |
+ type: 'interval', | |
+ }; | |
return uuid; | |
} | |
@@ -466,8 +417,8 @@ class FakeTimers { | |
callback: () => callback.apply(null, args), | |
expiry: this._now + delay, | |
interval: null, | |
- type: 'timeout' }; | |
- | |
+ type: 'timeout', | |
+ }; | |
return uuid; | |
} | |
@@ -508,9 +459,9 @@ class FakeTimers { | |
break; | |
default: | |
- throw new Error('Unexpected timer type: ' + timer.type);} | |
- | |
- }} | |
- | |
+ throw new Error('Unexpected timer type: ' + timer.type); | |
+ } | |
+ } | |
+} | |
-module.exports = FakeTimers; | |
\ No newline at end of file | |
+module.exports = FakeTimers; | |
diff --git i/packages/jest-util/build/NullConsole.js w/packages/jest-util/build/NullConsole.js | |
index 2461923c..f6b00832 100644 | |
--- i/packages/jest-util/build/NullConsole.js | |
+++ w/packages/jest-util/build/NullConsole.js | |
@@ -21,7 +21,7 @@ class NullConsole extends Console { | |
time() {} | |
timeEnd() {} | |
trace() {} | |
- warn() {}} | |
+ warn() {} | |
+} | |
- | |
-module.exports = NullConsole; | |
\ No newline at end of file | |
+module.exports = NullConsole; | |
diff --git i/packages/jest-util/build/clearLine.js w/packages/jest-util/build/clearLine.js | |
index 240c71a7..aa294802 100644 | |
--- i/packages/jest-util/build/clearLine.js | |
+++ w/packages/jest-util/build/clearLine.js | |
@@ -14,4 +14,4 @@ module.exports = stream => { | |
if (process.stdout.isTTY) { | |
stream.write('\x1b[999D\x1b[K'); | |
} | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-util/build/formatTestResults.js w/packages/jest-util/build/formatTestResults.js | |
index ec5f5a7d..65f1ebad 100644 | |
--- i/packages/jest-util/build/formatTestResults.js | |
+++ w/packages/jest-util/build/formatTestResults.js | |
@@ -10,22 +10,7 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
-const formatResult = ( | |
-testResult, | |
-codeCoverageFormatter, | |
-reporter) => | |
-{ | |
+const formatResult = (testResult, codeCoverageFormatter, reporter) => { | |
const now = Date.now(); | |
const output = { | |
assertionResults: [], | |
@@ -35,8 +20,8 @@ reporter) => | |
name: testResult.testFilePath, | |
startTime: now, | |
status: 'failed', | |
- summary: '' }; | |
- | |
+ summary: '', | |
+ }; | |
if (testResult.testExecError) { | |
output.message = testResult.testExecError.message; | |
@@ -58,13 +43,12 @@ reporter) => | |
return output; | |
}; | |
-function formatTestAssertion( | |
-assertion) | |
-{ | |
+function formatTestAssertion(assertion) { | |
const result = { | |
failureMessages: null, | |
status: assertion.status, | |
- title: assertion.title }; | |
+ title: assertion.title, | |
+ }; | |
if (assertion.failureMessages) { | |
result.failureMessages = assertion.failureMessages; | |
@@ -72,20 +56,16 @@ assertion) | |
return result; | |
} | |
-function formatTestResults( | |
-results, | |
-codeCoverageFormatter, | |
-reporter) | |
-{ | |
+function formatTestResults(results, codeCoverageFormatter, reporter) { | |
const formatter = codeCoverageFormatter || (coverage => coverage); | |
const testResults = results.testResults.map(testResult => | |
- formatResult(testResult, formatter, reporter)); | |
- | |
+ formatResult(testResult, formatter, reporter) | |
+ ); | |
return Object.assign(Object.create(null), results, { | |
- testResults }); | |
- | |
+ testResults, | |
+ }); | |
} | |
-module.exports = formatTestResults; | |
\ No newline at end of file | |
+module.exports = formatTestResults; | |
diff --git i/packages/jest-util/build/index.js w/packages/jest-util/build/index.js | |
index e0b5e032..35a13c4c 100644 | |
--- i/packages/jest-util/build/index.js | |
+++ w/packages/jest-util/build/index.js | |
@@ -40,4 +40,5 @@ module.exports = { | |
formatTestResults, | |
installCommonGlobals, | |
setGlobal, | |
- validateCLIOptions }; | |
\ No newline at end of file | |
+ validateCLIOptions, | |
+}; | |
diff --git i/packages/jest-util/build/installCommonGlobals.js w/packages/jest-util/build/installCommonGlobals.js | |
index 33e58e3a..ebcd4f37 100644 | |
--- i/packages/jest-util/build/installCommonGlobals.js | |
+++ w/packages/jest-util/build/installCommonGlobals.js | |
@@ -9,9 +9,6 @@ | |
*/ | |
'use strict'; | |
- | |
- | |
- | |
function deepCopy(obj) { | |
const newObj = {}; | |
let value; | |
@@ -36,8 +33,8 @@ module.exports = (global, globals) => { | |
if (Symbol && Symbol.toStringTag) { | |
// $FlowFixMe | |
toStringOverwrite = { | |
- [Symbol.toStringTag]: 'process' }; | |
- | |
+ [Symbol.toStringTag]: 'process', | |
+ }; | |
} | |
global.process = Object.assign({}, process, toStringOverwrite); | |
global.process.setMaxListeners = process.setMaxListeners.bind(process); | |
@@ -55,4 +52,4 @@ module.exports = (global, globals) => { | |
global.clearImmediate = clearImmediate; | |
Object.assign(global, deepCopy(globals)); | |
-}; | |
\ No newline at end of file | |
+}; | |
diff --git i/packages/jest-util/build/setGlobal.js w/packages/jest-util/build/setGlobal.js | |
index 8d2d5dd8..c183f6c8 100644 | |
--- i/packages/jest-util/build/setGlobal.js | |
+++ w/packages/jest-util/build/setGlobal.js | |
@@ -1,20 +1,7 @@ | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
module.exports = (global, key, value) => | |
-global[key] = value; /** | |
+ (global[ | |
+ key | |
+ ] = value); /** | |
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | |
* | |
* This source code is licensed under the BSD-style license found in the | |
@@ -23,4 +10,4 @@ global[key] = value; /** | |
* | |
* | |
*/ // This file must not use 'use strict'. | |
-// See https://github.com/facebook/jest/pull/2457#issuecomment-269518622 | |
\ No newline at end of file | |
+// See https://github.com/facebook/jest/pull/2457#issuecomment-269518622 | |
diff --git i/packages/jest-util/build/validateCLIOptions.js w/packages/jest-util/build/validateCLIOptions.js | |
index 235dcc67..334e69e1 100644 | |
--- i/packages/jest-util/build/validateCLIOptions.js | |
+++ w/packages/jest-util/build/validateCLIOptions.js | |
@@ -10,41 +10,36 @@ | |
'use strict'; | |
- | |
- | |
-const chalk = require('chalk');var _require = | |
- | |
- | |
- | |
- | |
-require('jest-validate');const ValidationError = _require.ValidationError,format = _require.format,createDidYouMeanMessage = _require.createDidYouMeanMessage; | |
+const chalk = require('chalk'); | |
+var _require = require('jest-validate'); | |
+const ValidationError = _require.ValidationError, | |
+ format = _require.format, | |
+ createDidYouMeanMessage = _require.createDidYouMeanMessage; | |
const BULLET = chalk.bold('\u25cf'); | |
-const createCLIValidationError = ( | |
-unrecognizedOptions, | |
-allowedOptions) => | |
-{ | |
+const createCLIValidationError = (unrecognizedOptions, allowedOptions) => { | |
let title = `${BULLET} Unrecognized CLI Parameter`; | |
let message; | |
const comment = | |
- ` ${chalk.bold('CLI Options Documentation')}:\n` + | |
- ` http://facebook.github.io/jest/docs/cli.html\n`; | |
+ ` ${chalk.bold('CLI Options Documentation')}:\n` + | |
+ ` http://facebook.github.io/jest/docs/cli.html\n`; | |
if (unrecognizedOptions.length === 1) { | |
const unrecognized = unrecognizedOptions[0]; | |
const didYouMeanMessage = createDidYouMeanMessage( | |
- unrecognized, | |
- Array.from(allowedOptions)); | |
+ unrecognized, | |
+ Array.from(allowedOptions) | |
+ ); | |
message = | |
- ` Unrecognized option ${chalk.bold(format(unrecognized))}.` + ( | |
- didYouMeanMessage ? ` ${didYouMeanMessage}` : ''); | |
+ ` Unrecognized option ${chalk.bold(format(unrecognized))}.` + | |
+ (didYouMeanMessage ? ` ${didYouMeanMessage}` : ''); | |
} else { | |
title += 's'; | |
message = | |
- ` Following options were not recognized:\n` + | |
- ` ${chalk.bold(format(unrecognizedOptions))}`; | |
+ ` Following options were not recognized:\n` + | |
+ ` ${chalk.bold(format(unrecognizedOptions))}`; | |
} | |
return new ValidationError(title, message, comment); | |
@@ -53,12 +48,13 @@ allowedOptions) => | |
const validateCLIOptions = (argv, options) => { | |
const yargsSpecialOptions = ['$0', '_', 'help', 'h']; | |
const allowedOptions = Object.keys(options).reduce( | |
- (acc, option) => acc.add(option).add(options[option].alias || option), | |
- new Set(yargsSpecialOptions)); | |
+ (acc, option) => acc.add(option).add(options[option].alias || option), | |
+ new Set(yargsSpecialOptions) | |
+ ); | |
const unrecognizedOptions = Object.keys(argv).filter( | |
- arg => !allowedOptions.has(arg)); | |
- | |
+ arg => !allowedOptions.has(arg) | |
+ ); | |
if (unrecognizedOptions.length) { | |
throw createCLIValidationError(unrecognizedOptions, allowedOptions); | |
@@ -67,4 +63,4 @@ const validateCLIOptions = (argv, options) => { | |
return true; | |
}; | |
-module.exports = validateCLIOptions; | |
\ No newline at end of file | |
+module.exports = validateCLIOptions; | |
diff --git i/packages/jest-validate/build/condition.js w/packages/jest-validate/build/condition.js | |
index 8b7bf961..81c59297 100644 | |
--- i/packages/jest-validate/build/condition.js | |
+++ w/packages/jest-validate/build/condition.js | |
@@ -16,8 +16,8 @@ const validationCondition = (option, validOption) => { | |
return ( | |
option === null || | |
option === undefined || | |
- toString.call(option) === toString.call(validOption)); | |
- | |
+ toString.call(option) === toString.call(validOption) | |
+ ); | |
}; | |
-module.exports = validationCondition; | |
\ No newline at end of file | |
+module.exports = validationCondition; | |
diff --git i/packages/jest-validate/build/defaultConfig.js w/packages/jest-validate/build/defaultConfig.js | |
index 6c78233d..1f5f7f26 100644 | |
--- i/packages/jest-validate/build/defaultConfig.js | |
+++ w/packages/jest-validate/build/defaultConfig.js | |
@@ -8,16 +8,19 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('./deprecated');const deprecationWarning = _require.deprecationWarning;var _require2 = | |
-require('./warnings');const unknownOptionWarning = _require2.unknownOptionWarning;var _require3 = | |
-require('./errors');const errorMessage = _require3.errorMessage; | |
+'use strict'; | |
+var _require = require('./deprecated'); | |
+const deprecationWarning = _require.deprecationWarning; | |
+var _require2 = require('./warnings'); | |
+const unknownOptionWarning = _require2.unknownOptionWarning; | |
+var _require3 = require('./errors'); | |
+const errorMessage = _require3.errorMessage; | |
const exampleConfig = require('./exampleConfig'); | |
-const validationCondition = require('./condition');var _require4 = | |
-require('./utils');const ERROR = _require4.ERROR,DEPRECATION = _require4.DEPRECATION,WARNING = _require4.WARNING; | |
+const validationCondition = require('./condition'); | |
+var _require4 = require('./utils'); | |
+const ERROR = _require4.ERROR, | |
+ DEPRECATION = _require4.DEPRECATION, | |
+ WARNING = _require4.WARNING; | |
module.exports = { | |
comment: '', | |
@@ -29,6 +32,8 @@ module.exports = { | |
title: { | |
deprecation: DEPRECATION, | |
error: ERROR, | |
- warning: WARNING }, | |
+ warning: WARNING, | |
+ }, | |
- unknown: unknownOptionWarning }; | |
\ No newline at end of file | |
+ unknown: unknownOptionWarning, | |
+}; | |
diff --git i/packages/jest-validate/build/deprecated.js w/packages/jest-validate/build/deprecated.js | |
index 5de6db0c..c1d58b15 100644 | |
--- i/packages/jest-validate/build/deprecated.js | |
+++ w/packages/jest-validate/build/deprecated.js | |
@@ -8,25 +8,19 @@ | |
* | |
*/ | |
-'use strict';var _require = | |
- | |
- | |
- | |
-require('./utils');const logValidationWarning = _require.logValidationWarning,DEPRECATION = _require.DEPRECATION; | |
+'use strict'; | |
+var _require = require('./utils'); | |
+const logValidationWarning = _require.logValidationWarning, | |
+ DEPRECATION = _require.DEPRECATION; | |
const deprecationMessage = (message, options) => { | |
const comment = options.comment; | |
- const name = options.title && options.title.deprecation || DEPRECATION; | |
+ const name = (options.title && options.title.deprecation) || DEPRECATION; | |
logValidationWarning(name, message, comment); | |
}; | |
-const deprecationWarning = ( | |
-config, | |
-option, | |
-deprecatedOptions, | |
-options) => | |
-{ | |
+const deprecationWarning = (config, option, deprecatedOptions, options) => { | |
if (option in deprecatedOptions) { | |
deprecationMessage(deprecatedOptions[option](config), options); | |
@@ -37,4 +31,5 @@ options) => | |
}; | |
module.exports = { | |
- deprecationWarning }; | |
\ No newline at end of file | |
+ deprecationWarning, | |
+}; | |
diff --git i/packages/jest-validate/build/errors.js w/packages/jest-validate/build/errors.js | |
index e5b770f4..a0466680 100644 | |
--- i/packages/jest-validate/build/errors.js | |
+++ w/packages/jest-validate/build/errors.js | |
@@ -10,18 +10,15 @@ | |
'use strict'; | |
- | |
- | |
-const chalk = require('chalk');var _require = | |
-require('./utils');const format = _require.format,ValidationError = _require.ValidationError,ERROR = _require.ERROR;var _require2 = | |
-require('jest-matcher-utils');const getType = _require2.getType; | |
- | |
-const errorMessage = ( | |
-option, | |
-received, | |
-defaultValue, | |
-options) => | |
-{ | |
+const chalk = require('chalk'); | |
+var _require = require('./utils'); | |
+const format = _require.format, | |
+ ValidationError = _require.ValidationError, | |
+ ERROR = _require.ERROR; | |
+var _require2 = require('jest-matcher-utils'); | |
+const getType = _require2.getType; | |
+ | |
+const errorMessage = (option, received, defaultValue, options) => { | |
const message = ` Option ${chalk.bold(`"${option}"`)} must be of type: | |
${chalk.bold.green(getType(defaultValue))} | |
but instead received: | |
@@ -33,11 +30,12 @@ options) => | |
}`; | |
const comment = options.comment; | |
- const name = options.title && options.title.error || ERROR; | |
+ const name = (options.title && options.title.error) || ERROR; | |
throw new ValidationError(name, message, comment); | |
}; | |
module.exports = { | |
ValidationError, | |
- errorMessage }; | |
\ No newline at end of file | |
+ errorMessage, | |
+}; | |
diff --git i/packages/jest-validate/build/exampleConfig.js w/packages/jest-validate/build/exampleConfig.js | |
index 2e26dc34..eaa62e2e 100644 | |
--- i/packages/jest-validate/build/exampleConfig.js | |
+++ w/packages/jest-validate/build/exampleConfig.js | |
@@ -10,23 +10,23 @@ | |
'use strict'; | |
- | |
- | |
const config = { | |
comment: ' A comment', | |
condition: (option, validOption) => true, | |
deprecate: (config, option, deprecatedOptions, options) => false, | |
deprecatedConfig: { | |
- key: config => {} }, | |
+ key: config => {}, | |
+ }, | |
error: (option, received, defaultValue, options) => {}, | |
- exampleConfig: { key: 'value', test: 'case' }, | |
+ exampleConfig: {key: 'value', test: 'case'}, | |
title: { | |
deprecation: 'Deprecation Warning', | |
error: 'Validation Error', | |
- warning: 'Validation Warning' }, | |
- | |
- unknown: (config, option, options) => {} }; | |
+ warning: 'Validation Warning', | |
+ }, | |
+ unknown: (config, option, options) => {}, | |
+}; | |
-module.exports = config; | |
\ No newline at end of file | |
+module.exports = config; | |
diff --git i/packages/jest-validate/build/index.js w/packages/jest-validate/build/index.js | |
index cbc8b066..6faae27c 100644 | |
--- i/packages/jest-validate/build/index.js | |
+++ w/packages/jest-validate/build/index.js | |
@@ -15,4 +15,5 @@ module.exports = { | |
createDidYouMeanMessage: require('./utils').createDidYouMeanMessage, | |
format: require('./utils').format, | |
logValidationWarning: require('./utils').logValidationWarning, | |
- validate: require('./validate') }; | |
\ No newline at end of file | |
+ validate: require('./validate'), | |
+}; | |
diff --git i/packages/jest-validate/build/types.js w/packages/jest-validate/build/types.js | |
index 01523b94..1c02bbe5 100644 | |
--- i/packages/jest-validate/build/types.js | |
+++ w/packages/jest-validate/build/types.js | |
@@ -8,4 +8,4 @@ | |
* | |
*/ | |
-'use strict'; | |
\ No newline at end of file | |
+'use strict'; | |
diff --git i/packages/jest-validate/build/utils.js w/packages/jest-validate/build/utils.js | |
index 0cd8fa40..4472bd58 100644 | |
--- i/packages/jest-validate/build/utils.js | |
+++ w/packages/jest-validate/build/utils.js | |
@@ -17,36 +17,26 @@ const ERROR = `${BULLET} Validation Error`; | |
const WARNING = `${BULLET} Validation Warning`; | |
const format = value => | |
-typeof value === 'function' ? | |
-value.toString() : | |
-require('pretty-format')(value, { min: true }); | |
+ typeof value === 'function' | |
+ ? value.toString() | |
+ : require('pretty-format')(value, {min: true}); | |
class ValidationError extends Error { | |
- | |
- | |
- | |
constructor(name, message, comment) { | |
super(); | |
comment = comment ? '\n\n' + comment : '\n'; | |
this.name = ''; | |
this.message = chalk.red(chalk.bold(name) + ':\n\n' + message + comment); | |
Error.captureStackTrace(this, () => {}); | |
- }} | |
+ } | |
+} | |
- | |
-const logValidationWarning = ( | |
-name, | |
-message, | |
-comment) => | |
-{ | |
+const logValidationWarning = (name, message, comment) => { | |
comment = comment ? '\n\n' + comment : '\n'; | |
console.warn(chalk.yellow(chalk.bold(name) + ':\n\n' + message + comment)); | |
}; | |
-const createDidYouMeanMessage = ( | |
-unrecognized, | |
-allowedOptions) => | |
-{ | |
+const createDidYouMeanMessage = (unrecognized, allowedOptions) => { | |
const leven = require('leven'); | |
const suggestion = allowedOptions.find(option => { | |
const steps = leven(option, unrecognized); | |
@@ -63,4 +53,5 @@ module.exports = { | |
WARNING, | |
createDidYouMeanMessage, | |
format, | |
- logValidationWarning }; | |
\ No newline at end of file | |
+ logValidationWarning, | |
+}; | |
diff --git i/packages/jest-validate/build/validate.js w/packages/jest-validate/build/validate.js | |
index 870a3ece..579afab4 100644 | |
--- i/packages/jest-validate/build/validate.js | |
+++ w/packages/jest-validate/build/validate.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const defaultConfig = require('./defaultConfig'); | |
const _validate = (config, options) => { | |
@@ -19,51 +17,48 @@ const _validate = (config, options) => { | |
for (const key in config) { | |
if ( | |
- options.deprecatedConfig && | |
- key in options.deprecatedConfig && | |
- typeof options.deprecate === 'function') | |
- { | |
+ options.deprecatedConfig && | |
+ key in options.deprecatedConfig && | |
+ typeof options.deprecate === 'function' | |
+ ) { | |
const isDeprecatedKey = options.deprecate( | |
- config, | |
- key, | |
- options.deprecatedConfig, | |
- options); | |
- | |
+ config, | |
+ key, | |
+ options.deprecatedConfig, | |
+ options | |
+ ); | |
hasDeprecationWarnings = hasDeprecationWarnings || isDeprecatedKey; | |
} else if (hasOwnProperty.call(options.exampleConfig, key)) { | |
if ( | |
- typeof options.condition === 'function' && | |
- typeof options.error === 'function' && | |
- !options.condition(config[key], options.exampleConfig[key])) | |
- { | |
+ typeof options.condition === 'function' && | |
+ typeof options.error === 'function' && | |
+ !options.condition(config[key], options.exampleConfig[key]) | |
+ ) { | |
options.error(key, config[key], options.exampleConfig[key], options); | |
} | |
} else { | |
options.unknown && | |
- options.unknown(config, options.exampleConfig, key, options); | |
+ options.unknown(config, options.exampleConfig, key, options); | |
} | |
} | |
- return { hasDeprecationWarnings }; | |
+ return {hasDeprecationWarnings}; | |
}; | |
const validate = (config, options) => { | |
_validate(options, defaultConfig); // validate against jest-validate config | |
- const defaultedOptions = Object.assign( | |
- {}, | |
- defaultConfig, | |
- options, | |
- { title: Object.assign({}, defaultConfig.title, options.title) });var _validate2 = | |
- | |
- | |
- _validate(config, defaultedOptions);const hasDeprecationWarnings = _validate2.hasDeprecationWarnings; | |
+ const defaultedOptions = Object.assign({}, defaultConfig, options, { | |
+ title: Object.assign({}, defaultConfig.title, options.title), | |
+ }); | |
+ var _validate2 = _validate(config, defaultedOptions); | |
+ const hasDeprecationWarnings = _validate2.hasDeprecationWarnings; | |
return { | |
hasDeprecationWarnings, | |
- isValid: true }; | |
- | |
+ isValid: true, | |
+ }; | |
}; | |
-module.exports = validate; | |
\ No newline at end of file | |
+module.exports = validate; | |
diff --git i/packages/jest-validate/build/warnings.js w/packages/jest-validate/build/warnings.js | |
index 2d15a12a..7a7a502b 100644 | |
--- i/packages/jest-validate/build/warnings.js | |
+++ w/packages/jest-validate/build/warnings.js | |
@@ -10,38 +10,32 @@ | |
'use strict'; | |
- | |
- | |
-const chalk = require('chalk');var _require = | |
- | |
- | |
- | |
- | |
- | |
-require('./utils');const format = _require.format,logValidationWarning = _require.logValidationWarning,createDidYouMeanMessage = _require.createDidYouMeanMessage,WARNING = _require.WARNING; | |
- | |
-const unknownOptionWarning = ( | |
-config, | |
-exampleConfig, | |
-option, | |
-options) => | |
-{ | |
+const chalk = require('chalk'); | |
+var _require = require('./utils'); | |
+const format = _require.format, | |
+ logValidationWarning = _require.logValidationWarning, | |
+ createDidYouMeanMessage = _require.createDidYouMeanMessage, | |
+ WARNING = _require.WARNING; | |
+ | |
+const unknownOptionWarning = (config, exampleConfig, option, options) => { | |
const didYouMean = createDidYouMeanMessage( | |
- option, | |
- Object.keys(exampleConfig)); | |
+ option, | |
+ Object.keys(exampleConfig) | |
+ ); | |
/* eslint-disable max-len */ | |
const message = | |
- ` Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(format(config[option]))} was found.` + ( | |
- didYouMean && ` ${didYouMean}`) + | |
- `\n This is probably a typing mistake. Fixing it will remove this message.`; | |
+ ` Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(format(config[option]))} was found.` + | |
+ (didYouMean && ` ${didYouMean}`) + | |
+ `\n This is probably a typing mistake. Fixing it will remove this message.`; | |
/* eslint-enable max-len */ | |
const comment = options.comment; | |
- const name = options.title && options.title.warning || WARNING; | |
+ const name = (options.title && options.title.warning) || WARNING; | |
logValidationWarning(name, message, comment); | |
}; | |
module.exports = { | |
- unknownOptionWarning }; | |
\ No newline at end of file | |
+ unknownOptionWarning, | |
+}; | |
diff --git i/packages/jest/build/jest.js w/packages/jest/build/jest.js | |
index 0473bd9a..1ea779e3 100644 | |
--- i/packages/jest/build/jest.js | |
+++ w/packages/jest/build/jest.js | |
@@ -8,4 +8,4 @@ | |
'use strict'; | |
-module.exports = require('jest-cli'); | |
\ No newline at end of file | |
+module.exports = require('jest-cli'); | |
diff --git i/packages/pretty-format/build/index.js w/packages/pretty-format/build/index.js | |
index 37507834..401109c6 100644 | |
--- i/packages/pretty-format/build/index.js | |
+++ w/packages/pretty-format/build/index.js | |
@@ -11,38 +11,8 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const style = require('ansi-styles'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const toString = Object.prototype.toString; | |
const toISOString = Date.prototype.toISOString; | |
const errorToString = Error.prototype.toString; | |
@@ -67,8 +37,8 @@ function isToStringedArrayType(toStringed) { | |
toStringed === '[object Uint8Array]' || | |
toStringed === '[object Uint8ClampedArray]' || | |
toStringed === '[object Uint16Array]' || | |
- toStringed === '[object Uint32Array]'); | |
- | |
+ toStringed === '[object Uint32Array]' | |
+ ); | |
} | |
function printNumber(val) { | |
@@ -97,11 +67,7 @@ function printError(val) { | |
return '[' + errorToString.call(val) + ']'; | |
} | |
-function printBasicValue( | |
-val, | |
-printFunctionName, | |
-escapeRegex) | |
-{ | |
+function printBasicValue(val, printFunctionName, escapeRegex) { | |
if (val === true || val === false) { | |
return '' + val; | |
} | |
@@ -136,9 +102,9 @@ escapeRegex) | |
return 'WeakSet {}'; | |
} | |
if ( | |
- toStringed === '[object Function]' || | |
- toStringed === '[object GeneratorFunction]') | |
- { | |
+ toStringed === '[object Function]' || | |
+ toStringed === '[object GeneratorFunction]' | |
+ ) { | |
return printFunction(val, printFunctionName); | |
} | |
if (toStringed === '[object Symbol]') { | |
@@ -172,21 +138,21 @@ escapeRegex) | |
} | |
function printList( | |
-list, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
+ list, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
let body = ''; | |
if (list.length) { | |
@@ -196,23 +162,23 @@ colors) | |
for (let i = 0; i < list.length; i++) { | |
body += | |
- innerIndent + | |
- print( | |
- list[i], | |
- indent, | |
- innerIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ innerIndent + | |
+ print( | |
+ list[i], | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
if (i < list.length - 1) { | |
body += ',' + spacing; | |
@@ -226,109 +192,27 @@ colors) | |
} | |
function printArguments( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
return ( | |
(min ? '' : 'Arguments ') + | |
printList( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors)); | |
- | |
- | |
-} | |
- | |
-function printArray( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
- return ( | |
- (min ? '' : val.constructor.name + ' ') + | |
- printList( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors)); | |
- | |
- | |
-} | |
- | |
-function printMap( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
- let result = 'Map {'; | |
- const iterator = val.entries(); | |
- let current = iterator.next(); | |
- | |
- if (!current.done) { | |
- result += edgeSpacing; | |
- | |
- const innerIndent = prevIndent + indent; | |
- | |
- while (!current.done) { | |
- const key = print( | |
- current.value[0], | |
+ val, | |
indent, | |
- innerIndent, | |
+ prevIndent, | |
spacing, | |
edgeSpacing, | |
refs, | |
@@ -339,12 +223,33 @@ colors) | |
callToJSON, | |
printFunctionName, | |
escapeRegex, | |
- colors); | |
+ colors | |
+ ) | |
+ ); | |
+} | |
- const value = print( | |
- current.value[1], | |
+function printArray( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
+ return ( | |
+ (min ? '' : val.constructor.name + ' ') + | |
+ printList( | |
+ val, | |
indent, | |
- innerIndent, | |
+ prevIndent, | |
spacing, | |
edgeSpacing, | |
refs, | |
@@ -355,8 +260,70 @@ colors) | |
callToJSON, | |
printFunctionName, | |
escapeRegex, | |
- colors); | |
+ colors | |
+ ) | |
+ ); | |
+} | |
+ | |
+function printMap( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
+ let result = 'Map {'; | |
+ const iterator = val.entries(); | |
+ let current = iterator.next(); | |
+ | |
+ if (!current.done) { | |
+ result += edgeSpacing; | |
+ | |
+ const innerIndent = prevIndent + indent; | |
+ while (!current.done) { | |
+ const key = print( | |
+ current.value[0], | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
+ | |
+ const value = print( | |
+ current.value[1], | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
result += innerIndent + key + ' => ' + value; | |
@@ -374,37 +341,36 @@ colors) | |
} | |
function printObject( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
- const constructor = min ? | |
- '' : | |
- val.constructor ? val.constructor.name + ' ' : 'Object '; | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
+ const constructor = min | |
+ ? '' | |
+ : val.constructor ? val.constructor.name + ' ' : 'Object '; | |
let result = constructor + '{'; | |
let keys = Object.keys(val).sort(); | |
const symbols = getSymbols(val); | |
if (symbols.length) { | |
- keys = keys. | |
- filter( | |
- key => | |
- // $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value | |
- !(typeof key === 'symbol' || | |
- toString.call(key) === '[object Symbol]')). | |
- | |
- concat(symbols); | |
+ keys = keys | |
+ .filter( | |
+ key => | |
+ // $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value | |
+ !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]') | |
+ ) | |
+ .concat(symbols); | |
} | |
if (keys.length) { | |
@@ -415,37 +381,38 @@ colors) | |
for (let i = 0; i < keys.length; i++) { | |
const key = keys[i]; | |
const name = print( | |
- key, | |
- indent, | |
- innerIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
+ key, | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
const value = print( | |
- val[key], | |
- indent, | |
- innerIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ val[key], | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
result += innerIndent + name + ': ' + value; | |
@@ -461,21 +428,21 @@ colors) | |
} | |
function printSet( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
let result = 'Set {'; | |
const iterator = val.entries(); | |
let current = iterator.next(); | |
@@ -487,23 +454,23 @@ colors) | |
while (!current.done) { | |
result += | |
- innerIndent + | |
- print( | |
- current.value[1], | |
- indent, | |
- innerIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ innerIndent + | |
+ print( | |
+ current.value[1], | |
+ indent, | |
+ innerIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
current = iterator.next(); | |
@@ -519,21 +486,21 @@ colors) | |
} | |
function printComplexValue( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+) { | |
refs = refs.slice(); | |
if (refs.indexOf(val) > -1) { | |
return '[Circular]'; | |
@@ -546,111 +513,129 @@ colors) | |
const hitMaxDepth = currentDepth > maxDepth; | |
if ( | |
- callToJSON && | |
- !hitMaxDepth && | |
- val.toJSON && | |
- typeof val.toJSON === 'function') | |
- { | |
+ callToJSON && | |
+ !hitMaxDepth && | |
+ val.toJSON && | |
+ typeof val.toJSON === 'function' | |
+ ) { | |
return print( | |
- val.toJSON(), | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ val.toJSON(), | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} | |
const toStringed = toString.call(val); | |
if (toStringed === '[object Arguments]') { | |
- return hitMaxDepth ? | |
- '[Arguments]' : | |
- printArguments( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ return hitMaxDepth | |
+ ? '[Arguments]' | |
+ : printArguments( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} else if (isToStringedArrayType(toStringed)) { | |
- return hitMaxDepth ? | |
- '[Array]' : | |
- printArray( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ return hitMaxDepth | |
+ ? '[Array]' | |
+ : printArray( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} else if (toStringed === '[object Map]') { | |
- return hitMaxDepth ? | |
- '[Map]' : | |
- printMap( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ return hitMaxDepth | |
+ ? '[Map]' | |
+ : printMap( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} else if (toStringed === '[object Set]') { | |
- return hitMaxDepth ? | |
- '[Set]' : | |
- printSet( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
- } | |
+ return hitMaxDepth | |
+ ? '[Set]' | |
+ : printSet( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
+ } | |
+ | |
+ return hitMaxDepth | |
+ ? '[Object]' | |
+ : printObject( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
+} | |
- return hitMaxDepth ? | |
- '[Object]' : | |
- printObject( | |
+function printPlugin( | |
val, | |
indent, | |
prevIndent, | |
@@ -664,26 +649,8 @@ colors) | |
callToJSON, | |
printFunctionName, | |
escapeRegex, | |
- colors); | |
- | |
-} | |
- | |
-function printPlugin( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
+ colors | |
+) { | |
let plugin; | |
for (let p = 0; p < plugins.length; p++) { | |
@@ -699,21 +666,21 @@ colors) | |
function boundPrint(val) { | |
return print( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} | |
function boundIndent(str) { | |
@@ -724,28 +691,13 @@ colors) | |
const opts = { | |
edgeSpacing, | |
min, | |
- spacing }; | |
+ spacing, | |
+ }; | |
return plugin.print(val, boundPrint, boundIndent, opts, colors); | |
} | |
function print( | |
-val, | |
-indent, | |
-prevIndent, | |
-spacing, | |
-edgeSpacing, | |
-refs, | |
-maxDepth, | |
-currentDepth, | |
-plugins, | |
-min, | |
-callToJSON, | |
-printFunctionName, | |
-escapeRegex, | |
-colors) | |
-{ | |
- const pluginsResult = printPlugin( | |
val, | |
indent, | |
prevIndent, | |
@@ -759,7 +711,24 @@ colors) | |
callToJSON, | |
printFunctionName, | |
escapeRegex, | |
- colors); | |
+ colors | |
+) { | |
+ const pluginsResult = printPlugin( | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
if (typeof pluginsResult === 'string') { | |
return pluginsResult; | |
@@ -771,21 +740,21 @@ colors) | |
} | |
return printComplexValue( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- maxDepth, | |
- currentDepth, | |
- plugins, | |
- min, | |
- callToJSON, | |
- printFunctionName, | |
- escapeRegex, | |
- colors); | |
- | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ maxDepth, | |
+ currentDepth, | |
+ plugins, | |
+ min, | |
+ callToJSON, | |
+ printFunctionName, | |
+ escapeRegex, | |
+ colors | |
+ ); | |
} | |
const DEFAULTS = { | |
@@ -804,9 +773,9 @@ const DEFAULTS = { | |
content: 'reset', | |
prop: 'yellow', | |
tag: 'cyan', | |
- value: 'green' } }; | |
- | |
- | |
+ value: 'green', | |
+ }, | |
+}; | |
function validateOptions(opts) { | |
Object.keys(opts).forEach(key => { | |
@@ -817,8 +786,8 @@ function validateOptions(opts) { | |
if (opts.min && opts.indent !== undefined && opts.indent !== 0) { | |
throw new Error( | |
- 'pretty-format: Options "min" and "indent" cannot be used together.'); | |
- | |
+ 'pretty-format: Options "min" and "indent" cannot be used together.' | |
+ ); | |
} | |
} | |
@@ -826,11 +795,11 @@ function normalizeOptions(opts) { | |
const result = {}; | |
Object.keys(DEFAULTS).forEach( | |
- key => | |
- result[key] = opts.hasOwnProperty(key) ? | |
- key === 'theme' ? normalizeTheme(opts.theme) : opts[key] : | |
- DEFAULTS[key]); | |
- | |
+ key => | |
+ (result[key] = opts.hasOwnProperty(key) | |
+ ? key === 'theme' ? normalizeTheme(opts.theme) : opts[key] | |
+ : DEFAULTS[key]) | |
+ ); | |
if (result.min) { | |
result.indent = 0; | |
@@ -847,17 +816,17 @@ function normalizeTheme(themeOption) { | |
if (typeof themeOption !== 'object') { | |
throw new Error( | |
- `pretty-format: Option "theme" must be of type "object" but instead received "${typeof themeOption}".`); | |
- | |
+ `pretty-format: Option "theme" must be of type "object" but instead received "${typeof themeOption}".` | |
+ ); | |
} | |
// Silently ignore any keys in `theme` that are not in defaults. | |
const themeRefined = themeOption; | |
const themeDefaults = DEFAULTS.theme; | |
return Object.keys(themeDefaults).reduce((theme, key) => { | |
- theme[key] = Object.prototype.hasOwnProperty.call(themeOption, key) ? | |
- themeRefined[key] : | |
- themeDefaults[key]; | |
+ theme[key] = Object.prototype.hasOwnProperty.call(themeOption, key) | |
+ ? themeRefined[key] | |
+ : themeDefaults[key]; | |
return theme; | |
}, {}); | |
} | |
@@ -876,23 +845,24 @@ function prettyFormat(val, initialOptions) { | |
} | |
const colors = { | |
- comment: { close: '', open: '' }, | |
- content: { close: '', open: '' }, | |
- prop: { close: '', open: '' }, | |
- tag: { close: '', open: '' }, | |
- value: { close: '', open: '' } }; | |
+ comment: {close: '', open: ''}, | |
+ content: {close: '', open: ''}, | |
+ prop: {close: '', open: ''}, | |
+ tag: {close: '', open: ''}, | |
+ value: {close: '', open: ''}, | |
+ }; | |
Object.keys(opts.theme).forEach(key => { | |
if (opts.highlight) { | |
- const color = colors[key] = style[opts.theme[key]]; | |
+ const color = (colors[key] = style[opts.theme[key]]); | |
if ( | |
- !color || | |
- typeof color.close !== 'string' || | |
- typeof color.open !== 'string') | |
- { | |
+ !color || | |
+ typeof color.close !== 'string' || | |
+ typeof color.open !== 'string' | |
+ ) { | |
throw new Error( | |
- `pretty-format: Option "theme" has a key "${key}" whose value "${opts.theme[key]}" is undefined in ansi-styles.`); | |
- | |
+ `pretty-format: Option "theme" has a key "${key}" whose value "${opts.theme[key]}" is undefined in ansi-styles.` | |
+ ); | |
} | |
} | |
}); | |
@@ -908,20 +878,21 @@ function prettyFormat(val, initialOptions) { | |
indent = createIndent(opts.indent); | |
refs = []; | |
const pluginsResult = printPlugin( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- opts.maxDepth, | |
- currentDepth, | |
- opts.plugins, | |
- opts.min, | |
- opts.callToJSON, | |
- opts.printFunctionName, | |
- opts.escapeRegex, | |
- colors); | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ opts.maxDepth, | |
+ currentDepth, | |
+ opts.plugins, | |
+ opts.min, | |
+ opts.callToJSON, | |
+ opts.printFunctionName, | |
+ opts.escapeRegex, | |
+ colors | |
+ ); | |
if (typeof pluginsResult === 'string') { | |
return pluginsResult; | |
@@ -929,9 +900,10 @@ function prettyFormat(val, initialOptions) { | |
} | |
const basicResult = printBasicValue( | |
- val, | |
- opts.printFunctionName, | |
- opts.escapeRegex); | |
+ val, | |
+ opts.printFunctionName, | |
+ opts.escapeRegex | |
+ ); | |
if (basicResult !== null) { | |
return basicResult; | |
@@ -944,21 +916,21 @@ function prettyFormat(val, initialOptions) { | |
refs = []; | |
} | |
return printComplexValue( | |
- val, | |
- indent, | |
- prevIndent, | |
- spacing, | |
- edgeSpacing, | |
- refs, | |
- opts.maxDepth, | |
- currentDepth, | |
- opts.plugins, | |
- opts.min, | |
- opts.callToJSON, | |
- opts.printFunctionName, | |
- opts.escapeRegex, | |
- colors); | |
- | |
+ val, | |
+ indent, | |
+ prevIndent, | |
+ spacing, | |
+ edgeSpacing, | |
+ refs, | |
+ opts.maxDepth, | |
+ currentDepth, | |
+ opts.plugins, | |
+ opts.min, | |
+ opts.callToJSON, | |
+ opts.printFunctionName, | |
+ opts.escapeRegex, | |
+ colors | |
+ ); | |
} | |
prettyFormat.plugins = { | |
@@ -967,7 +939,7 @@ prettyFormat.plugins = { | |
HTMLElement: require('./plugins/HTMLElement'), | |
Immutable: require('./plugins/ImmutablePlugins'), | |
ReactElement: require('./plugins/ReactElement'), | |
- ReactTestComponent: require('./plugins/ReactTestComponent') }; | |
- | |
+ ReactTestComponent: require('./plugins/ReactTestComponent'), | |
+}; | |
-module.exports = prettyFormat; | |
\ No newline at end of file | |
+module.exports = prettyFormat; | |
diff --git i/packages/pretty-format/build/plugins/AsymmetricMatcher.js w/packages/pretty-format/build/plugins/AsymmetricMatcher.js | |
index dc0fe104..68673a59 100644 | |
--- i/packages/pretty-format/build/plugins/AsymmetricMatcher.js | |
+++ w/packages/pretty-format/build/plugins/AsymmetricMatcher.js | |
@@ -10,35 +10,27 @@ | |
'use strict'; | |
- | |
- | |
const asymmetricMatcher = Symbol.for('jest.asymmetricMatcher'); | |
const SPACE = ' '; | |
class ArrayContaining extends Array {} | |
class ObjectContaining extends Object {} | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-{ | |
+const print = (val, print, indent, opts, colors) => { | |
const stringedValue = val.toString(); | |
if (stringedValue === 'ArrayContaining') { | |
const array = ArrayContaining.from(val.sample); | |
- return opts.spacing === SPACE ? | |
- stringedValue + SPACE + print(array) : | |
- print(array); | |
+ return opts.spacing === SPACE | |
+ ? stringedValue + SPACE + print(array) | |
+ : print(array); | |
} | |
if (stringedValue === 'ObjectContaining') { | |
const object = Object.assign(new ObjectContaining(), val.sample); | |
- return opts.spacing === SPACE ? | |
- stringedValue + SPACE + print(object) : | |
- print(object); | |
+ return opts.spacing === SPACE | |
+ ? stringedValue + SPACE + print(object) | |
+ : print(object); | |
} | |
if (stringedValue === 'StringMatching') { | |
@@ -54,4 +46,4 @@ colors) => | |
const test = object => object && object.$$typeof === asymmetricMatcher; | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ConvertAnsi.js w/packages/pretty-format/build/plugins/ConvertAnsi.js | |
index d8bdc276..27d92ae1 100644 | |
--- i/packages/pretty-format/build/plugins/ConvertAnsi.js | |
+++ w/packages/pretty-format/build/plugins/ConvertAnsi.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const ansiRegex = require('ansi-regex'); | |
const toHumanReadableAnsi = text => { | |
@@ -32,20 +30,14 @@ const toHumanReadableAnsi = text => { | |
case style.bold.open: | |
return '<bold>'; | |
default: | |
- return '';} | |
- | |
+ return ''; | |
+ } | |
}); | |
}; | |
-const test = value => | |
-typeof value === 'string' && value.match(ansiRegex()); | |
+const test = value => typeof value === 'string' && value.match(ansiRegex()); | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-print(toHumanReadableAnsi(val)); | |
+const print = (val, print, indent, opts, colors) => | |
+ print(toHumanReadableAnsi(val)); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/HTMLElement.js w/packages/pretty-format/build/plugins/HTMLElement.js | |
index 017eebf0..bbe6da90 100644 | |
--- i/packages/pretty-format/build/plugins/HTMLElement.js | |
+++ w/packages/pretty-format/build/plugins/HTMLElement.js | |
@@ -10,97 +10,67 @@ | |
'use strict'; | |
- | |
- | |
const escapeHTML = require('./lib/escapeHTML'); | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const HTML_ELEMENT_REGEXP = /(HTML\w*?Element)|Text|Comment/; | |
const test = isHTMLElement; | |
function isHTMLElement(value) { | |
return ( | |
value !== undefined && | |
- value !== null && ( | |
- value.nodeType === 1 || value.nodeType === 3 || value.nodeType === 8) && | |
+ value !== null && | |
+ (value.nodeType === 1 || value.nodeType === 3 || value.nodeType === 8) && | |
value.constructor !== undefined && | |
value.constructor.name !== undefined && | |
- HTML_ELEMENT_REGEXP.test(value.constructor.name)); | |
- | |
+ HTML_ELEMENT_REGEXP.test(value.constructor.name) | |
+ ); | |
} | |
function printChildren(flatChildren, print, indent, colors, opts) { | |
- return flatChildren. | |
- map(node => { | |
- if (typeof node === 'object') { | |
- return print(node, print, indent, colors, opts); | |
- } else if (typeof node === 'string') { | |
- return colors.content.open + escapeHTML(node) + colors.content.close; | |
- } else { | |
- return print(node); | |
- } | |
- }). | |
- filter(value => value.trim().length). | |
- join(opts.edgeSpacing); | |
+ return flatChildren | |
+ .map(node => { | |
+ if (typeof node === 'object') { | |
+ return print(node, print, indent, colors, opts); | |
+ } else if (typeof node === 'string') { | |
+ return colors.content.open + escapeHTML(node) + colors.content.close; | |
+ } else { | |
+ return print(node); | |
+ } | |
+ }) | |
+ .filter(value => value.trim().length) | |
+ .join(opts.edgeSpacing); | |
} | |
function printAttributes(attributes, indent, colors, opts) { | |
- return attributes. | |
- sort(). | |
- map(attribute => { | |
- return ( | |
- opts.spacing + | |
- indent(colors.prop.open + attribute.name + colors.prop.close + '=') + | |
- colors.value.open + | |
- `"${attribute.value}"` + | |
- colors.value.close); | |
- | |
- }). | |
- join(''); | |
+ return attributes | |
+ .sort() | |
+ .map(attribute => { | |
+ return ( | |
+ opts.spacing + | |
+ indent(colors.prop.open + attribute.name + colors.prop.close + '=') + | |
+ colors.value.open + | |
+ `"${attribute.value}"` + | |
+ colors.value.close | |
+ ); | |
+ }) | |
+ .join(''); | |
} | |
-const print = ( | |
-element, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-{ | |
+const print = (element, print, indent, opts, colors) => { | |
if (element.nodeType === 3) { | |
- return element.data. | |
- split('\n'). | |
- map(text => text.trimLeft()). | |
- filter(text => text.length). | |
- join(' '); | |
+ return element.data | |
+ .split('\n') | |
+ .map(text => text.trimLeft()) | |
+ .filter(text => text.length) | |
+ .join(' '); | |
} else if (element.nodeType === 8) { | |
return ( | |
colors.comment.open + | |
'<!-- ' + | |
element.data.trim() + | |
' -->' + | |
- colors.comment.close); | |
- | |
+ colors.comment.close | |
+ ); | |
} | |
let result = colors.tag.open + '<'; | |
@@ -122,24 +92,24 @@ colors) => | |
if (flatChildren.length) { | |
const children = printChildren(flatChildren, print, indent, colors, opts); | |
result += | |
- colors.tag.open + ( | |
- closeInNewLine ? '\n' : '') + | |
- '>' + | |
- colors.tag.close + | |
- opts.edgeSpacing + | |
- indent(children) + | |
- opts.edgeSpacing + | |
- colors.tag.open + | |
- '</' + | |
- elementName + | |
- '>' + | |
- colors.tag.close; | |
+ colors.tag.open + | |
+ (closeInNewLine ? '\n' : '') + | |
+ '>' + | |
+ colors.tag.close + | |
+ opts.edgeSpacing + | |
+ indent(children) + | |
+ opts.edgeSpacing + | |
+ colors.tag.open + | |
+ '</' + | |
+ elementName + | |
+ '>' + | |
+ colors.tag.close; | |
} else { | |
result += | |
- colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
+ colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
} | |
return result; | |
}; | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableList.js w/packages/pretty-format/build/plugins/ImmutableList.js | |
index a00c9bb3..0fef12e0 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableList.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableList.js | |
@@ -10,19 +10,12 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_LIST = '@@__IMMUTABLE_LIST__@@'; | |
const test = maybeList => !!(maybeList && maybeList[IS_LIST]); | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'List', false); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'List', false); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableMap.js w/packages/pretty-format/build/plugins/ImmutableMap.js | |
index 5d66b0ce..d9fabebe 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableMap.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableMap.js | |
@@ -10,21 +10,14 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_MAP = '@@__IMMUTABLE_MAP__@@'; | |
const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@'; | |
const test = maybeMap => | |
-!!(maybeMap && maybeMap[IS_MAP] && !maybeMap[IS_ORDERED]); | |
+ !!(maybeMap && maybeMap[IS_MAP] && !maybeMap[IS_ORDERED]); | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'Map', true); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'Map', true); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableOrderedMap.js w/packages/pretty-format/build/plugins/ImmutableOrderedMap.js | |
index af23ef9a..2edb5179 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableOrderedMap.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableOrderedMap.js | |
@@ -10,21 +10,14 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_MAP = '@@__IMMUTABLE_MAP__@@'; | |
const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@'; | |
const test = maybeOrderedMap => | |
-maybeOrderedMap && maybeOrderedMap[IS_MAP] && maybeOrderedMap[IS_ORDERED]; | |
+ maybeOrderedMap && maybeOrderedMap[IS_MAP] && maybeOrderedMap[IS_ORDERED]; | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'OrderedMap', true); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'OrderedMap', true); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableOrderedSet.js w/packages/pretty-format/build/plugins/ImmutableOrderedSet.js | |
index 48a3dffc..30b4c864 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableOrderedSet.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableOrderedSet.js | |
@@ -10,21 +10,14 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_SET = '@@__IMMUTABLE_SET__@@'; | |
const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@'; | |
const test = maybeOrderedSet => | |
-maybeOrderedSet && maybeOrderedSet[IS_SET] && maybeOrderedSet[IS_ORDERED]; | |
+ maybeOrderedSet && maybeOrderedSet[IS_SET] && maybeOrderedSet[IS_ORDERED]; | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'OrderedSet', false); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'OrderedSet', false); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutablePlugins.js w/packages/pretty-format/build/plugins/ImmutablePlugins.js | |
index 209271f4..c7fac292 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutablePlugins.js | |
+++ w/packages/pretty-format/build/plugins/ImmutablePlugins.js | |
@@ -11,9 +11,10 @@ | |
'use strict'; | |
module.exports = [ | |
-require('./ImmutableList'), | |
-require('./ImmutableSet'), | |
-require('./ImmutableMap'), | |
-require('./ImmutableStack'), | |
-require('./ImmutableOrderedSet'), | |
-require('./ImmutableOrderedMap')]; | |
\ No newline at end of file | |
+ require('./ImmutableList'), | |
+ require('./ImmutableSet'), | |
+ require('./ImmutableMap'), | |
+ require('./ImmutableStack'), | |
+ require('./ImmutableOrderedSet'), | |
+ require('./ImmutableOrderedMap'), | |
+]; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableSet.js w/packages/pretty-format/build/plugins/ImmutableSet.js | |
index 957f138c..a90ae80b 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableSet.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableSet.js | |
@@ -10,21 +10,14 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_SET = '@@__IMMUTABLE_SET__@@'; | |
const IS_ORDERED = '@@__IMMUTABLE_ORDERED__@@'; | |
const test = maybeSet => | |
-!!(maybeSet && maybeSet[IS_SET] && !maybeSet[IS_ORDERED]); | |
+ !!(maybeSet && maybeSet[IS_SET] && !maybeSet[IS_ORDERED]); | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'Set', false); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'Set', false); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ImmutableStack.js w/packages/pretty-format/build/plugins/ImmutableStack.js | |
index 7ce457cc..392f2675 100644 | |
--- i/packages/pretty-format/build/plugins/ImmutableStack.js | |
+++ w/packages/pretty-format/build/plugins/ImmutableStack.js | |
@@ -10,19 +10,12 @@ | |
'use strict'; | |
- | |
- | |
const printImmutable = require('./lib/printImmutable'); | |
const IS_STACK = '@@__IMMUTABLE_STACK__@@'; | |
const test = maybeStack => !!(maybeStack && maybeStack[IS_STACK]); | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printImmutable(val, print, indent, opts, colors, 'Stack', false); | |
+const print = (val, print, indent, opts, colors) => | |
+ printImmutable(val, print, indent, opts, colors, 'Stack', false); | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ReactElement.js w/packages/pretty-format/build/plugins/ReactElement.js | |
index a2366065..6af451fd 100644 | |
--- i/packages/pretty-format/build/plugins/ReactElement.js | |
+++ w/packages/pretty-format/build/plugins/ReactElement.js | |
@@ -10,8 +10,6 @@ | |
'use strict'; | |
- | |
- | |
const escapeHTML = require('./lib/escapeHTML'); | |
const reactElement = Symbol.for('react.element'); | |
@@ -25,59 +23,53 @@ function traverseChildren(opaqueChildren, cb) { | |
} | |
function printChildren(flatChildren, print, indent, colors, opts) { | |
- return flatChildren. | |
- map(node => { | |
- if (typeof node === 'object') { | |
- return print(node, print, indent, colors, opts); | |
- } else if (typeof node === 'string') { | |
- return colors.content.open + escapeHTML(node) + colors.content.close; | |
- } else { | |
- return print(node); | |
- } | |
- }). | |
- join(opts.edgeSpacing); | |
+ return flatChildren | |
+ .map(node => { | |
+ if (typeof node === 'object') { | |
+ return print(node, print, indent, colors, opts); | |
+ } else if (typeof node === 'string') { | |
+ return colors.content.open + escapeHTML(node) + colors.content.close; | |
+ } else { | |
+ return print(node); | |
+ } | |
+ }) | |
+ .join(opts.edgeSpacing); | |
} | |
function printProps(props, print, indent, colors, opts) { | |
- return Object.keys(props). | |
- sort(). | |
- map(name => { | |
- if (name === 'children') { | |
- return ''; | |
- } | |
- | |
- const prop = props[name]; | |
- let printed = print(prop); | |
- | |
- if (typeof prop !== 'string') { | |
- if (printed.indexOf('\n') !== -1) { | |
- printed = | |
- '{' + | |
- opts.edgeSpacing + | |
- indent(indent(printed) + opts.edgeSpacing + '}'); | |
- } else { | |
- printed = '{' + printed + '}'; | |
+ return Object.keys(props) | |
+ .sort() | |
+ .map(name => { | |
+ if (name === 'children') { | |
+ return ''; | |
} | |
- } | |
- return ( | |
- opts.spacing + | |
- indent(colors.prop.open + name + colors.prop.close + '=') + | |
- colors.value.open + | |
- printed + | |
- colors.value.close); | |
+ const prop = props[name]; | |
+ let printed = print(prop); | |
+ | |
+ if (typeof prop !== 'string') { | |
+ if (printed.indexOf('\n') !== -1) { | |
+ printed = | |
+ '{' + | |
+ opts.edgeSpacing + | |
+ indent(indent(printed) + opts.edgeSpacing + '}'); | |
+ } else { | |
+ printed = '{' + printed + '}'; | |
+ } | |
+ } | |
- }). | |
- join(''); | |
+ return ( | |
+ opts.spacing + | |
+ indent(colors.prop.open + name + colors.prop.close + '=') + | |
+ colors.value.open + | |
+ printed + | |
+ colors.value.close | |
+ ); | |
+ }) | |
+ .join(''); | |
} | |
-const print = ( | |
-element, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-{ | |
+const print = (element, print, indent, opts, colors) => { | |
let result = colors.tag.open + '<'; | |
let elementName; | |
if (typeof element.type === 'string') { | |
@@ -92,8 +84,8 @@ colors) => | |
const opaqueChildren = element.props.children; | |
const hasProps = !!Object.keys(element.props).filter( | |
- propName => propName !== 'children'). | |
- length; | |
+ propName => propName !== 'children' | |
+ ).length; | |
const closeInNewLine = hasProps && !opts.min; | |
if (opaqueChildren) { | |
@@ -103,21 +95,21 @@ colors) => | |
}); | |
const children = printChildren(flatChildren, print, indent, colors, opts); | |
result += | |
- colors.tag.open + ( | |
- closeInNewLine ? '\n' : '') + | |
- '>' + | |
- colors.tag.close + | |
- opts.edgeSpacing + | |
- indent(children) + | |
- opts.edgeSpacing + | |
- colors.tag.open + | |
- '</' + | |
- elementName + | |
- '>' + | |
- colors.tag.close; | |
+ colors.tag.open + | |
+ (closeInNewLine ? '\n' : '') + | |
+ '>' + | |
+ colors.tag.close + | |
+ opts.edgeSpacing + | |
+ indent(children) + | |
+ opts.edgeSpacing + | |
+ colors.tag.open + | |
+ '</' + | |
+ elementName + | |
+ '>' + | |
+ colors.tag.close; | |
} else { | |
result += | |
- colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
+ colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
} | |
return result; | |
@@ -125,4 +117,4 @@ colors) => | |
const test = object => object && object.$$typeof === reactElement; | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/ReactTestComponent.js w/packages/pretty-format/build/plugins/ReactTestComponent.js | |
index a56a82dc..3efb008f 100644 | |
--- i/packages/pretty-format/build/plugins/ReactTestComponent.js | |
+++ w/packages/pretty-format/build/plugins/ReactTestComponent.js | |
@@ -10,59 +10,43 @@ | |
'use strict'; | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
- | |
const escapeHTML = require('./lib/escapeHTML'); | |
const reactTestInstance = Symbol.for('react.test.json'); | |
-function printChildren( | |
-children, | |
-print, | |
-indent, | |
-colors, | |
-opts) | |
-{ | |
- return children. | |
- map(child => printInstance(child, print, indent, colors, opts)). | |
- join(opts.edgeSpacing); | |
+function printChildren(children, print, indent, colors, opts) { | |
+ return children | |
+ .map(child => printInstance(child, print, indent, colors, opts)) | |
+ .join(opts.edgeSpacing); | |
} | |
function printProps(props, print, indent, colors, opts) { | |
- return Object.keys(props). | |
- sort(). | |
- map(name => { | |
- const prop = props[name]; | |
- let printed = print(prop); | |
- | |
- if (typeof prop !== 'string') { | |
- if (printed.indexOf('\n') !== -1) { | |
- printed = | |
- '{' + | |
- opts.edgeSpacing + | |
- indent(indent(printed) + opts.edgeSpacing + '}'); | |
- } else { | |
- printed = '{' + printed + '}'; | |
+ return Object.keys(props) | |
+ .sort() | |
+ .map(name => { | |
+ const prop = props[name]; | |
+ let printed = print(prop); | |
+ | |
+ if (typeof prop !== 'string') { | |
+ if (printed.indexOf('\n') !== -1) { | |
+ printed = | |
+ '{' + | |
+ opts.edgeSpacing + | |
+ indent(indent(printed) + opts.edgeSpacing + '}'); | |
+ } else { | |
+ printed = '{' + printed + '}'; | |
+ } | |
} | |
- } | |
- | |
- return ( | |
- opts.spacing + | |
- indent(colors.prop.open + name + colors.prop.close + '=') + | |
- colors.value.open + | |
- printed + | |
- colors.value.close); | |
- }). | |
- join(''); | |
+ return ( | |
+ opts.spacing + | |
+ indent(colors.prop.open + name + colors.prop.close + '=') + | |
+ colors.value.open + | |
+ printed + | |
+ colors.value.close | |
+ ); | |
+ }) | |
+ .join(''); | |
} | |
function printInstance(instance, print, indent, colors, opts) { | |
@@ -82,42 +66,37 @@ function printInstance(instance, print, indent, colors, opts) { | |
if (instance.children) { | |
const children = printChildren( | |
- instance.children, | |
- print, | |
- indent, | |
- colors, | |
- opts); | |
+ instance.children, | |
+ print, | |
+ indent, | |
+ colors, | |
+ opts | |
+ ); | |
result += | |
- colors.tag.open + ( | |
- closeInNewLine ? '\n' : '') + | |
- '>' + | |
- colors.tag.close + | |
- opts.edgeSpacing + | |
- indent(children) + | |
- opts.edgeSpacing + | |
- colors.tag.open + | |
- '</' + | |
- instance.type + | |
- '>' + | |
- colors.tag.close; | |
+ colors.tag.open + | |
+ (closeInNewLine ? '\n' : '') + | |
+ '>' + | |
+ colors.tag.close + | |
+ opts.edgeSpacing + | |
+ indent(children) + | |
+ opts.edgeSpacing + | |
+ colors.tag.open + | |
+ '</' + | |
+ instance.type + | |
+ '>' + | |
+ colors.tag.close; | |
} else { | |
result += | |
- colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
+ colors.tag.open + (closeInNewLine ? '\n' : ' ') + '/>' + colors.tag.close; | |
} | |
return result; | |
} | |
-const print = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors) => | |
-printInstance(val, print, indent, colors, opts); | |
+const print = (val, print, indent, opts, colors) => | |
+ printInstance(val, print, indent, colors, opts); | |
-const test = object => | |
-object && object.$$typeof === reactTestInstance; | |
+const test = object => object && object.$$typeof === reactTestInstance; | |
-module.exports = { print, test }; | |
\ No newline at end of file | |
+module.exports = {print, test}; | |
diff --git i/packages/pretty-format/build/plugins/lib/escapeHTML.js w/packages/pretty-format/build/plugins/lib/escapeHTML.js | |
index de6dda18..8154576b 100644 | |
--- i/packages/pretty-format/build/plugins/lib/escapeHTML.js | |
+++ w/packages/pretty-format/build/plugins/lib/escapeHTML.js | |
@@ -13,4 +13,4 @@ function escapeHTML(str) { | |
return str.replace(/</g, '<').replace(/>/g, '>'); | |
} | |
-module.exports = escapeHTML; | |
\ No newline at end of file | |
+module.exports = escapeHTML; | |
diff --git i/packages/pretty-format/build/plugins/lib/printImmutable.js w/packages/pretty-format/build/plugins/lib/printImmutable.js | |
index f7a9c45a..2885b463 100644 | |
--- i/packages/pretty-format/build/plugins/lib/printImmutable.js | |
+++ w/packages/pretty-format/build/plugins/lib/printImmutable.js | |
@@ -8,41 +8,79 @@ | |
* | |
*/ | |
-'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}(); | |
- | |
- | |
+'use strict'; | |
+var _slicedToArray = (function() { | |
+ function sliceIterator(arr, i) { | |
+ var _arr = []; | |
+ var _n = true; | |
+ var _d = false; | |
+ var _e = undefined; | |
+ try { | |
+ for ( | |
+ var _i = arr[Symbol.iterator](), _s; | |
+ !(_n = (_s = _i.next()).done); | |
+ _n = true | |
+ ) { | |
+ _arr.push(_s.value); | |
+ if (i && _arr.length === i) break; | |
+ } | |
+ } catch (err) { | |
+ _d = true; | |
+ _e = err; | |
+ } finally { | |
+ try { | |
+ if (!_n && _i['return']) _i['return'](); | |
+ } finally { | |
+ if (_d) throw _e; | |
+ } | |
+ } | |
+ return _arr; | |
+ } | |
+ return function(arr, i) { | |
+ if (Array.isArray(arr)) { | |
+ return arr; | |
+ } else if (Symbol.iterator in Object(arr)) { | |
+ return sliceIterator(arr, i); | |
+ } else { | |
+ throw new TypeError( | |
+ 'Invalid attempt to destructure non-iterable instance' | |
+ ); | |
+ } | |
+ }; | |
+})(); | |
const IMMUTABLE_NAMESPACE = 'Immutable.'; | |
const SPACE = ' '; | |
-const addKey = (isMap, key) => isMap ? key + ': ' : ''; | |
+const addKey = (isMap, key) => (isMap ? key + ': ' : ''); | |
const addFinalEdgeSpacing = (length, edgeSpacing) => | |
-length > 0 ? edgeSpacing : ''; | |
+ length > 0 ? edgeSpacing : ''; | |
const printImmutable = ( | |
-val, | |
-print, | |
-indent, | |
-opts, | |
-colors, | |
-immutableDataStructureName, | |
-isMap) => | |
-{var _ref = | |
- isMap ? ['{', '}'] : ['[', ']'],_ref2 = _slicedToArray(_ref, 2);const openTag = _ref2[0],closeTag = _ref2[1]; | |
+ val, | |
+ print, | |
+ indent, | |
+ opts, | |
+ colors, | |
+ immutableDataStructureName, | |
+ isMap | |
+) => { | |
+ var _ref = isMap ? ['{', '}'] : ['[', ']'], _ref2 = _slicedToArray(_ref, 2); | |
+ const openTag = _ref2[0], closeTag = _ref2[1]; | |
let result = | |
- IMMUTABLE_NAMESPACE + | |
- immutableDataStructureName + | |
- SPACE + | |
- openTag + | |
- opts.edgeSpacing; | |
+ IMMUTABLE_NAMESPACE + | |
+ immutableDataStructureName + | |
+ SPACE + | |
+ openTag + | |
+ opts.edgeSpacing; | |
const immutableArray = []; | |
val.forEach((item, key) => | |
- immutableArray.push( | |
- indent(addKey(isMap, key) + print(item, print, indent, opts, colors)))); | |
- | |
- | |
+ immutableArray.push( | |
+ indent(addKey(isMap, key) + print(item, print, indent, opts, colors)) | |
+ ) | |
+ ); | |
result += immutableArray.join(',' + opts.spacing); | |
if (!opts.min && immutableArray.length > 0) { | |
@@ -52,8 +90,8 @@ isMap) => | |
return ( | |
result + | |
addFinalEdgeSpacing(immutableArray.length, opts.edgeSpacing) + | |
- closeTag); | |
- | |
+ closeTag | |
+ ); | |
}; | |
-module.exports = printImmutable; | |
\ No newline at end of file | |
+module.exports = printImmutable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment