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: add a seed value to test runs #13400

Merged
merged 57 commits into from
Oct 9, 2022
Merged

Conversation

jhwang98
Copy link
Contributor

@jhwang98 jhwang98 commented Oct 7, 2022

Summary

Context from this conversation.

jest will now generate a seed value when running via the CLI. This seed can be accessed in the runtime via jest.getSeed().

You can also manually specify the seed with --seed=1234.

Test plan

Screen.Recording.2022-10-07.at.21.58.14.mov

packages/jest-types/src/Config.ts Outdated Show resolved Hide resolved
packages/jest-cli/src/args.ts Outdated Show resolved Hide resolved
packages/jest-environment/src/index.ts Show resolved Hide resolved
packages/jest-environment/src/index.ts Outdated Show resolved Hide resolved
packages/jest-config/src/normalize.ts Outdated Show resolved Hide resolved
docs/CLI.md Outdated Show resolved Hide resolved
docs/JestObjectAPI.md Outdated Show resolved Hide resolved
docs/CLI.md Outdated Show resolved Hide resolved
docs/JestObjectAPI.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.

exciting stuff! left some quick comments on direction, haven't done a thorough review (currently on vacation, so a bit on and off)

packages/jest-reporters/src/getSummary.ts Outdated Show resolved Hide resolved
packages/jest-environment/src/index.ts Outdated Show resolved Hide resolved
packages/jest-runtime/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.

fantastic work, thanks!

@SimenB
Copy link
Member

SimenB commented Oct 9, 2022

@mrazauskas any other comments? If not, I'll merge 🙂

@mrazauskas
Copy link
Contributor

Thanks! Looks like all is done.

@SimenB SimenB changed the title Feat get seed feat: add a seed value to test runs Oct 9, 2022
@SimenB SimenB merged commit 7b49471 into jestjs:main Oct 9, 2022
@@ -1614,6 +1614,12 @@ const config: Config = {
export default config;
```

### `showSeed` \[boolean]

Default: `false`
Copy link
Contributor

Choose a reason for hiding this comment

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

Such a great option, I love it 💕

Copy link
Member

@SimenB SimenB Oct 9, 2022

Choose a reason for hiding this comment

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

I was just about to tag you 🙂 Does this (i.e. this entire implementation, not just this specific option) fit your use case and usage?

Copy link
Member

@SimenB SimenB Oct 9, 2022

Choose a reason for hiding this comment

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

I'm thinking you can just document setting this config flag instead of printing the seed yourself (as a major release I guess)

Copy link
Contributor

@dubzzz dubzzz Oct 9, 2022

Choose a reason for hiding this comment

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

It will definitely help a lot. So far @fast-check/jest was mostly responsible for building a seed for fast-check and appending it to the name of the it (and also provide a it tailored for pbt). With both seed and showSeed options altering the name of the test might not be that required.

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't documented the removal of the seed printing yet, but that was my idea when I opened dubzzz/fast-check#3287

@SimenB
Copy link
Member

SimenB commented Oct 14, 2022

https://github.com/facebook/jest/releases/tag/v29.2.0

thewilkybarkid added a commit to PREreview/prereview.org that referenced this pull request Oct 26, 2022
Jest 29.2 added an option to set a seed, which fast-check uses, and to show it. In the event of a failure, we can rerun the tests with the same seed, making debugging non-deterministic failures far simpler.

I'm not sure why Dependabot isn't updating Jest/ts-jest to v29.

Refs #388, a6b0f11, jestjs/jest#13400, dubzzz/fast-check#3332
@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 Nov 14, 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.

6 participants