diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2583e32c..3f78a71c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: branches: - master - release + - feat-concepts pull_request: jobs: get-affected: diff --git a/README.md b/README.md index 3ebf2006a..7fc96b893 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

Mocks Server logo

+

Mocks Server logo

Build Status @@ -15,17 +15,27 @@ ## Introduction -This project provides a mock server that can simulate multiple responses for the same API routes. It can be added as a dependency of your project, and started simply running an NPM command. +Node.js mock server running live, interactive mocks in place of real APIs. __It makes able to define many different responses for a same route__, so, you can change the whole mocked API behavior by simply changing the response of one or many routes while the server is running. -It is easy to use both for development and testing because the responses of the mocked API and other configuration options can be changed while the server is running using: +## Usage -* Interactive command line user interface -* REST API client -* Other integration tools, such as [Cypress][cypress] commands +Define your mocked API routes in JSON, JavaScript or TypeScript files. Mocks Server loads them automatically and watches for changes. Defining routes using any of the available APIs is also possible. + +Routes can be defined in many ways, from plain objects to Express middlewares, and they can act in different ways also, from sending a response to proxy the request to another host. + +## Configuration + +Configure the server simply modifying the configuration file at the root folder of your project, or use command line arguments, or even environment variables. + +For changing options while it is running, you can also use any of the available integrations tools that enable live interactions with Mocks Server. + +## Integrations + +Providing a Javascript API, an interactive command line interface and a REST API for __changing the responses of the mocked API while it is running, it is easy to use both for development and testing__. Tools providing integrations with other ecosystems are also available, such as Cypress commands. ## Documentation -To check out docs, visit [mocks-server.org][website-url]. +To check out docs, visit [www.mocks-server.org][website-url]. ## Ecosystem diff --git a/mocks/admin-api-client-data-provider-e2e-mocks/mocks/mocks.json b/mocks/admin-api-client-data-provider-e2e-mocks/mocks/collections.json similarity index 51% rename from mocks/admin-api-client-data-provider-e2e-mocks/mocks/mocks.json rename to mocks/admin-api-client-data-provider-e2e-mocks/mocks/collections.json index 0b3e9ee3c..7cc91c9eb 100644 --- a/mocks/admin-api-client-data-provider-e2e-mocks/mocks/mocks.json +++ b/mocks/admin-api-client-data-provider-e2e-mocks/mocks/collections.json @@ -1,11 +1,11 @@ [ { "id": "base", - "routesVariants": ["get-user:1"] + "routes": ["get-user:1"] }, { "id": "user2", "from": "base", - "routesVariants": ["get-user:2"] + "routes": ["get-user:2"] } ] diff --git a/mocks/admin-api-client-data-provider-e2e-mocks/mocks/routes/users.js b/mocks/admin-api-client-data-provider-e2e-mocks/mocks/routes/users.js index 78c3ba7f2..b64b15fc5 100644 --- a/mocks/admin-api-client-data-provider-e2e-mocks/mocks/routes/users.js +++ b/mocks/admin-api-client-data-provider-e2e-mocks/mocks/routes/users.js @@ -6,16 +6,16 @@ module.exports = [ variants: [ { id: "1", - handler: "json", - response: { + type: "json", + options: { status: 200, body: [{ email: "foo@foo.com" }], }, }, { id: "2", - handler: "json", - response: { + type: "json", + options: { status: 200, body: [{ email: "foo2@foo2.com" }], }, diff --git a/mocks/admin-api-client-data-provider-e2e-react-app/src/App.js b/mocks/admin-api-client-data-provider-e2e-react-app/src/App.js index da9a4aa2a..4d19353b7 100644 --- a/mocks/admin-api-client-data-provider-e2e-react-app/src/App.js +++ b/mocks/admin-api-client-data-provider-e2e-react-app/src/App.js @@ -4,7 +4,7 @@ import { storeManager } from "@data-provider/core"; import About from "./modules/about"; import Settings from "./modules/settings"; -import Mocks from "./modules/mocks"; +import Mocks from "./modules/collections"; import CurrentRouteVariant from "./modules/current-route-variant"; import Routes from "./modules/routes"; import Alerts from "./modules/alerts"; diff --git a/mocks/admin-api-client-data-provider-e2e-react-app/src/modules/about/AboutView.js b/mocks/admin-api-client-data-provider-e2e-react-app/src/modules/about/AboutView.js index ce9418e1e..ee06d269d 100644 --- a/mocks/admin-api-client-data-provider-e2e-react-app/src/modules/about/AboutView.js +++ b/mocks/admin-api-client-data-provider-e2e-react-app/src/modules/about/AboutView.js @@ -1,3 +1,5 @@ +import { useMemo } from "react"; + import PropTypes from "prop-types"; const format = (value) => { @@ -5,15 +7,19 @@ const format = (value) => { }; const AboutView = ({ about }) => { - console.log(about); + const versions = useMemo(() => { + return (about && about.versions) || {}; + }, [about]); + return (

About