@rwx-research/jest-runner
Advanced tools
Comparing version 29.3.100-alpha.4 to 29.3.100-alpha.5
@@ -7,2 +7,10 @@ 'use strict'; | ||
exports.abqSpawnedMessage = void 0; | ||
/** | ||
* Copyright (c) ReadWriteExecute, Inc. and its affiliates. All Rights Reserved. | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
@@ -12,3 +20,3 @@ | ||
{ | ||
version: '29.3.100-alpha.4', | ||
version: '29.3.100-alpha.5', | ||
packages: [ | ||
@@ -15,0 +23,0 @@ { |
@@ -14,2 +14,9 @@ /** | ||
/** | ||
* Copyright (c) ReadWriteExecute, Inc. and its affiliates. All Rights Reserved. | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
export declare const abqSpawnedMessage: { | ||
@@ -16,0 +23,0 @@ adapterName: string; |
@@ -199,3 +199,5 @@ 'use strict'; | ||
} | ||
console.error('creating abq run'); | ||
return new Promise((resolve, reject) => { | ||
console.error('starting'); | ||
Abq() | ||
@@ -225,3 +227,2 @@ .connect(abqConfig, _abq2.abqSpawnedMessage) | ||
const fileName = resolveTestPath(testCase.meta.fileName); | ||
const testName = testCase.meta.testName; | ||
const test = tests.find(t => t.path === fileName); | ||
@@ -231,12 +232,7 @@ if (!test) { | ||
} | ||
let testConfig; | ||
if (testName) { | ||
testConfig = { | ||
...this._globalConfig, | ||
testNamePattern: testName | ||
}; | ||
} else { | ||
testConfig = this._globalConfig; | ||
} | ||
// NB: if individual-test running is supported, the configuration | ||
// must be modified to drill-down on a test. | ||
const testConfig = this._globalConfig; | ||
// Estimated start time used in estimating the runtime when the test | ||
@@ -266,6 +262,19 @@ // will ultimately error-out. The estimation is imprecise because the | ||
} | ||
function millisecondToNanosecond(ms) { | ||
return ms * 1000000; | ||
} | ||
if (resultIsError(result)) { | ||
if (!resultIsError(result)) { | ||
// The runtime of the whole file, to be used in place of a | ||
// per-test runtime, if it is missing for some reason. | ||
const estimatedRuntime = result.perfStats | ||
? millisecondToNanosecond(result.perfStats.runtime) | ||
: 0; | ||
const testResults = formatAbqFileTestResults( | ||
fileName, | ||
result, | ||
test.context.config, | ||
testConfig, | ||
estimatedRuntime | ||
); | ||
testResultMessage = { | ||
test_results: testResults | ||
}; | ||
} else { | ||
const estimatedRuntime = millisecondToNanosecond( | ||
@@ -286,3 +295,3 @@ estimatedStartTime - Date.now() | ||
test_result: { | ||
display_name: testName || fileName, | ||
display_name: fileName, | ||
id: testCase.id, | ||
@@ -301,26 +310,2 @@ meta: {}, | ||
}; | ||
} else { | ||
const runtime = result.perfStats | ||
? millisecondToNanosecond(result.perfStats.runtime) | ||
: 0; | ||
let status; | ||
if (result.numFailingTests > 0) { | ||
status = { | ||
type: 'failure' | ||
}; | ||
} else { | ||
status = { | ||
type: 'success' | ||
}; | ||
} | ||
testResultMessage = { | ||
test_result: { | ||
display_name: testName || fileName, | ||
id: testCase.id, | ||
meta: {}, | ||
output: result.failureMessage, | ||
runtime, | ||
status | ||
} | ||
}; | ||
} | ||
@@ -332,3 +317,3 @@ return Abq().protocolWrite(socket, testResultMessage); | ||
test_result: { | ||
display_name: testName || fileName, | ||
display_name: fileName, | ||
id: testCase.id, | ||
@@ -456,2 +441,129 @@ meta: {}, | ||
exports.default = TestRunner; | ||
function millisecondToNanosecond(ms) { | ||
return ms * 1000000; | ||
} | ||
function formatAbqLocation(fileName, callsite) { | ||
return { | ||
column: callsite?.column, | ||
file: fileName, | ||
line: callsite?.line | ||
}; | ||
} | ||
function formatAbqStatus(status, failureMessages, options) { | ||
switch (status) { | ||
case 'passed': { | ||
return { | ||
type: 'success' | ||
}; | ||
} | ||
case 'failed': { | ||
if (failureMessages.length === 0) { | ||
return { | ||
type: 'failure' | ||
}; | ||
} | ||
const backtraces = []; | ||
let exceptions = ''; | ||
for (const errorAndBt of failureMessages) { | ||
const {message, stack} = (0, | ||
_jestMessageUtil().separateMessageFromStack)(errorAndBt); | ||
const optnewline = exceptions.length === 0 ? '' : '\n'; | ||
exceptions += `${optnewline}${message}`; | ||
const stackTraceLines = (0, _jestMessageUtil().getStackTraceLines)( | ||
stack, | ||
options | ||
); | ||
if (backtraces.length > 0) { | ||
backtraces.push('\n'); | ||
} | ||
for (const stackTraceLine of stackTraceLines) { | ||
// The formatter might keep around leading whitespace or empty lines; | ||
// drop those. | ||
const stLine = stackTraceLine.trimLeft(); | ||
if (stLine.length > 0) { | ||
backtraces.push(stLine); | ||
} | ||
} | ||
} | ||
return { | ||
backtrace: backtraces, | ||
exception: exceptions, | ||
type: 'failure' | ||
}; | ||
} | ||
case 'pending': { | ||
return { | ||
type: 'pending' | ||
}; | ||
} | ||
case 'skipped': { | ||
return { | ||
type: 'skipped' | ||
}; | ||
} | ||
case 'todo': { | ||
return { | ||
type: 'todo' | ||
}; | ||
} | ||
case 'disabled': { | ||
return { | ||
type: 'skipped' | ||
}; | ||
} | ||
} | ||
} | ||
function formatAbqFileTestResults( | ||
fileName, | ||
jestTestFileResult, | ||
config, | ||
options, | ||
estimatedRuntime | ||
) { | ||
const results = []; | ||
for (const jestResult of jestTestFileResult.testResults) { | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const { | ||
ancestorTitles, | ||
duration, | ||
failureDetails: _failureDetails, | ||
failureMessages, | ||
fullName, | ||
location: optCallsite, | ||
numPassingAsserts: _numPassingAsserts, | ||
retryReasons: _retryReasons, | ||
status: jestStatus, | ||
title: _title | ||
} = jestResult; | ||
/* eslint-enable @typescript-eslint/no-unused-vars */ | ||
// It appears that jest runners will sometimes report the duration observed | ||
// for a failure after the first in a file as zero-timed; in these cases, | ||
// use the estimated runtime. | ||
const runtime = duration | ||
? millisecondToNanosecond(duration) | ||
: estimatedRuntime; | ||
const location = formatAbqLocation(fileName, optCallsite); | ||
const status = formatAbqStatus(jestStatus, failureMessages, options); | ||
const output = (0, _jestMessageUtil().formatResultsErrors)( | ||
[jestResult], | ||
// XREF jest-jasmine2's calling of formatResultsErrors | ||
config, | ||
options, | ||
jestTestFileResult.testFilePath | ||
); | ||
const result = { | ||
display_name: fullName, | ||
id: fullName, | ||
lineage: ancestorTitles, | ||
location, | ||
meta: {}, | ||
output, | ||
runtime, | ||
status | ||
}; | ||
results.push(result); | ||
} | ||
return results; | ||
} | ||
class CancelRun extends Error { | ||
@@ -458,0 +570,0 @@ constructor(message) { |
{ | ||
"name": "@rwx-research/jest-runner", | ||
"version": "29.3.100-alpha.4", | ||
"version": "29.3.100-alpha.5", | ||
"repository": { | ||
@@ -25,3 +25,3 @@ "type": "git", | ||
"@jest/types": "^29.3.1", | ||
"@rwx-research/abq": "0.1.0-alpha.5", | ||
"@rwx-research/abq": "0.1.0-alpha.7", | ||
"@types/node": "*", | ||
@@ -28,0 +28,0 @@ "chalk": "^4.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41542
1336
+ Added@rwx-research/abq@0.1.0-alpha.7(transitive)
- Removed@rwx-research/abq@0.1.0-alpha.5(transitive)