Giter VIP home page Giter VIP logo

node-rest-api-jest-tests's Introduction

How to Test Node.js Integrations with Jest

This repo provides a sample Node.js REST API that makes calls out to an external GraphQL endpoint and returns the Graph data to the user.

Sample tests are included that mock the GraphQL integration. Mocks are defined using the Jest Testing Framework.

Install

Install the dependencies with the following command:

npm install

Launch REST API Locally

To run a build and launch the development server, execute:

npm start

Routes

Once completed, the app should be avialable at the following routes:

Returns a list of recent hikes.

Returns data describing hike 123.

Returns a list of photos taken during hike 123.

Tests

Unit tests can be executed with by running the following command:

npm test

VSCode Debugging

Tests can be executed with a debugger in VS Code using the Jest Runner extension. If running VS Code in WSL mode, make sure the Jest Runner extension is installed and enabled for use with WSL.

Development

This application was bootstrapped with Express Application Generator, and was developed with Node.js version v16.13.1

Supplemental Blog Post

Here is a blog post I created that explains the setup and testing in further detail: https://taylor.callsen.me/testing-node-js-integrations-with-jest/

node-rest-api-jest-tests's People

Contributors

tcallsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.