
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@takeshape/vitest-docker-dynamodb
Advanced tools
Bootstrap vitest tests with docker-compose and dynamodb.
Provides an easy way to start and stop docker-compose
projects with vitest
tests. Additional functionality to easily set up dynamodb table fixtures.
npm i @takeshape/vitest-docker-dynamodb -D
# or
yarn add @takeshape/vitest-docker-dynamodb -D
# or
pnpm add @takeshape/vitest-docker-dynamodb -D
vitest.config.ts
All config is optional, if you provide no config the plugin will attempt to load
docker-compose.yml
in your working directory.
import dockerDynamodbPlugin from '@takeshape/vitest-docker-dynamodb';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [
dockerDynamodbPlugin({
dynamodb: {
basePort: 8000
},
projectName: 'my-test-project',
configFile: 'docker-compose.yml'
})
]
});
const client = new DynamoDBClient({
...yourConfig,
...(process.env.MOCK_DYNAMODB_ENDPOINT && {
endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
region: 'local'
})
});
If you have a docker-compose.yml
file living beside your vitest.config.ts
file
you can simple run vitest
and it should be run on setup, and stopped on teardown.
If you want to configure dynamodb
, or do anything custom read along...
// vitest.config.mts
dockerDynamodbPlugin({
dynamodb: {
basePort: 8099
},
projectName: 'my-test-project',
config: {
services: {
dynamodb: {
image: 'amazon/dynamodb-local',
environment: {
_JAVA_OPTIONS: '-Xms512m -Xmx512m'
},
ports: ["8099:8000"]
}
}
}
})
// vitest.config.mts
dockerDynamodbPlugin({
dynamodb: {
basePort: 8099,
tables: [
{
TableName: 'table',
KeySchema: [{ AttributeName: 'id', KeyType: 'HASH' }],
AttributeDefinitions: [{ AttributeName: 'id', AttributeType: 'S' }],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
}
]
}
})
// vitest.config.mts
dockerDynamodbPlugin({
dynamodb: {
basePort: 8099,
tables: './my-tables.mjs'
}
})
// my-tables.mjs
export default () => {
return [
{
TableName: 'table',
KeySchema: [{ AttributeName: 'id', KeyType: 'HASH' }],
AttributeDefinitions: [{ AttributeName: 'id', AttributeType: 'S' }],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
}
]
};
Check out the types here.
Check out the code here.
This project is deeply indebted to vitest-dynamodb-local. You'll see a lot of similarity in the code and
process, but swapping in docker-compose
for dynamo-db-local
.
FAQs
Bootstrap vitest tests with docker-compose and dynamodb.
We found that @takeshape/vitest-docker-dynamodb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.