Skip to content
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

feat(jest-runner): allow setupFiles module to export an async function #12042

Merged
merged 4 commits into from
Feb 25, 2022
Merged

feat(jest-runner): allow setupFiles module to export an async function #12042

merged 4 commits into from
Feb 25, 2022

Conversation

mrazauskas
Copy link
Contributor

@mrazauskas mrazauskas commented Nov 5, 2021

Closes #11038

Summary

As it is described in the issue, async function in setupFiles modules might be useful to fetch data asynchronously.

I do not think it is the best place to set up a database, because there is no way to tear it down later without some additional script. But fetching some fixture data and temporary storing it in an object would work.

The implementation is only targeting CJS modules, because (as it was pointed out in the issue) ESM modules allow top-level await. In way this PR simply enables CJS users to have similar functionality as ESM user have.

Test plan

Integration test is added.

@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2021

Codecov Report

Merging #12042 (3bfcb07) into main (95f4969) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12042      +/-   ##
==========================================
- Coverage   68.77%   68.72%   -0.05%     
==========================================
  Files         324      324              
  Lines       16670    16682      +12     
  Branches     4814     4818       +4     
==========================================
  Hits        11465    11465              
- Misses       5172     5184      +12     
  Partials       33       33              
Impacted Files Coverage Δ
packages/jest-runner/src/runTest.ts 3.36% <0.00%> (-0.12%) ⬇️
packages/jest-runtime/src/index.ts 56.17% <0.00%> (-0.53%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95f4969...3bfcb07. Read the comment docs.

@mrazauskas mrazauskas marked this pull request as draft November 5, 2021 17:12
@mrazauskas mrazauskas requested a review from SimenB November 5, 2021 18:10
@mrazauskas mrazauskas marked this pull request as ready for review November 5, 2021 18:49
@SimenB
Copy link
Member

SimenB commented Feb 24, 2022

Completely lost track of this. Could you rebase @mrazauskas?

docs/Configuration.md Outdated Show resolved Hide resolved
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

docs/Configuration.md Outdated Show resolved Hide resolved
@SimenB SimenB merged commit c9a3d37 into jestjs:main Feb 25, 2022
@mrazauskas mrazauskas deleted the feat-async-setupFiles branch February 25, 2022 10:16
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Async setupFiles
4 participants