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

Support for async fixtures #15

Open
jfantunes opened this issue Jan 23, 2021 · 3 comments
Open

Support for async fixtures #15

jfantunes opened this issue Jan 23, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@jfantunes
Copy link

I'm trying to return a fixture where the outcome is the result of a async function, but I'm not getting any success. Is that possible or not yet?

@CyriacBr
Copy link
Owner

You mean using @Fixture( () => Promise ) ? IIRC that's not supported. Can you show your use case please?

@CyriacBr CyriacBr added the question Further information is requested label Jan 24, 2021
@jfantunes
Copy link
Author

jfantunes commented Jan 24, 2021

Thanks for the prompt response @CyriacBr.
The case is the following one:

 @Fixture(() => hashPassword(faker.random.words()))
 public password: string;

The function hashPassword uses a library called argon which generates cyphers only using async methods.
I can use it like this:

const fakeUsers = fixture
            .make(User)
            .with({
                password: await hashPassword(faker.random.alphaNumeric(6)),
            })

But I can't define a fixture using it. It doesn't throw me a linter error, but on the execution fails.

@CyriacBr CyriacBr added enhancement New feature or request and removed question Further information is requested labels Jan 31, 2021
@CyriacBr
Copy link
Owner

I'll see if this is easily fixable.

@CyriacBr CyriacBr mentioned this issue Apr 12, 2021
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants