Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.

Commit ec2e5bb

Browse files
authored
Merge pull request #161 from mocks-server/release
Release v2.3.0
2 parents f8c2a27 + dee353a commit ec2e5bb

33 files changed

Lines changed: 2093 additions & 179 deletions

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node: ["12.22.1", "14.16.1", "15.14.0"]
14+
node: ["12.22.1", "14.16.1", "15.14.0", "16.1.0"]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2
@@ -54,7 +54,7 @@ jobs:
5454
runs-on: windows-2019
5555
strategy:
5656
matrix:
57-
node: ["15.2.0"]
57+
node: ["16.1.0"]
5858
steps:
5959
- name: Checkout
6060
uses: actions/checkout@v2
@@ -90,7 +90,7 @@ jobs:
9090
- name: Download test results
9191
uses: actions/download-artifact@v2
9292
with:
93-
name: coverage-15.14.0
93+
name: coverage-16.1.0
9494
path: coverage
9595
- name: Coveralls
9696
uses: coverallsapp/github-action@master

.github/workflows/publish-to-github.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v2
1010
- uses: actions/setup-node@v2
1111
with:
12-
node-version: '12.x'
12+
node-version: '14.x'
1313
registry-url: 'https://npm.pkg.github.com'
1414
# Defaults to the user or organization that owns the workflow file
1515
scope: '@mocks-server'

.github/workflows/publish-to-npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v2
1010
- uses: actions/setup-node@v2
1111
with:
12-
node-version: '12.x'
12+
node-version: '14.x'
1313
registry-url: 'https://registry.npmjs.org/'
1414
- run: npm publish
1515
env:

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
### Removed
1515
### BREAKING CHANGES
1616

17+
## [2.3.0] - 2021-05-05
18+
19+
### Added
20+
- feat: Validate that routes and mocks files export an array (#101)
21+
- feat: Validate routes and route variants format (#101)
22+
- feat: Validate mocks format (#101)
23+
- feat: Add an alert when mocks contains non existent routeVariants (#101)
24+
- feat: Ignore mocks, routes and route variants with duplicated ids (#101)
25+
- feat: Add an alert if mock "from" property is not valid (not correspondent to any mock id) (#101)
26+
- feat: Add an alert if there are many variants of the same route in the same mock (#101)
27+
- feat: Support defining http methods in lowercase
28+
- chore: Support Node.js v16.x
29+
30+
### Changed
31+
- chore(deps): update dependencies
32+
33+
### Fixed
34+
- fix: Routes with delay 0 had delay null in plain representation
35+
1736
## [2.2.0] - 2021-04-14
1837

1938
### Added

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = {
2626

2727
// The glob patterns Jest uses to detect test files
2828
testMatch: ["<rootDir>/test/unit/**/*.spec.js"],
29-
// testMatch: ["<rootDir>/test/unit/**/files-loader/helpers.spec.js"],
29+
// testMatch: ["<rootDir>/test/unit/**/mocks/validations.spec.js"],
3030

3131
// The test environment that will be used for testing
3232
testEnvironment: "node",

jest.e2e.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
clearMocks: true,
77

88
testMatch: ["<rootDir>/test/e2e/**/*.spec.js"],
9-
// testMatch: ["<rootDir>/test/e2e/**/typescript.spec.js"],
9+
// testMatch: ["<rootDir>/test/e2e/v2/**/delay-setting.spec.js"],
1010

1111
// Indicates whether the coverage information should be collected while executing the test
1212
collectCoverage: false,

package-lock.json

Lines changed: 50 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mocks-server/core",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"description": "Pluggable mock server supporting multiple route variants and mocks",
55
"keywords": [
66
"mocks",
@@ -41,6 +41,8 @@
4141
"dependencies": {
4242
"@babel/register": "7.13.14",
4343
"@hapi/boom": "9.1.2",
44+
"ajv": "8.1.0",
45+
"ajv-errors": "3.0.0",
4446
"body-parser": "1.19.0",
4547
"commander": "6.2.1",
4648
"cors": "2.8.5",
@@ -88,6 +90,6 @@
8890
}
8991
},
9092
"engines": {
91-
"node": "12.x || 14.x || 15.x"
93+
"node": "12.x || 14.x || 15.x || 16.x"
9294
}
9395
}

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sonar.organization=mocks-server
22
sonar.projectKey=mocks-server-core
3-
sonar.projectVersion=2.2.0
3+
sonar.projectVersion=2.3.0
44

55
sonar.javascript.file.suffixes=.js
66
sonar.sourceEncoding=UTF-8

src/mocks/Mock.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,7 @@ const express = require("express");
1212

1313
const tracer = require("../tracer");
1414

15-
const METHODS = {
16-
GET: "get",
17-
POST: "post",
18-
PATCH: "patch",
19-
DELETE: "delete",
20-
PUT: "put",
21-
OPTIONS: "options",
22-
HEAD: "head",
23-
TRACE: "trace",
24-
};
15+
const { HTTP_METHODS } = require("./validations");
2516

2617
class Mock {
2718
constructor({ id, routesVariants, getDelay }) {
@@ -38,7 +29,8 @@ class Mock {
3829
? routeVariant.method
3930
: [routeVariant.method];
4031
methods.forEach((method) => {
41-
this._router[METHODS[method]](routeVariant.url, (req, res, next) => {
32+
const httpMethod = HTTP_METHODS[method.toUpperCase()];
33+
this._router[httpMethod](routeVariant.url, (req, res, next) => {
4234
const delay = routeVariant.delay !== null ? routeVariant.delay : this._getDelay();
4335
if (delay > 0) {
4436
tracer.verbose(`Applying delay of ${delay}ms to route variant "${this._id}"`);
@@ -49,10 +41,7 @@ class Mock {
4941
next();
5042
}
5143
});
52-
this._router[METHODS[method]](
53-
routeVariant.url,
54-
routeVariant.middleware.bind(routeVariant)
55-
);
44+
this._router[httpMethod](routeVariant.url, routeVariant.middleware.bind(routeVariant));
5645
});
5746
});
5847
}

0 commit comments

Comments
 (0)