refactor: change mock files to commonjs (#3246)

This commit is contained in:
花裤衩
2020-06-11 11:40:53 +08:00
committed by GitHub
parent 0bf61aac53
commit d3bd933a8e
9 changed files with 74 additions and 25 deletions

View File

@@ -8,7 +8,7 @@ const mockDir = path.join(process.cwd(), 'mock')
function registerRoutes(app) {
let mockLastIndex
const { default: mocks } = require('./index.js')
const { mocks } = require('./index.js')
const mocksForServer = mocks.map(route => {
return responseFake(route.url, route.type, route.response)
})
@@ -44,9 +44,6 @@ const responseFake = (url, type, respond) => {
}
module.exports = app => {
// es6 polyfill
require('@babel/register')
// parse app.body
// https://expressjs.com/en/4x/api.html#req.body
app.use(bodyParser.json())