Package Exports
- specmatic
- specmatic/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (specmatic) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Specmatic is a contract driven development tool that leverages API Specifications, such as OpenAPI, as executable specification.
Thin Wrapper
Specmatic is a standalone executable that is agnostic to programming languages and technology stacks. This node module is a thin wrapper over the standalone executable jar. All core capabilities are in the main Specmatic project. The purpose of this wrapper module is to act as a convenience to help with below aspects.
- Easy installation and upgrade of the jar file in node projects through npm
- JS helper library which provides to do various setup steps like start, stop the specmatic stub server, installing specs etc. These helpers methods can be used inside a setup file inside a javascript project programmatically instead of using cli scripts.
Quick Start
npm install specmatic will install the specmatic locally to the node project.
Sample npm scripts to run specmatic, (Check Documentation for more information on cli commands and arguments.)
Contract as Stub / Smart Mock (For API clients / consumers)
In stub mode, Specmatic emulates the Provider / API / Service based on the API Specification so that the consumer / client application can make independent progress. Learn more.
Contract as Test (For API Providers / Service)
Tests for Free – Specmatic parses your API Specification files and based on this generates requests which are fired at your application. It then verifies if your application’s response is as per your API Specification. All this with a “No Code” approach.. Learn More
API
Check Documentation for more information on cli commands and arguments.
Test helper library
import {
startStubServer,
runContractTests,
loadDynamicStub,
installContracts,
setSpecmaticEnvironment
} from 'specmatic';Specmatic JS library exposes methods which can be used in your JS project to setup the tests, as well as do advanced things like load stubs dynamically. These can be used to programmatically run specmatic commands from any javascript testing framework, during setup or test phases.
startStubServer(specmaticDir: string, stubDir: string, host: string, port: string)
method to start the stub server.
runContractTests(specmaticDir: string, host: string, port: string)
Alias: startTestServer
method to start test server.
loadDynamicStub(stubPath: string)
Alias: setExpectations
method to load stub dynamically from inside an automated test.
installContracts()
Alias: installSpecs
method to install specs in local machine.
setSpecmaticEnvironment = (environmentName: string, environment: Environment)
method to dynamically write new variables or assign values to variables of the environment passed as argument to the function, inside the file 'specmatic.json'.This function expects the file 'specmatic.json' to be in the root directory of your project.
printSpecmaticJarVersion()
method to print the version of specmatic.jar
