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

Commit

Permalink
Merge pull request #161 from mocks-server/release
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
javierbrea committed May 5, 2021
2 parents f8c2a27 + dee353a commit ec2e5bb
Show file tree
Hide file tree
Showing 33 changed files with 2,093 additions and 179 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: ["12.22.1", "14.16.1", "15.14.0"]
node: ["12.22.1", "14.16.1", "15.14.0", "16.1.0"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
runs-on: windows-2019
strategy:
matrix:
node: ["15.2.0"]
node: ["16.1.0"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Download test results
uses: actions/download-artifact@v2
with:
name: coverage-15.14.0
name: coverage-16.1.0
path: coverage
- name: Coveralls
uses: coverallsapp/github-action@master
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 @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
node-version: '14.x'
registry-url: 'https://npm.pkg.github.com'
# Defaults to the user or organization that owns the workflow file
scope: '@mocks-server'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
node-version: '14.x'
registry-url: 'https://registry.npmjs.org/'
- run: npm publish
env:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Removed
### BREAKING CHANGES

## [2.3.0] - 2021-05-05

### Added
- feat: Validate that routes and mocks files export an array (#101)
- feat: Validate routes and route variants format (#101)
- feat: Validate mocks format (#101)
- feat: Add an alert when mocks contains non existent routeVariants (#101)
- feat: Ignore mocks, routes and route variants with duplicated ids (#101)
- feat: Add an alert if mock "from" property is not valid (not correspondent to any mock id) (#101)
- feat: Add an alert if there are many variants of the same route in the same mock (#101)
- feat: Support defining http methods in lowercase
- chore: Support Node.js v16.x

### Changed
- chore(deps): update dependencies

### Fixed
- fix: Routes with delay 0 had delay null in plain representation

## [2.2.0] - 2021-04-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {

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

// The test environment that will be used for testing
testEnvironment: "node",
Expand Down
2 changes: 1 addition & 1 deletion jest.e2e.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
clearMocks: true,

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

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: false,
Expand Down
67 changes: 50 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mocks-server/core",
"version": "2.2.0",
"version": "2.3.0",
"description": "Pluggable mock server supporting multiple route variants and mocks",
"keywords": [
"mocks",
Expand Down Expand Up @@ -41,6 +41,8 @@
"dependencies": {
"@babel/register": "7.13.14",
"@hapi/boom": "9.1.2",
"ajv": "8.1.0",
"ajv-errors": "3.0.0",
"body-parser": "1.19.0",
"commander": "6.2.1",
"cors": "2.8.5",
Expand Down Expand Up @@ -88,6 +90,6 @@
}
},
"engines": {
"node": "12.x || 14.x || 15.x"
"node": "12.x || 14.x || 15.x || 16.x"
}
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.organization=mocks-server
sonar.projectKey=mocks-server-core
sonar.projectVersion=2.2.0
sonar.projectVersion=2.3.0

sonar.javascript.file.suffixes=.js
sonar.sourceEncoding=UTF-8
Expand Down
19 changes: 4 additions & 15 deletions src/mocks/Mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ const express = require("express");

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

const METHODS = {
GET: "get",
POST: "post",
PATCH: "patch",
DELETE: "delete",
PUT: "put",
OPTIONS: "options",
HEAD: "head",
TRACE: "trace",
};
const { HTTP_METHODS } = require("./validations");

class Mock {
constructor({ id, routesVariants, getDelay }) {
Expand All @@ -38,7 +29,8 @@ class Mock {
? routeVariant.method
: [routeVariant.method];
methods.forEach((method) => {
this._router[METHODS[method]](routeVariant.url, (req, res, next) => {
const httpMethod = HTTP_METHODS[method.toUpperCase()];
this._router[httpMethod](routeVariant.url, (req, res, next) => {
const delay = routeVariant.delay !== null ? routeVariant.delay : this._getDelay();
if (delay > 0) {
tracer.verbose(`Applying delay of ${delay}ms to route variant "${this._id}"`);
Expand All @@ -49,10 +41,7 @@ class Mock {
next();
}
});
this._router[METHODS[method]](
routeVariant.url,
routeVariant.middleware.bind(routeVariant)
);
this._router[httpMethod](routeVariant.url, routeVariant.middleware.bind(routeVariant));
});
});
}
Expand Down
Loading

0 comments on commit ec2e5bb

Please sign in to comment.