Open oreporan opened 2 years ago
Maybe something is wrong in my monorepo setup... I am getting an issue similar to #113 but even with his PR fix I'm still failing to create the tables
My structure:
jest-dynamodb-config.js package-a/ jest.config.js package-b/ jest.config.js
this is the inside of package-a and package-b jest.config.js
jest.config.js
const shelfPreset = require('@shelf/jest-dynamodb/jest-preset'); const path = require('path'); // dynamodb-local process.env.JEST_DYNAMODB_CONFIG = path.resolve(__dirname, '../../../jest-dynamodb-config.js'); module.exports = { ...shelfPreset, testEnvironment: 'node', };
this is the content of jest-dynamodb-config.js located at the root:
jest-dynamodb-config.js
module.exports = { tables: [ { TableName: 'table-a-tests', }, { TableName: 'table-b-tests', }, ], port: 8000, };
When running the tests, both package-a and package-b fail with:
ResourceInUseException: ResourceInUseException at deserializeAws_json1_0CreateTableCommandError (/Users/xxx/dev/repos/serverless/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:973:41) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async /Users/xxx/dev/repos/serverless/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:6:20 at async /Users/xxx/dev/repos/serverless/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:11:20 at async StandardRetryStrategy.retry (/Users/xxx/dev/repos/serverless/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46) at async /Users/xxx/dev/repos/serverless/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22 at async Promise.all (index 0) at async module.exports (/Users/xxx/dev/repos/serverless/node_modules/@shelf/jest-dynamodb/setup.js:72:5) at async /Users/xxx/dev/repos/serverless/node_modules/@jest/core/build/runGlobalHook.js:82:11 at async waitForPromiseWithCleanup (/Users/xxx/dev/repos/serverless/node_modules/@jest/transform/build/ScriptTransformer.js:207:5) { '$fault': 'client', '$metadata': { httpStatusCode: 400, extendedRequestId: undefined, cfId: undefined, attempts: 1, totalRetryDelay: 0 }
Looks like jest-dynamodb-config.js doesn't have a complete config. You need to define hash/range keys for each table.
Looks like the error comes from DDB not b/c of monorepo
Maybe something is wrong in my monorepo setup... I am getting an issue similar to #113 but even with his PR fix I'm still failing to create the tables
My structure:
this is the inside of package-a and package-b
jest.config.js
this is the content of
jest-dynamodb-config.js
located at the root:When running the tests, both package-a and package-b fail with: