This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@rise8/mock-test-kit-core
TypeScript icon, indicating that this package has built-in type declarations

1.6.1 • Public • Published

mock-test-kit-core

A library for creating Mock Test Kit .json files programmatically.

Introduction

Mock Test Kit is a set of tools that allow you to create REST and GraphQL Federated mock data APIs. Mock Test Kit Core helps you build the mocked data to be served using the Mock Test Kit API (ghcr.io/rise8-us/mock-test-kit-api:latest).

Getting Started

See extended documentation for more details on usage.

Installing

npm install @rise8/mock-test-kit-core --save-dev
# or 
yarn add @rise8/mock-test-kit-core --dev

Configuration

# docker-compose.yml
services:
  mock-api:
    image: ghcr.io/rise8-us/mock-test-kit-api:latest
    ports:
      - "8080:8080"
    volumes:
      - "./infra/mock-data:/tmp/mock-data"
    environment:
      - PORT=8080
      - API_NAME=mock-api
      - WATCH=true // Used to watch for changes in the mock data directory
      - HEADERS=false // Used to enable pattern matching on headers
// global-setup.js
import mtk from '@rise8/mock-test-kit-core';

mtk.initialize({
  outputDir: './infra/mock-data', // Set the output directory for json files
  development: false, // Set this to allow core library code to run during development
})

Usage

// page.test.js
import mtk, {
  Expr,
  Fn,
  Ctx,
  Match,  
} from '@rise8/mock-test-kit-core';

describe('page', () => {
  it('should load with "Hello ${name}" message', () => {
    mtk.generate(
        new Builder.RestRequest({
          service: 'mock-api',
          path: '/hello/:name',
          method: 'GET',
        })
        .withParam('name', Match.any())
        .addResponses(
            new Builder.RestResponse()
            .withStatus(200)
            .withBody({
              message: `Hello ${Expr.create(Ctx.getParam('name'))}`
            }).build()
        ).build()
    );
    // ... the rest of the test
  })
});

Careers

Explore new opportunities with Rise8.

Readme

Keywords

none

Package Sidebar

Install

npm i @rise8/mock-test-kit-core

Weekly Downloads

30

Version

1.6.1

License

MIT

Unpacked Size

37.6 kB

Total Files

58

Last publish

Collaborators

  • dlamberson
  • jmiller-rise8
  • kivarsson-r8
  • treynolds-r8