Code Monkey home page Code Monkey logo

apish's Introduction

Build Status Coveralls Status npm downloads Greenkeeper badge

apish - Mock APIs and Services

Describe any API or Service you need mocked. Supports API Blueprint and Swagger API Description formats.

Use cases

3rd party APIs

  • Your app is calling GitHub API, weather API, Trello API, …
  • Describe endpoints in API Description format like API Blueprint (or ask API provider for API Description)
  • Add it as a test fixture and let apish create mock for you:
before(() => {
  return apish(fs.readFileSync('github-api.apib', 'utf8'));
});

// Run your tests with mocked requests against GitHub API

(Micro)services

  • Have all your services publish API Description onto (private) npm. Use semver to version it and tools like Dredd to test its implementation
  • When you depend on another service, just require its package with API Description and run tests against its mocks, that are always in sync with implementation
  • You can always compare version you've tested against to what is currently running in your environment
import myOtherService from 'myOtherService';

before(() => apish(myOtherService));

// Run your tests…

Installation

$ npm i apish -D

Usage

import apish from 'apish';

// In your test runner
let mockResult = {};
before(() => {
  const apib = fs.readFileSync('github-api.apib', 'utf8');
  return mockResult = apish(apib); // apish returns a Promise
});

// Cleanup
after(() => {
  // .value() is Promise-related helper in this case
  mockResult.value().restore();
});

Arguments

const mockedApi = apish(apiDescription, options);
  • apiDescription (string) - API Blueprint or Swagger API Description
  • options (OPTIONAL, object)
    • host (string) - overwrite specified host (base URL) that should be used

returns Promise

Resolved promise returns object with methods:

  • restore() - clears all mocks for this host

License

MIT

apish's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar jackub avatar snakeye avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

apish's Issues

An in-range update of nock is breaking the build 🚨

Version 9.0.23 of nock was just published.

Branch Build failing 🚨
Dependency nock
Current Version 9.0.22
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

nock is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v9.0.23

9.0.23 (2017-10-20)

Bug Fixes

  • include path in the matching log output (#996) (ea2fe9f)

Previous Changelog

Find changes for versions before 9.0.23 at https://github.com/node-nock/nock/blob/bd387365ff8e6df731cf5a35cc92560346826ec5/CHANGELOG.md

Commits

The new version differs by 7 commits.

  • f13add9 chore(travis): semantic-release setup
  • 909dbce chore(package): semantic-release
  • e4b0958 test: intercept test fix
  • 62e7566 Fix matchStringOrRegexp TypeError on undefined (#998)
  • 4772df5 allowUnmocked causes no requests to match when query is specified (#955)
  • ea2fe9f fix: include path in the matching log output (#996)
  • 6d9704d chore(CHANGELOG): 9.0.22

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of request is breaking the build 🚨

Version 2.88.0 of request was just published.

Branch Build failing 🚨
Dependency request
Current Version 2.87.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

request is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).
  • coverage/coveralls: First build on greenkeeper/request-2.88.0 at 100.0% (Details).

Commits

The new version differs by 13 commits.

  • 6420240 2.88.0
  • bd22e21 fix: massive dependency upgrade, fixes all production vulnerabilities
  • 925849a Merge pull request #2996 from kwonoj/fix-uuid
  • 7b68551 fix(uuid): import versioned uuid
  • 5797963 Merge pull request #2994 from dlecocq/oauth-sign-0.9.0
  • 628ff5e Update to oauth-sign 0.9.0
  • 10987ef Merge pull request #2993 from simov/fix-header-tests
  • cd848af These are not going to fail if there is a server listening on those ports
  • a92e138 #515, #2894 Strip port suffix from Host header if the protocol is known. (#2904)
  • 45ffc4b Improve AWS SigV4 support. (#2791)
  • a121270 Merge pull request #2977 from simov/update-cert
  • bd16414 Update test certificates
  • 536f0e7 2.87.1

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

An in-range update of eslint is breaking the build 🚨

Version 4.16.0 of eslint was just published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.15.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796) (Michael Ficarra)
  • af043eb Update: Add NewExpression support to comma-style (#9591) (Frazer McLean)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813) (Matija Marohnić)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852) (Kevin Partington)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855) (PiIsFour)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847) (Kevin Partington)
  • 978574f Docs: Fix examples for no-useless-escape (#9853) (Toru Kobayashi)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815) (Kevin Partington)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816) (Kevin Partington)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831) (Teddy Katz)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820) (Teddy Katz)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819) (Teddy Katz)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818) (Teddy Katz)
  • 6a5cd32 Fix: prefer-destructuring error with computed properties (fixes #9784) (#9817) (Teddy Katz)
  • 601f851 Docs: Minor modification to code comments for clarity (#9821) (rgovind92)
  • b9da067 Docs: fix misleading info about RuleTester column numbers (#9830) (Teddy Katz)
  • 2cf4522 Update: Rename and deprecate object-property-newline option (#9570) (Jonathan Pool)
  • acde640 Docs: Add ES 2018 to Configuring ESLint (#9829) (Kai Cataldo)
  • ccfce15 Docs: Minor tweaks to working with rules page (#9824) (Kevin Partington)
  • 54b329a Docs: fix substitution of {{ name }} (#9822) (Andres Kalle)
Commits

The new version differs by 22 commits.

  • 33ca1ea 4.16.0
  • 1a9ddee Build: changelog update for 4.16.0
  • e26a25f Update: allow continue instead of if wrap in guard-for-in (fixes #7567) (#9796)
  • af043eb Update: Add NewExpression support to comma-style (#9591)
  • 4f898c7 Build: Fix JSDoc syntax errors (#9813)
  • 13bcf3c Fix: Removing curly quotes in no-eq-null report message (#9852)
  • b96fb31 Docs: configuration hierarchy for CLIEngine options (fixes #9526) (#9855)
  • 8ccbdda Docs: Clarify that -c configs merge with .eslintrc.* (fixes #9535) (#9847)
  • 978574f Docs: Fix examples for no-useless-escape (#9853)
  • cd5681d Chore: Deactivate consistent-docs-url in internal rules folder (#9815)
  • 2e87ddd Docs: Sync messageId examples' style with other examples (#9816)
  • 1d61930 Update: use doctrine range information in valid-jsdoc (#9831)
  • 133336e Update: fix indent behavior on template literal arguments (fixes #9061) (#9820)
  • ea1b15d Fix: avoid crashing on malformed configuration comments (fixes #9373) (#9819)
  • add1e70 Update: fix indent bug on comments in ternary expressions (fixes #9729) (#9818)

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Problem with parameters in URL and URITemplate

Hello!

I'm trying to implement API tests with apish and looks like I've found a problem.

Consider the following API endpoints:

http://www.example.com:80/users/{user}/
http://www.example.com:80/users/{user}/posts/

In file create-mocks.js:28 the filtering path function will match API call /users/example/posts/ to the first endpoint due to nature of the URI Template - they use regexp /(.*)/$ to extract parameters.

An in-range update of sinon is breaking the build 🚨

Version 5.0.9 of sinon was just published.

Branch Build failing 🚨
Dependency sinon
Current Version 5.0.8
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

sinon is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 5 commits.

  • 86b930c Update docs/changelog.md and set new release id in docs/_config.yml
  • 033aa60 Add release documentation for v5.0.9
  • 3321085 5.0.9
  • 9f321d5 Update History.md and AUTHORS for new release
  • e862196 Upgrade @std/esm to esm.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

Version 4.6.1 of eslint just got published.

Branch Build failing 🚨
Dependency eslint
Current Version 4.6.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.6.1
  • bdec46d Build: avoid process leak when generating website (#9217) (Teddy Katz)
  • cb74b87 Fix: avoid adding globals when an env is used with false (fixes #9202) (#9203) (Teddy Katz)
  • f9b7544 Docs: Correct a typo in generator-star-spacing documentation (#9205) (Ethan Rutherford)
  • e5c5e83 Build: Fixing issue with docs generation (Fixes #9199) (#9200) (Ilya Volodin)
Commits

The new version differs by 6 commits.

  • d65c540 4.6.1
  • 61c845c Build: changelog update for 4.6.1
  • bdec46d Build: avoid process leak when generating website (#9217)
  • cb74b87 Fix: avoid adding globals when an env is used with false (fixes #9202) (#9203)
  • f9b7544 Docs: Correct a typo in generator-star-spacing documentation (#9205)
  • e5c5e83 Build: Fixing issue with docs generation (Fixes #9199) (#9200)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Any way to use as express middleware?

Can the Promise returned by apish() be utilized as Express middleware? It would be useful to see more specific documentation on what can be done with that returned promise.

An in-range update of babel-loader is breaking the build 🚨

Version 6.4.1 of babel-loader just got published.

Branch Build failing 🚨
Dependency babel-loader
Current Version 6.4.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-loader is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Release Notes v6.4.1

🐛 Bug Fix

Commits

The new version differs by 2 commits .

  • 48325ea 6.4.1
  • f3241f8 Fixed reset of BABEL_ENV when options.forceEnv is used (#420)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of urijs is breaking the build 🚨

Version 1.18.9 of urijs just got published.

Branch Build failing 🚨
Dependency urijs
Current Version 1.18.8
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As urijs is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes 1.18.9 (March 6th 2017)
  • adding option strict to URITemplate() in order to throw an exception in case a placeholder could not be replaced - PR #331
Commits

The new version differs by 3 commits .

  • 230da87 chore(dist): updating distributables to version 1.18.9
  • 303817f chore(build): bumping to version 1.18.9
  • c70874e feature(templates): adding strict mode for placeholder replacement (#331)

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of nock is breaking the build 🚨

Version 9.0.5 of nock just got published.

Branch Build failing 🚨
Dependency nock
Current Version 9.0.4
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As nock is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Commits

The new version differs by 12 commits .

  • 0fb8c3d 9.0.5: Various bug fixes
  • 86babe8 Merge pull request #822 from KingHenne/fix/isomorphic-fetch-basic-auth
  • 2318034 Merge pull request #823 from KingHenne/fix/nyc-config
  • 58b04e3 Merge pull request #769 from RubenVerborgh/fix-socket-this
  • 2ae0f25 exclude test files from coverage reports
  • 7fbc2f9 add text summary coverage reporter
  • 933cbad fix basicAuth/matchHeader interceptors with isomorphic-fetch
  • 26b2610 add failing test for isomorphic-fetch and matchHeader
  • d8b6d62 add failing test for isomorphic-fetch and basicAuth
  • 1d1cafc Merge pull request #821 from node-nock/chore-changelog-v9.0.4
  • 219241d Update changelog using "npm run changelog"
  • 50859e5 Set this to request on socket event.

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-core is breaking the build 🚨

Version 6.25.0 of babel-core just got published.

Branch Build failing 🚨
Dependency babel-core
Current Version 6.24.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-core is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v3.4.0

Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.

This week's highlights:

  • allowUncaught added to commandline as --allow-uncaught (and bugfixed)
  • warning-related Node flags

🎉 Enhancements

🐛 Fixes

🔩 Other

Commits

The new version differs by 9 commits0.

  • 7554b31 Add Changelog for v3.4.0
  • 9f7f7ed Add --trace-warnings flag
  • 92561c8 Add --no-warnings flag
  • ceee976 lint test/integration/fixtures/simple-reporter.js
  • dcfc094 Revert "use semistandard directly"
  • 93392dd no special case for macOS running Karma locally
  • 4d1d91d --allow-uncaught cli option
  • fb1e083 fix allowUncaught in browser
  • 4ed3fc5 Add license report and scan status

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of sinon-chai is breaking the build 🚨

Version 2.11.0 of sinon-chai just got published.

Branch Build failing 🚨
Dependency sinon-chai
Current Version 2.10.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As sinon-chai is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes 2.11.0

Added support for Chai 4.x (@charlierudolph, #101).

Commits

The new version differs by 5 commits.

  • 1513007 Version 2.11.0
  • 63ac40f Convert the tests away from CoffeeScript
  • 40b35f3 Add support for, and test against, Chai v4
  • 5ff1468 Various cleanups and updates
  • 10dd944 Only test "immediately" call order variants when they exist

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

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.