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): expose Config type from jest #12848

Merged
merged 11 commits into from
May 19, 2022
Merged

feat(jest): expose Config type from jest #12848

merged 11 commits into from
May 19, 2022

Conversation

mrazauskas
Copy link
Contributor

Closes #12037
Closes #12801

Summary

This second attempt to unify the style of configuration examples. Previously (in #12037) I was trying to refactor all config to JSON. That looked alright, but something was missing. This PR is based #12817 (comment) in which the user suggesting that the examples could be functioning copy-paste code.

Interesting. Made me think in that direction. In that PR only CJS syntax was covered, but it is possible to have JS, TS tabs. For instance, Playwright’s config examples are written in this way.

JestConfig type is borrowed from my other PR. This is simply a reexport of Config.InitialOptions. Just thinking out loud, I am fine to use either.

The motivation to add JestConfig:

  • Config.InitialOptions is verbose and feels like an internal type.
  • also exposing JestConfig from jest does not require to install additional package to pass stricter audit.

No feelings hurt is something looks unacceptable. In my projects Jest configs are mostly written in JSON, to be honest ;D

Test plan

Tests are added. Lint should pass.

@mrazauskas
Copy link
Contributor Author

This is all about how it looks like. So, here is preview: https://deploy-preview-12848--jestjs.netlify.app/docs/next/configuration

packages/jest/src/index.ts 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.

I like this approach more!

From a quick glance through, the docs now no longer mention the config can export an async function, beyond that it looks like all is covered.

I'm AFK until wednesday (https://en.wikipedia.org/wiki/Constitution_Day_(Norway)), but I'll read through the docs more thoroughly then 👍

@mrazauskas
Copy link
Contributor Author

It would be nice to make the tabs implementation less verbose, e.g.:

:::tabs

// js code

// ts code

:::

I was looking at docusaurus-remark-plugin-codetabs. Good example, but could be better. Will try to write a custom plugin at some point.

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.

this is fantastic 👏

I really like defaulting to JS config all over, plus showing both JS and TS examples - the tabs work great 👍

packages/jest/src/index.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
docs/Configuration.md Outdated Show resolved Hide resolved
mrazauskas and others added 2 commits May 18, 2022 20:26
Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
@mrazauskas
Copy link
Contributor Author

By the way, I almost finished a Docusaurus plugin which creates a box with two tabs out of this (imagine backtics instead):

'''js tabs
// some js code
'''

'''ts tabs
// some ts code
'''

@SimenB SimenB changed the title feat(jest): expose JestConfig type feat(jest): expose Config type from jest May 19, 2022
@SimenB SimenB merged commit a841a74 into jestjs:main May 19, 2022
@mrazauskas mrazauskas deleted the feat-JesConfig-type branch May 19, 2022 06:32
@mrazauskas
Copy link
Contributor Author

Hm.. Seems like deploy is failing for few days. @SimenB could you take a look, please? (;

@SimenB
Copy link
Member

SimenB commented May 19, 2022

Looks like an error in the french translation:
image

I've tried to edit the translation itself 🤞

@SimenB
Copy link
Member

SimenB commented May 23, 2022

Website deployment was successful today, btw. Thanks for noticing!

@mrazauskas
Copy link
Contributor Author

Website deployment was successful today, btw. Thanks for noticing!

Great. Tabs look really good. I'm happy about the result. Nice!

@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 Jun 23, 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.

3 participants