From 943d0e9e38fe49aed612c4544633477d102ffd7a Mon Sep 17 00:00:00 2001 From: Kris Thom White Date: Sun, 10 Nov 2019 10:45:28 -0600 Subject: [PATCH] feat: add ability to pass dynamodb-local options from config file --- jest-dynamodb-config.js | 3 ++- setup.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/jest-dynamodb-config.js b/jest-dynamodb-config.js index 32b9b5d..3ab2f0a 100644 --- a/jest-dynamodb-config.js +++ b/jest-dynamodb-config.js @@ -7,5 +7,6 @@ module.exports = { ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1} } ], - port: 8000 + port: 8000, + options: ['-sharedDb'] }; diff --git a/setup.js b/setup.js index 392f421..c592eca 100644 --- a/setup.js +++ b/setup.js @@ -8,17 +8,18 @@ process.env.AWS_ACCESS_KEY_ID = 'access-key'; process.env.AWS_SECRET_ACCESS_KEY = 'secret-key'; const DEFAULT_PORT = 8000; +const DEFAULT_OPTIONS = ['-sharedDb']; module.exports = async function() { const config = require(resolve(cwd(), 'jest-dynamodb-config.js')); - const {tables, port: port = DEFAULT_PORT} = + const {tables, port: port = DEFAULT_PORT, options: options = DEFAULT_OPTIONS} = typeof config === 'function' ? await config() : config; const dynamoDB = new DynamoDB({ endpoint: 'localhost:' + port, sslEnabled: false, region: 'local-env' }); - global.__DYNAMODB__ = await DynamoDbLocal.launch(port, null, ['-sharedDb']); + global.__DYNAMODB__ = await DynamoDbLocal.launch(port, null, options); await createTables(dynamoDB, tables); };