Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# tests
/coverage
/mocks
/test/acceptance/main/fixtures/files-watch
/test/acceptance/fixtures/files-watch

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ script:
- npm run lint
- npm run test-ci
- npm run coveralls
- sonar-scanner -Dsonar.login=${SONAR_TOKEN}
- 'if [ -n "$SONAR_TOKEN" ]; then sonar-scanner -Dsonar.login=${SONAR_TOKEN}; fi'

deploy:
provider: npm
Expand Down
54 changes: 4 additions & 50 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [To be deprecated]
- Deprecate options "features" and "feature".
- Remove "/features" api path.
- Remove "features" getter from Server
- Remove Server and Cli constructors. Use @mocks-server/core instead

## [unreleased]
### Added
### Changed
### Fixed
### Removed

## [1.3.0] - 2019-11-17
### Added
- Add programmatic Classes end-to-end tests
- Add files watcher end-to-end tests

### Changed
- Full refactor for making it pluggable.
- Split code into core, cli and api main Classes, which are intended to be published separately.

## [1.2.0] - 2019-11-13
### Added
- Add api acceptance tests

### Changed
- Upgrade dependencies

### Fixed
- Catch server.listen error and reject start method promise with it when occurs.

## [1.1.1] - 2019-11-12
### Changed
- Change readme. Add links to docs website.

## [1.1.0] - 2019-11-08
### Changed
- Change "feature" concept by "behavior". Maintain old "feature" options and urls as aliases for maintaining compatibility.
- Upgrade dependencies

## [1.0.3] - 2019-11-08
### Fixed
- Fix examples and badges in readme.

## [1.0.2] - 2019-11-08
### Changed
- Project forked from xbyorange/mocks-server. Fixed license. Read NOTICE for further details

### Fixed
- Fix some minor Sonar bugs and code smells.

## [1.0.1] - 2019-06-04
### Fixed
- Upgrade dependencies to fix potential security vulnerability
- Bind winston tracer methods to winston tracer instance to fix an issue produced by new Winston version as described in: https://github.com/winstonjs/winston/issues/1577

## [1.0.0] - 2019-06-04
### Changed
- Forked from xbyorange mocks-server gitlab private repository.
## [1.0.0] - 2019-12-06
- Migrate administration api from [@mocks-server/main, v1.3.0](https://github.com/mocks-server/main/releases/tag/v1.3.0). For further info read the [previous repository CHANGELOG.md](https://github.com/mocks-server/main/blob/v1.3.0/CHANGELOG.md#130---2019-11-17)
- Export Plugin, which can be used only programmatically. (Binary is still distributed in the [@mocks-server/main](https://github.com/mocks-server/main) package).
- Remove core and inquirer-cli. Both have now their own repositories.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@

END OF TERMS AND CONDITIONS

Copyright 2019 Javier Brea and contributors
Copyright 2019 Javier Brea
Copyright 2019 XbyOrange
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mocks-server. Main distributable
mocks-server admin-api plugin.
Copyright 2019 Javier Brea

Portions of this software were developed at XbyOrange company.
Expand Down
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,51 @@
[![NPM downloads][npm-downloads-image]][npm-downloads-url] [![License][license-image]][license-url]


# [![Mocks Server][logo-url]][website-url] Mocks Server
# [![Mocks Server][logo-url]][website-url] Mocks Server Plugin Admin Api

This package provides a server that simulates API behaviors. It can be added as a dependency of your project, and started simply running an NPM command.
Plugin for [Mocks Server][website-url] that provides an API REST that allows to change dinamically the current behavior, change delay time, and another [Mocks Server options][options-url].

## Documentation
This is __very useful when running acceptance tests, as you can change the behavior of the api__ simply making an HTTP request in your tests `before` method, for example.

Please refer to the [project documentation website][website-url]:
## Usage

* [Get started](https://www.mocks-server.org/docs/get-started-intro)
* [Tutorials](https://www.mocks-server.org/docs/tutorials-static)
* [Configuration](https://www.mocks-server.org/docs/configuration-command-line-arguments)
This plugin is included in the [main distribution of the Mocks Server project][main-distribution-url], so you can refer to the [official documentation website][website-url].

## Why a mocks server?
## API Resources

Controlling the responses of the api will improve the front-end development workflow, avoiding early dependencies with back-end. It also improves the testing and development of error cases or another cases that are commonly hard to reproduce in the real api.
Available api resources are:

Defining the api responses during the earliest phases of development will improve the communication among team members and align their expectations.

Working with Node.js, it integrates better in front-end projects as any other NPM dependency, and it will be easier for front-end developers to maintain the mocks.
* `GET` `/mocks/behaviors/current` Returns current behavior.
* `PUT` `/mocks/behaviors/current` Set current behavior.
* Request body example: `{ "name": "behavior-name" }`
* `GET` `/mocks/settings` Returns current server settings.
* Response body example: `{ "delay": 0 }`
* `PUT` `/mocks/settings` Changes current server settings.
* Request body example: `{ "delay": 3000 }`

## Contributing

Contributors are welcome.
Please read the [contributing guidelines](.github/CONTRIBUTING.md) and [code of conduct](.github/CODE_OF_CONDUCT.md).

[website-url]: https://www.mocks-server.org
[main-distribution-url]: https://www.npmjs.com/package/@mocks-server/main
[options-url]: https://www.mocks-server.org/docs/configuration-options
[logo-url]: https://www.mocks-server.org/img/logo_120.png
[inquirer-url]: https://www.npmjs.com/package/inquirer#support-os-terminals
[inquirer-support]: https://www.npmjs.com/package/inquirer#support-os-terminals

[coveralls-image]: https://coveralls.io/repos/github/mocks-server/main/badge.svg
[coveralls-url]: https://coveralls.io/github/mocks-server/main
[travisci-image]: https://travis-ci.com/mocks-server/main.svg?branch=master
[travisci-url]: https://travis-ci.com/mocks-server/main
[last-commit-image]: https://img.shields.io/github/last-commit/mocks-server/main.svg
[last-commit-url]: https://github.com/mocks-server/main/commits
[license-image]: https://img.shields.io/npm/l/@mocks-server/main.svg
[license-url]: https://github.com/mocks-server/main/blob/master/LICENSE
[npm-downloads-image]: https://img.shields.io/npm/dm/@mocks-server/main.svg
[npm-downloads-url]: https://www.npmjs.com/package/@mocks-server/main
[npm-dependencies-image]: https://img.shields.io/david/mocks-server/main.svg
[npm-dependencies-url]: https://david-dm.org/mocks-server/main
[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=mocks-server-main&metric=alert_status
[quality-gate-url]: https://sonarcloud.io/dashboard?id=mocks-server-main
[release-image]: https://img.shields.io/github/release-date/mocks-server/main.svg
[release-url]: https://github.com/mocks-server/main/releases

[coveralls-image]: https://coveralls.io/repos/github/mocks-server/plugin-admin-api/badge.svg
[coveralls-url]: https://coveralls.io/github/mocks-server/plugin-admin-api
[travisci-image]: https://travis-ci.com/mocks-server/plugin-admin-api.svg?branch=master
[travisci-url]: https://travis-ci.com/mocks-server/plugin-admin-api
[last-commit-image]: https://img.shields.io/github/last-commit/mocks-server/plugin-admin-api.svg
[last-commit-url]: https://github.com/mocks-server/plugin-admin-api/commits
[license-image]: https://img.shields.io/npm/l/@mocks-server/plugin-admin-api.svg
[license-url]: https://github.com/mocks-server/plugin-admin-api/blob/master/LICENSE
[npm-downloads-image]: https://img.shields.io/npm/dm/@mocks-server/plugin-admin-api.svg
[npm-downloads-url]: https://www.npmjs.com/package/@mocks-server/plugin-admin-api
[npm-dependencies-image]: https://img.shields.io/david/mocks-server/plugin-admin-api.svg
[npm-dependencies-url]: https://david-dm.org/mocks-server/plugin-admin-api
[quality-gate-image]: https://sonarcloud.io/api/project_badges/measure?project=mocks-server-plugin-admin-api&metric=alert_status
[quality-gate-url]: https://sonarcloud.io/dashboard?id=mocks-server-plugin-admin-api
[release-image]: https://img.shields.io/github/release-date/mocks-server/plugin-admin-api.svg
[release-url]: https://github.com/mocks-server/plugin-admin-api/releases
Binary file removed assets/cli_animation.gif
Binary file not shown.
14 changes: 0 additions & 14 deletions bin/mocks-server

This file was deleted.

30 changes: 0 additions & 30 deletions docs/cli.md

This file was deleted.

11 changes: 2 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ Unless required by applicable law or agreed to in writing, software distributed

"use strict";

const ProgrammaticCli = require("./lib/ProgrammaticCli");
const ProgrammaticServer = require("./lib/ProgrammaticServer");
const Behavior = require("./lib/core/mocks/Behavior");
const PluginAdminApi = require("./src/Api");

module.exports = {
Cli: ProgrammaticCli,
Server: ProgrammaticServer,
Feature: Behavior,
Behavior
};
module.exports = PluginAdminApi;
1 change: 0 additions & 1 deletion jest.acceptance.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
clearMocks: true,

testMatch: ["**/test/acceptance/**/?(*.)+(spec|test).js?(x)"],
//testMatch: ["**/test/acceptance/main/programmatic-cli.spec.js"],

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: false,
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ["index.js", "lib/**"],
collectCoverageFrom: ["index.js", "src/**"],

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",
Expand Down
67 changes: 0 additions & 67 deletions lib/ProgrammaticCli.js

This file was deleted.

Loading