aws-samples / lambda-refarch-webapp

The Web Application reference architecture is a general-purpose, event-driven, web application back-end that uses AWS Lambda, Amazon API Gateway for its business logic. It also uses Amazon DynamoDB as its database and Amazon Cognito for user management. All static content is hosted using AWS Amplify Console.
https://aws.amazon.com/lambda/web-apps/
Apache License 2.0
1.59k stars 910 forks source link

Unable to test locally #57

Open kaihendry opened 2 years ago

kaihendry commented 2 years ago

Reproduction Steps

(ins)[hendry@t14s todo-src]$ npm run test

> hello_world@1.0.0 test
> mocha tests/unit/

Error: No test files found: "tests/unit/"

I also tried following the steps in the README, but the dynamodb create-table line doesn't work

(ins)[hendry@t14s ~]$ aws dynamodb create-table --table-name TodoTable --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --billing-mode PAY_PER_REQUEST --endpoint-url http://127.0.0.1:8000

You must specify a region. You can also configure your region by running "aws configure".
(ins)[hendry@t14s ~]$ aws --region ap-southeast-1 dynamodb create-table --table-name TodoTable --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --billing-mode PAY_PER_REQUEST --endpoint-url http://127.0.0.1:8000

Unable to locate credentials. You can configure credentials by running "aws configure".
(ins)[hendry@t14s ~]$ aws --version
aws-cli/2.2.39 Python/3.8.8 Linux/5.14.8-arch1-1 exe/x86_64.arch prompt/off

This is :bug: Bug Report

kaihendry commented 2 years ago

Also it's not super clear to me if or how https://github.com/aws-samples/lambda-refarch-webapp/blob/master/todo-src/test/unit/test-handler.js gets used

GQMai commented 2 years ago

@kaihendry the test folder name is wrong. It should be "test/unit/"