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
Show all changes
45 commits
Select commit Hold shift + click to select a range
df19714
docs(readme): Add missed API resources
javierbrea Dec 26, 2020
590618e
chore(deps): update dependency jest to v26.6.3
renovate-bot Jan 5, 2021
8daeb53
Merge pull request #75 from mocks-server/renovate/jest-monorepo
renovate[bot] Jan 9, 2021
da9dce8
feat: Add API resources for core v2 mocks, routes and routesVariants.…
javierbrea Feb 2, 2021
f57d55f
chore(deps): update dependency eslint to v7.19.0
renovate-bot Feb 2, 2021
a1506d7
chore: publish with beta tag
javierbrea Feb 3, 2021
5d2335f
feat: use admin-api-paths 2.0.0-beta.1
javierbrea Feb 3, 2021
77b5898
feat: Remove adminApiDeprecatedPaths option. Move legacy api under ma…
javierbrea Feb 3, 2021
f0dfb5f
Merge pull request #81 from mocks-server/renovate/eslint-7.x
renovate[bot] Feb 10, 2021
ae709a3
chore(deps): update dependency eslint-plugin-prettier to v3.3.1
renovate-bot Feb 10, 2021
135ad75
Merge pull request #82 from mocks-server/renovate/eslint-plugin-prett…
renovate[bot] Feb 11, 2021
9febc31
chore(deps): update dependency husky to v4.3.8
renovate-bot Feb 11, 2021
79a2d46
Merge pull request #83 from mocks-server/renovate/husky-4.x
renovate[bot] Feb 11, 2021
40bd22f
chore(deps): update dependency lint-staged to v10.5.4
renovate-bot Feb 11, 2021
7afecd8
Merge pull request #84 from mocks-server/renovate/lint-staged-10.x
renovate[bot] Feb 11, 2021
d29357d
chore(deps): update dependency fs-extra to v9.1.0
renovate-bot Feb 11, 2021
2a4f10c
Merge pull request #85 from mocks-server/renovate/fs-extra-9.x
renovate[bot] Feb 11, 2021
99fae33
chore(deps): update dependency prettier to v2.2.1
renovate-bot Feb 11, 2021
9368692
Merge pull request #86 from mocks-server/renovate/prettier-2.x
renovate[bot] Feb 12, 2021
00c9d5b
chore(deps): update dependency sinon to v9.2.4
renovate-bot Feb 12, 2021
ee891f3
Merge pull request #87 from mocks-server/renovate/sinon-9.x
renovate[bot] Feb 12, 2021
44b08c0
fix(deps): update dependency @hapi/boom to v9.1.1
renovate-bot Feb 12, 2021
46fce89
Merge pull request #88 from mocks-server/renovate/hapijs-monorepo
renovate[bot] Feb 12, 2021
ab98162
chore(deps): update dependency eslint-config-prettier to v7
renovate-bot Feb 12, 2021
f7bca60
feat: add resource to admin custom routes variants
javierbrea Feb 14, 2021
ab78253
test: adapt e2e tests. Get coverage from e2e tests. remove unit tests
javierbrea Feb 14, 2021
86fac1c
chore: do not run unit tests in ci
javierbrea Feb 14, 2021
3229412
chore(release): Upgrade version
javierbrea Feb 14, 2021
ab3b6cf
chore: merge with release
javierbrea Feb 14, 2021
0dd122b
chore(ci): Build pre-release branch
javierbrea Feb 14, 2021
7f59f09
chore(sonar): exclude fixtures from sonar analysis
javierbrea Feb 14, 2021
0951e32
style: fix sonar smell
javierbrea Feb 14, 2021
5a3bedb
chore(deps): Update core dependency
javierbrea Feb 16, 2021
74f9a07
Merge pull request #89 from mocks-server/renovate/eslint-config-prett…
javierbrea Feb 16, 2021
dbd8a74
chore(deps): update dependency eslint to v7.20.0
renovate-bot Feb 16, 2021
7b2c3fd
Merge pull request #90 from mocks-server/renovate/eslint-7.x
renovate[bot] Feb 17, 2021
26ab596
refactor: fix Sonar smell
javierbrea Feb 17, 2021
53db278
chore: merge
javierbrea Feb 17, 2021
2b250f2
chore(deps): Update dependencies
javierbrea Feb 17, 2021
57e6046
docs: add license
javierbrea Feb 17, 2021
2234af8
Merge pull request #92 from mocks-server/pre-release
javierbrea Feb 17, 2021
acab336
Merge branch 'master' into release
javierbrea Feb 17, 2021
1ad769c
chore: publish without tags
javierbrea Feb 17, 2021
29da8a3
chore(release): Upgrade version
javierbrea Feb 17, 2021
afae700
docs: add breaking changes
javierbrea Feb 17, 2021
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
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
39 changes: 37 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,50 @@ 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
### Removed

## [2.0.0] - 2021-02-17

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

### Changed
- feat: Move behaviors and fixtures apis under legacy folder
- refactor: Use helper to create routers with same structure
- chore(deps): Update dependencies

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

### BREAKING CHANGES
- Move behaviors and fixtures apis under legacy folder
- Remove deprecated api paths
- Remove adminApiDeprecatedPaths option.

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

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

## [2.0.0-beta.1] - 2021-02-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: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +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 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