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: support conditions from test environments #11863

Merged
merged 2 commits into from
Sep 13, 2021

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Sep 10, 2021

Summary

Allows custom test environments to pass extra conditions for Jest to pass on to custom resolver, such as node or browser.

Depends on (and includes as the first commit) #11859.

/cc @nicolo-ribaudo

Test plan

Tests added

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2021

Codecov Report

Merging #11863 (56b7aa3) into main (a0bf671) will increase coverage by 0.00%.
The diff coverage is 80.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #11863   +/-   ##
=======================================
  Coverage   68.93%   68.93%           
=======================================
  Files         312      312           
  Lines       16411    16412    +1     
  Branches     4759     4760    +1     
=======================================
+ Hits        11313    11314    +1     
  Misses       5071     5071           
  Partials       27       27           
Impacted Files Coverage Δ
packages/jest-environment-node/src/index.ts 63.46% <ø> (ø)
packages/jest-resolve/src/defaultResolver.ts 88.67% <ø> (ø)
packages/jest-runtime/src/index.ts 57.43% <80.00%> (+0.05%) ⬆️

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 a0bf671...56b7aa3. Read the comment docs.

@SimenB SimenB marked this pull request as ready for review September 13, 2021 07:06
@@ -42,6 +42,7 @@ export declare class JestEnvironment<Timer = unknown> {
setup(): Promise<void>;
teardown(): Promise<void>;
handleTestEvent?: Circus.EventHandler;
exportConditions?: () => Array<string>;
Copy link
Member Author

Choose a reason for hiding this comment

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

this could probably be a property, but making it into a function seems fine for a bit more flexibility

@SimenB SimenB merged commit 8c35c4d into jestjs:main Sep 13, 2021
@SimenB SimenB deleted the conditions-env branch September 13, 2021 07:56
AndrewSouthpaw added a commit to AndrewSouthpaw/jest that referenced this pull request Sep 23, 2021
…nsform-ignore-patterns

* 'main' of https://github.com/facebook/jest: (38 commits)
  chore: update `npm` instructions in README (jestjs#11890)
  chore: force patched version of ansi-regex (jestjs#11889)
  chore: update lockfile after publish
  v27.2.1
  chore: update changelog for release
  make the syntax error message more helpful for TS users (jestjs#11807)
  fix: include path to test file in "after teardown" error (jestjs#11885)
  docs: add link to the typescript integration instructions (jestjs#11806)
  fix: properly return mocks when using jest.isolatedModules (jestjs#11882)
  chore: remove node version pinning from CI (jestjs#11866)
  chore: remove node 13 as condition in some tests (jestjs#11880)
  chore: fix typo in docs
  chore: update lockfile after publish
  v27.2.0
  chore: roll new website version
  chore: update changelog for release
  chore: update lock
  feat: support `conditions` from test environments (jestjs#11863)
  Revert "chore: remove unneeded yarn patch for react native (jestjs#11853)"
  chore: supress experimental warnings in tests
  ...
@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 Oct 14, 2021
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.

3 participants