Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Node.js AWS-SDK + FakeS3 mocking tests
const fs = require('fs')
const AWS = require('aws-sdk')
const FAKE_S3_HOST = process.env.FAKE_S3_HOST || "localhost"
const FAKE_S3_PORT = process.env.FAKE_S3_HOST || "localhost"
// Create S3 service object using fakes3
const s3 = new AWS.S3({
region: 'us-east-2',
secretAccessKey: '123',
accessKeyId: '123',
apiVersion: '2006-03-01',
endpoint: `http://${FAKE_S3_HOST}:${FAKE_S3_PORT}/`,
httpOptions: {
proxy: `http://${FAKE_S3_HOST}:${FAKE_S3_PORT}/`
}
})
describe('Prepare', () => {
before((done) => {
const fileContent = fs.readFileSync('fixtures/myfile.pdf')
const params = {
Bucket: 'fakes3',
Key: 'myfile.pdf',
Body: fileContent
}
s3.upload(params, (err, data) => {
if (err) return done(err)
done()
})
})
it('Your test', () => {})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.