GithubHelp home page GithubHelp logo

l-monninger / fauna-test-setup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cntric/fauna-test-setup

0.0 0.0 0.0 334 KB

License: MIT License

JavaScript 3.41% HTML 82.13% CSS 2.35% TypeScript 12.11%

fauna-test-setup's Introduction

fauna-test-setup

A package for setting up Fauna Dev servers with minimal hassel.

yarn add --dev https://github.com/concentricio/fauna-test-setup

Motivation

The process of setting up Fauna Dev servers to test Fauna logic can be cumbersome and detached from the actual development of test suites. This package automates test server setup, so you can do it inline and in a single line.

const testDb = await FaunaTestDb();

Besides this package, you only need to make sure you have Docker installed and running.

You can create a database and test against it without any additional setup:

import {FaunaTestDB} from "fauna-test-setup";

// Jest example
describe("Basic functionality", ()=>{
        test("Addition", async ()=>{

            const {
                client
            } = await FaunaTestDb();
    
            const result = await client.query(Add(2, 2));
            expect(result).toBe(4)

        }, 5000)
})

Automation

If needed, FaunaTestDb() will automatically...

  • pull the fauna/faunadb Docker image,
  • deploy a container with the fauna/faunadb Docker image,
  • create a Fauna endpoint and forward it to the desired port,
  • create a test database.

Reuse

By default, FaunaTestDb() will...

  • reuse Docker containers running with the fauna/faunadb image,
  • reuse endpoints deployed on the desired port,
  • NOT reuse previous test databases.

fauna-test-setup will NOT automatically tear down your testing environment. However, a teardown() method is provided.

import {teardown} from "fauna-test-setup";
// Jest example
afterAll(async ()=>{
  await teardown();
})

Default

By default, teardown() will...

  • delete any test databases used within the running of the application.

Additional

teardown() can additionally be configured to...

  • delete databases used without the context of the application,
  • delete Fauna endpoints within or without the context of the application,
  • remove fauna/faunadb Docker containers within or without the context of the application.

Docs

From within the package directory, yarn run docs.

fauna-test-setup's People

Contributors

l-monninger 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.