question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The tests that use s3 to put/update/delete objects are prone to race conditions if the same tests are being run from multiple places (i.e. pr & push builds on travis). This leads to unexpectedly flopping tests and solving with a retry, which is a bit cumbersome. Example errors:

404 status code downloading tarball https://node-pre-gyp-tests.s3-us-west-1.amazonaws.com/app3/v0.1.0-dev.4/node-v51-linux-x64.tar.gz

In order to run tests reliably, we can mock out s3 functions and their responses and assert specific parameters were called. Let’s have a look at mock-aws-sdk-js, which uses sinon stubs.

cc @springmeyer

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
springmeyercommented, Apr 27, 2018

Ah, okay. In this case node-pre-gyp primarily uses both http and aws-sdk to interact with AWS. http for GET and aws-sdk for PUT/DELETE/LIST.

0reactions
mapsamcommented, Jun 5, 2018

Diving into these tests has left me with some large-scale refactor desires. Opened a ticket in https://github.com/mapbox/node-pre-gyp/issues/392 to discuss this further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mock S3 for integration test - DEV Community ‍ ‍
Create S3 mock server ... First we create a HttpHandler . It will return the content of S3 object. ... Then we start...
Read more >
How to mock Amazon S3 in an integration test - Stack Overflow
It mocks the essential parts of AWS S3 API on top of local filesystem: import io.findify.s3mock.S3Mock S3Mock api = S3Mock.create(8001, ...
Read more >
How to Mock AWS S3 in a Jest (Unit) Test - Nikhil
Here's a unit test for the code above using Jest. We'll be mocking S3, and asserting that S3's copyObject function gets called with...
Read more >
How to Mock AWS S3 in a Jest (Unit) Test | by Nikhil Vijayan
Here's a unit test for the code above using Jest. We'll be mocking S3, and asserting that S3's copyObject function gets called with...
Read more >
adobe/S3Mock: A simple mock implementation of the AWS S3 ...
S3Mock is a lightweight server that implements parts of the Amazon S3 API. It has been created to support local integration testing by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found