Giter Site home page Giter Site logo

Comments (2)

jordanmaxfightcamp avatar jordanmaxfightcamp commented on June 14, 2024

I did find a workaround:

await serverless.init();
  const service = await serverless.variables.populateService();
  const resources = service.resources.Resources;
  let tables = Object.keys(resources)
    .map((name) => resources[name])
    .filter((r) => r.Type === 'AWS::DynamoDB::Table')
    .map((r) => r.Properties);
  
  // This is a workaround, there is some bug that says we need a property called `StreamEnabled` on tables with `StreamSpecification` but that will error out serverless.
  // It's also not in the docs, so I am erroring on the side of Serverless since it seems they are adhering to rules
  // https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-streamspecification.html
  // So the workaround, is for local, we dont need streams anyways, remove this property to not get error.
  tables = tables.map(table => {
    const { StreamSpecification } = table;
    if(StreamSpecification) {
      delete table.StreamSpecification;
    }

    return table;
  })

  return {
    tables,
    port: 8000,
  };

So basically just remove any tables with StreamSpecification in your jest dynamodb config, not the best but works.

from jest-dynamodb.

hugoduraes avatar hugoduraes commented on June 14, 2024

@jordanmaxfightcamp if you need streams, instead of deleting StreamSpecification you'll need to do this instead:

tables = tables.map(table => {
  if (table.StreamSpecification) {
    table.StreamSpecification = {
      ...table.StreamSpecification,
      StreamEnabled: true,
    };
  }

  return table;
})

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html
According to this, StreamEnabled is a required property.

from jest-dynamodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.