| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Webpack Dev Server mocking engine
npm i --save devmockor
yarn add devmockAnd require it for further usage
const { DevMock } = require("devmock")devServer: {
before: DevMock.v3({
mocksPath: path.resolve("mocks/**/*.mock.js")
})
}devServer: {
onBeforeSetupMiddleware: DevMock.make({
mocksPath: path.resolve("mocks/**/*.mock.js")
})
}DevMock.make({
mocksPath: "mocks/*.mock.js", // glob supported path to your mock files (required)
})DevMock.make and DevMock.v3 has the same params.
// mocks/exmaple.mock.js
module.exports = {
path: "/users", // Query path (required)
method: "GET", // HTTP method (optional, default: GET)
delay: 300, // Response delay in ms (optional, default: 0)
status: 200, // Response status code (options, default: 200)
response: [ // Response object (optional, default: {})
{ id: 1, name: "John" },
{ id: 2, name: "Mary" },
{ id: 3, name: "Bob" },
]
}Both status and response params can be a function of request params:
module.exports = {
path: "/users",
status: params => params.error ? 422 : 200,
response: params => params.error ? { success: false } : { success: true }
}Released under MIT License.
| Back | FazBrowse Home | New Git URL |