Skip to content

Anne-and-Walter/spring-cloud-contract-json-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

JavaScript Spring Cloud Contract JSON Reader ๐ŸŽ†

Read Spring Cloud Contract JSON directly in your consumer contract tests and banish magic numbers once and for all! ๐Ÿ˜ฑ

Install ๐Ÿšš

npm install spring-cloud-contract-json-reader

or

yarn install spring-cloud-contract-json-reader

Usage ๐Ÿคน

  1. Set environment variable CONTRACT_JSON_BASE_PATH to wherever your contract test json is located relative to the root of your project's git repository. E.g.: build/stubs/META-INF/com.somepackage/myfancyapp/0.0.1-SNAPSHOT/mappings

Note: No need for leading or trailing slashes.

  1. Import the Spring Cloud Contract JSON Reader into your tests and start asserting on response body data!
const readJsonContractFile = require('spring-cloud-contract-json-reader');

const contractResponseBody = await readJsonContractFile('shouldReturnListOfSuperheroes.json');

const response = await axios.fetch('http://my-api/some-endpoint');

expect(response.data).toEqual(contractResponseBody);

Running Unit Tests โš™

This library includes its own test suite. You'll need to install testing dependencies before you can run the tests:

npm install

After that's done, just run the tests with:

npm test

License ๐Ÿ“ƒ

MIT

About

Read Spring Cloud Contract JSON directly in your consumer contract tests and banish magic numbers once and for all! ๐Ÿ˜ฑ

Resources

License

Stars

Watchers

Forks

Packages

No packages published