Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monorepo is not really supported #119

Open
oreporan opened this issue Dec 6, 2021 · 1 comment
Open

monorepo is not really supported #119

oreporan opened this issue Dec 6, 2021 · 1 comment

Comments

@oreporan
Copy link

oreporan commented Dec 6, 2021

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

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:

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
  }
@vladholubiev
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants