mock-aws-s3-v3
TypeScript icon, indicating that this package has built-in type declarations

5.0.6 • Public • Published

npm version

Mock AWS S3 SDK v3

Local file-based mock for AWS S3 for unit and local testing for AWS JavaScript SDK v3+.

Based on mock-aws-s3 and aws-sdk-mock.

Usage

import { createS3Client } from 'mock-aws-s3-v3';
import { GetObjectCommand } from '@aws-sdk/client-s3';

const client = createS3Client('./local-folder'); // of type S3Client

await client.send(new PutObjectCommand({
  Bucket: 'test-bucket',
  Key: 'test-key',
  Body: 'hello',
});

This will create:

  • Folder ./local-folder/test-bucket
  • File ./local-folder/test-key with content 'hello'

Supported Operations

The following operations are currently supported in this mock:

  • CreateBucketCommand
  • DeleteBucketCommand
  • ListObjectsCommand
  • ListObjectsV2Command
  • DeleteObjectsCommand
  • DeleteObjectCommand
  • GetObjectCommand
  • HeadObjectCommand
  • PutObjectCommand
  • CopyObjectCommand
  • GetObjectTaggingCommand
  • PutObjectTaggingCommand

Same as mock-aws-s3 minus getSignedUrl. For an example of how getSignedUrl could be mocked, see templateS3Bucket.ts.

Readme

Keywords

Package Sidebar

Install

npm i mock-aws-s3-v3

Weekly Downloads

235

Version

5.0.6

License

MIT

Unpacked Size

9.47 kB

Total Files

6

Last publish

Collaborators

  • mxro