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

Mocking waitFor calls #12

Open
m-radzikowski opened this issue Apr 10, 2021 · 4 comments
Open

Mocking waitFor calls #12

m-radzikowski opened this issue Apr 10, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@m-radzikowski
Copy link
Owner

m-radzikowski commented Apr 10, 2021

See aws/aws-sdk-js-v3#2215 and aws/aws-sdk-js-v3#1156 (comment)

@m-radzikowski m-radzikowski added the enhancement New feature or request label May 31, 2021
@evanstachowiak
Copy link

@m-radzikowski any update on this?

I'm trying to mock cloudfront waitUntilInvalidationCompleted. I think this would helpful.

I also see there is the callsFake method but I haven't figured out how to get that working, if that's even the way to go. Any suggestions would be greatly appreciated.

@m-radzikowski
Copy link
Owner Author

No, it's not supported directly by the library. The best approach is to mock the waitUntilInvalidationCompleted function with Jest or other lib, like this: https://jestjs.io/docs/mock-functions#mocking-partials

@evanstachowiak
Copy link

Thanks for the quick response! I managed to mock successfully as you suggested.

@evanstachowiak
Copy link

For future reference, the workaround I found:

jest.mock('@aws-sdk/client-cloudfront', () => ({
  ...jest.requireActual('@aws-sdk/client-cloudfront'),
  waitUntilInvalidationCompleted: jest.fn(async () => cloudfrontWaiterResponse),
}));

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