-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor, add action name to command, add actionResult to reportTestA…
…ctionDone
- Loading branch information
1 parent
3b8f5db
commit 051dec3
Showing
11 changed files
with
129 additions
and
52 deletions.
There are no files selected for viewing
File renamed without changes.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,12 @@ | ||
import TestController from './test-controller'; | ||
import testRunTracker from './test-run-tracker'; | ||
import TestRun from '../test-run'; | ||
import TestCafeErrorList from '../errors/error-list'; | ||
import { MissingAwaitError } from '../errors/test-run'; | ||
import addRenderedWarning from '../notifications/add-rendered-warning'; | ||
import WARNING_MESSAGES from '../notifications/warning-message'; | ||
import { addErrors, addWarnings } from './test-controller/add-errors'; | ||
import wrapTestFunction, { WrapTestFunctionExecutorArguments } from './wrap-test-function'; | ||
|
||
export default function wrapCustomAction (fn: Function): Function { | ||
return async (testRun: TestRun, functionArgs: any) => { | ||
let result = null; | ||
const errList = new TestCafeErrorList(); | ||
|
||
testRun.controller = new TestController(testRun); | ||
|
||
const executor = async function ({ testRun, functionArgs }: WrapTestFunctionExecutorArguments): Promise<any> { | ||
const markeredfn = testRunTracker.addTrackingMarkerToFunction(testRun.id, fn, testRun.controller); | ||
|
||
testRun.observedCallsites.clear(); | ||
testRunTracker.ensureEnabled(); | ||
|
||
try { | ||
result = await markeredfn(...functionArgs); | ||
} | ||
catch (err) { | ||
errList.addError(err); | ||
} | ||
|
||
if (!errList.hasUncaughtErrorsInTestCode) { | ||
for (const { callsite, actionId } of testRun.observedCallsites.awaitedSnapshotWarnings.values()) | ||
addRenderedWarning(testRun.warningLog, { message: WARNING_MESSAGES.excessiveAwaitInAssertion, actionId }, callsite); | ||
|
||
addWarnings(testRun.observedCallsites.unawaitedSnapshotCallsites, WARNING_MESSAGES.missingAwaitOnSnapshotProperty, testRun); | ||
addErrors(testRun.observedCallsites.callsitesWithoutAwait, MissingAwaitError, errList); | ||
} | ||
|
||
if (errList.hasErrors) | ||
throw errList; | ||
|
||
return result; | ||
return await markeredfn(...functionArgs); | ||
}; | ||
|
||
return wrapTestFunction(fn, executor); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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