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

UUID and random dates doesn´t respect the seed #346

Open
MarioJuniorPro opened this issue Feb 1, 2023 · 4 comments
Open

UUID and random dates doesn´t respect the seed #346

MarioJuniorPro opened this issue Feb 1, 2023 · 4 comments

Comments

@MarioJuniorPro
Copy link

Is this a regression?

Yes

Description

Generating uuids doesn´t respect the seed and it is always random. Also, when I generate dates and reload the environment, the date generated respect the seed except by the seconds.
If for some reason it is not considered a bug, would be nice to have global option to use a strict mode.

import { seed } from '@ngneat/falso';
import { randUuid, random, randSoonDate } from '@ngneat/falso';

const uuids = [];
seed('1');
uuids.push([randUuid(), random(), randSoonDate()]);
seed('2');
uuids.push([randUuid(), random(), randSoonDate()]);
seed('1');
uuids.push([randUuid(), random(), randSoonDate()]);
console.table(uuids);

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/typescript-sblpt9?file=index.ts

Please provide the exception or error you saw

// First run:
// 0	"da91cec3-7971-4a92-bb27-d54185e0be65"	0.2694488477791326	"2023-02-01T10:16:28.796Z"
// 1	"0a7b3a3e-4529-4626-b49f-7d395887312d"	0.7153687886990808	"2023-02-01T08:51:34.962Z"
// 2	"6f523c82-c565-4f84-92b9-9201899a292a"	0.2694488477791326	"2023-02-01T10:16:28.796Z"

// Seconds run:
// 0	"e5bd2a4c-d6e7-42d5-8c47-1777d8d7cefc"	0.2694488477791326	"2023-02-01T10:17:02.298Z"
// 1	"384e485c-a539-45da-b893-420e387ce038"	0.7153687886990808	"2023-02-01T08:52:08.465Z"
// 2	"ae7b7285-56d6-4efe-bb08-80ebded093f4"	0.2694488477791326	"2023-02-01T10:17:02.299Z"

Please provide the environment you discovered this bug in

It can be reproduced using this link [https://stackblitz.com/edit/typescript-sblpt9?file=index.ts]()

Anything else?

No response

Do you want to create a pull request?

No

@stackblitz
Copy link

stackblitz bot commented Feb 1, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@MarioJuniorPro
Copy link
Author

After test using node, the uuid works fine, maybe the issue is when it runs in the browser or in StackBlitz.
The date issue is because the functions uses new Date(), I don´t now know if the best approach would implement some parameter or a global static timestamp.

@MarcoB-Ec
Copy link

I am having this exactly same behavior. Having a hard time getting the same uuid while using Jest. @MarioJuniorPro Do you manage to solved it? Thanks for any information!

@shaharkazaz
Copy link
Contributor

@MarioJuniorPro @MarcoB-Ec I noticed that you are using @ngneat/[email protected] for some reason there.
The UUID seems to be working as expected after upgrading to the latest version.
Regarding randSoonDate, as you guys said it's based on new Date() so that would change between runs since it's not static by the seed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants