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
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- master
- release
- pre-release
pull_request:
jobs:
test:
Expand Down Expand Up @@ -38,8 +39,6 @@ jobs:
run: npm ci
- name: Lint
run: npm run lint
- name: Test unit
run: npm run test:unit
- name: Test E2E
run: npm run test:e2e
id: test-e2e
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
scope: '@mocks-server'
- run: npm publish
- run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org/'
- run: npm publish
- run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# tests
/coverage
/mocks
/test/e2e/fixtures/files-watch
/test/e2e/fixtures/temp
/test/e2e/fixtures/mocks.config.js

# misc
.DS_Store
Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,31 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [To be deprecated]
- Remove deprecated "/mocks" api path.
- Remove property "name" from behavior model.

## [unreleased]
### Added
### Changed
### Fixed
- docs(readme): Add missed API resources.
### Removed

## [2.0.0-beta.2] - 2021-01-16

### Changed
- chore(deps): Update mocks-server/core dependency. Adapt tests.

## [2.0.0-beta.1] - 2021-01-14

### Added
- Add mocks, routes, routes-variants and mock-custom-routes-variants apis

### Changed
- Move behaviors and fixtures apis under legacy folder
- refactor: Use helper to create routers with same structure

### Removed
- Remove deprecated api paths
- Remove adminApiDeprecatedPaths option.

## [1.5.0] - 2020-12-25

### Added
Expand Down
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,46 @@

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

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].
Plugin for [Mocks Server][website-url] that provides an API REST that allows to change the current behavior, change delay time, and another [Mocks Server options][options-url].

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.
This is __very useful when running acceptance tests, as you can change the current mock__ simply with a HTTP request in the `before` method of your tests, for example.

A __client for the administration api__ is also distributed as a separated package: [@mocks-server/admin-api-client](https://www.npmjs.com/package/@mocks-server/admin-api-client).

## Usage

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].

## Options

* `adminApiPath` - Base path for the administration api. Default is "/admin". You should change it only if there is any conflict with the api you are mocking.
* `adminApiDeprecatedPaths` - Boolean option, disables deprecated "/mocks" api path, which is still enabled by default.
* __`adminApiPath`__ _(String)_: Path for the administration api. Default is `/admin`. You should change it only in case there is any conflict with the api you are mocking.

Read more about [how to define options for the mocks-server plugins here](https://www.mocks-server.org/docs/configuration-options).
Read more about [how to set options in Mocks Server here](https://www.mocks-server.org/docs/configuration-options).

## API Resources

Available api resources are:

* `GET` `/admin/about` Returns plugin information.
* `GET` `/admin/about` Returns "plugin-admin-api" information.
* Response body example: `{ "version": "1.2.0" }`
* `GET` `/admin/behaviors` Returns behaviors collection.
* `GET` `/admin/behaviors/:id` Returns an specific behavior.
* `GET` `/admin/fixtures` Returns fixtures collection.
* `GET` `/admin/fixtures/:id` Returns an specific fixture.
* `GET` `/admin/mocks` Returns mocks.
* `GET` `/admin/mocks/:id` Returns a specific mock.
* `GET` `/admin/routes` Returns routes collection.
* `GET` `/admin/routes/:id` Returns a specific route.
* `GET` `/admin/routes-variants` Returns routes variants collection.
* `GET` `/admin/routes-variants/:id` Returns a specific route variant.
* `GET` `/admin/mock-custom-routes-variants` Returns an array of currently custom routes variants ids.
* `POST` `/admin/mock-custom-routes-variants` Defines a route variant to be used by current mock.
* Request body example: `{ "id": "users:error" }`
* `DELETE` `/admin/mock-custom-routes-variants` Restore routes variants to those defined in current mock.
* `GET` `/admin/settings` Returns current server settings.
* Response body example: `{ "delay": 0, behavior: "foo-behavior", path: "mocks" }`
* Response body example: `{ "delay": 0, mock: "foo-mock", path: "mocks" }`
* `PATCH` `/admin/settings` Changes current server settings.
* Request body example: `{ "delay": 3000 }`
* `GET` `/admin/alerts` Returns current alerts.
* `GET` `/admin/alerts/:id` Returns an specific alert. The alert `id` is equivalent to the alert `context`.
* `GET` `/admin/alerts/:id` Returns a specific alert. The alert `id` is equivalent to the alert `context` _(read the [developing plugins chapter](plugins-developing-plugins.md) for further info about alerts)_.

> Deprecated api resources under "/mocks" api path are still available.
> v1.x deprecated api resources are also still available under the `/legacy` path.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module.exports = {
},

// The glob patterns Jest uses to detect test files
testMatch: ["<rootDir>/test/unit/**/*.spec.js"],
// testMatch: ["<rootDir>/test/unit/**/Plugin.spec.js"],
testMatch: ["<rootDir>/test/e2e/**/*.spec.js"],
// testMatch: ["<rootDir>/test/e2e/**/legacy-behaviors-api.spec.js"],

// The test environment that will be used for testing
testEnvironment: "node",
Expand Down
16 changes: 0 additions & 16 deletions jest.e2e.config.js

This file was deleted.

Loading