Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cypress for testing AWS lambda application: is a way to go?

Yuri Reis
August 20, 2022

Cypress for testing AWS lambda application: is a way to go?

Yuri Reis

August 20, 2022
Tweet

More Decks by Yuri Reis

Other Decks in Programming

Transcript

  1. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  2. Serverless is a cloud-native development model that allows developers to

    build and run applications without having to manage servers. There are still servers in serverless, but they are abstracted away from app development. Once deployed, serverless apps respond to demand and automatically scale up and down as needed. Serverless offerings from public cloud providers are usually metered on-demand through an event-driven execution model. SERVERLESS - CONCEPT
  3. Serverless is a cloud-native development model that allows developers to

    build and run applications without having to manage servers. There are still servers in serverless, but they are abstracted away from app development. Once deployed, serverless apps respond to demand and automatically scale up and down as needed. Serverless offerings from public cloud providers are usually metered on-demand through an event-driven execution model. SERVERLESS - CONCEPT
  4. Serverless is a cloud-native development model that allows developers to

    build and run applications without having to manage servers. There are still servers in serverless, but they are abstracted away from app development. Once deployed, serverless apps respond to demand and automatically scale up and down as needed. Serverless offerings from public cloud providers are usually metered on-demand through an event-driven execution model. SERVERLESS - CONCEPT
  5. Serverless is a cloud-native development model that allows developers to

    build and run applications without having to manage servers. There are still servers in serverless, but they are abstracted away from app development. Once deployed, serverless apps respond to demand and automatically scale up and down as needed. Serverless offerings from public cloud providers are usually metered on-demand through an event-driven execution model. SERVERLESS - CONCEPT
  6. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  7. SERVERLESS - COMPONENTS EVENT SOURCE FUNCTION SERVICES cron job change

    in data state endpoint request resource state cron job change in data state endpoint request resource state cron job change in data state endpoint request resource state
  8. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  9. SERVERLESS - ANATOMY OF A SERVERLESS FUNCTION HANDLER FUNCTION EVENT

    OBJECT CONTEXT OBJECT function to be executed upon invocation data sent during lambda function invocation methods available to interact with runtime information (request id, log group, etc)
  10. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  11. SERVERLESS - SAM } The AWS Serverless Application Model (SAM)

    is an open-source framework for building serverless applications It provides shorthand syntax to express functions, APIs, databases, and event source mappings With just a few lines per resource, you can define the application you want and model it using YAML
  12. SERVERLESS - SAM } The AWS Serverless Application Model (SAM)

    is an open-source framework for building serverless applications It provides shorthand syntax to express functions, APIs, databases, and event source mappings With just a few lines per resource, you can define the application you want and model it using YAML
  13. SERVERLESS - SAM } The AWS Serverless Application Model (SAM)

    is an open-source framework for building serverless applications It provides shorthand syntax to express functions, APIs, databases, and event source mappings With just a few lines per resource, you can define the application you want and model it using YAML
  14. SERVERLESS - SAM SAM CLI {is an open-source CLI tool

    that helps you develop serverless applications containing Lambda functions, Step Functions, API Gateway, EventBridge, SQS, SNS and more
  15. SERVERLESS - SAM SAM CLI (commands) { start-api COMMANDS COMMAND

    allows to set up a local endpoint that you can use to test your API allows to set up a local endpoint to invoke your local lambda functions start-lambda
  16. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  17. TESTING - WHERE AND WHAT TO TEST IN A LAMBDA

    FUNCTION SOURCE (DEV) STAGING PROD lint unit tests successful build - if applies integration tests - aws SAM CLI - some test framework/library safe deploy - traffic-shifting - auto-publish - rollback strategy
  18. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  19. CYPRESS - CONCEPT Cypress is a purely JavaScript-based front-end testing

    tool built for the modern web. It aims to address the pain points developers or QA engineers face while testing an application. Cypress is a more developer-friendly tool that uses a unique DOM manipulation technique and operates directly in the browser.
  20. CYPRESS - CONCEPT Cypress is a purely JavaScript-based front-end testing

    tool built for the modern web. It aims to address the pain points developers or QA engineers face while testing an application. Cypress is a more developer-friendly tool that uses a unique DOM manipulation technique and operates directly in the browser.
  21. CYPRESS - CONCEPT Cypress is a purely JavaScript-based front-end testing

    tool built for the modern web. It aims to address the pain points developers or QA engineers face while testing an application. Cypress is a more developer-friendly tool that uses a unique DOM manipulation technique and operates directly in the browser.
  22. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  23. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  24. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Embedded HTTP library uses publish - subscribe approach Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  25. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Embedded HTTP library uses publish - subscribe approach Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  26. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Embedded HTTP library uses publish - subscribe approach Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  27. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Embedded HTTP library uses publish - subscribe approach Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  28. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Embedded HTTP library uses publish - subscribe approach Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  29. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other
  30. STRENGTHS DRAWBACKS UI for test run Easy test debug through

    browser Retrying tests for a certain time until they succeed or finally fail Easy setup to generate reports Great collection of libraries CYPRESS - STRENGTHS AND DRAWBACKS Runs through a browser giving a slow performance The framework was done for E2E UI testing, even it works for other purposes
  31. TOPICS 1. SERVERLESS 1.1. CONCEPT 1.2. COMPONENTS 1.3. ANATOMY OF

    A SERVERLESS FUNCTION 1.4. SERVERLESS APPLICATION MODEL (SAM) 2. TESTING 2.1. WHERE AND WHAT TO TEST A LAMBDA PROJECT 3. CYPRESS 3.1. CONCEPT 3.2. HOW IT WORKS 3.3. STRENGTHS AND DRAWBACKS 3.4. IS A WAY TO GO OR NOT
  32. CYPRESS - IS A WAY TO GO OR NOT MAYBE

    DEFINITELY NOT NO YES DEFINITELY YES CYPRESS FOR LAMBDA FUNCTIONS TESTING 0 1 2 -1 -2 UNIT TESTING DEFINITELY NOT INTEGRATION TESTING DEFINITELY NOT E2E TESTING YES MANUAL TESTING (HUMAN TRIGGERING) DEFINITELY YES CONTINUOUS INTEGRATION TESTING MAYBE RESULT NO