-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add testLocationInResults
support to jest-circus
#6291
Conversation
// Technically the column should be 3, but callsites is not correct. | ||
// jest-circus uses stack-utils + asyncErrors which resolves this. | ||
expect(assertions[1].location).toEqual({ | ||
column: SkipOnJestCircus.isJestCircusRun() ? 3 : 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution!
packages/jest-circus/src/utils.js
Outdated
unhandledErrors: unhandledErrors.map(_formatError), | ||
}; | ||
}; | ||
|
||
const makeTestResults = (describeBlock: DescribeBlock): TestResults => { | ||
const makeTestResults = (describeBlock: DescribeBlock, config): TestResults => { | ||
const stackUtils = new StackUtils(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can instantiate this at the top of the file. It will always be instantiated anyways
@@ -243,16 +248,25 @@ const makeTestResults = (describeBlock: DescribeBlock): TestResults => { | |||
if (!status) { | |||
throw new Error('Status should be present after tests are run.'); | |||
} | |||
|
|||
let location = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this needs to be undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test expliclity asserts .toBeNull()
.
packages/jest-circus/src/utils.js
Outdated
|
||
let location = null; | ||
if (config.testLocationInResults) { | ||
const stackLine = test.asyncError.stack.split('\n')[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjesun is gonna love it 😄 😄
@@ -102,7 +102,7 @@ export const runAndTransformResultsToJestFormat = async ({ | |||
globalConfig: GlobalConfig, | |||
testPath: string, | |||
}): Promise<TestResult> => { | |||
const runResult = await run(); | |||
const runResult = await run(config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm really not sure about passing the config to jest-circus
world, that couples it pretty tightly to the rest of jest
would you be ok dispatching an action, like i did on line 73 in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@captbaritone seems like
|
@aaronabramov I'm working on approach 3. |
@@ -32,6 +32,9 @@ export type Hook = { | |||
export type EventHandler = (event: Event, state: State) => void; | |||
|
|||
export type Event = | |||
| {| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
later if we want to keep jest-circus
decoupled we should probably introduce config
or settings
property on the state and mutate them through a single action.
At the same time i'm a little worried about introducing one more config :D
Flow types: #6294 |
@aaronabramov rebased on top of #6294. |
Codecov Report
@@ Coverage Diff @@
## master #6291 +/- ##
=========================================
Coverage ? 63.47%
=========================================
Files ? 221
Lines ? 8513
Branches ? 4
=========================================
Hits ? 5404
Misses ? 3108
Partials ? 1
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Part of #4362
@SimenB
@aaronabramov importing
stack-utils
inpackages/jest-circus/src/utils.js
breaks flow-strict. Thoughts?