@tuchuang.space/mock-server
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -38,3 +38,8 @@ const express = require('express') | ||
expressApp.all('*', upload.array('images'), (req, res, next) => { | ||
expressApp.all('*', (req, res, next) => { | ||
res.setHeader('Access-Control-Allow-Origin', '*') | ||
res.setHeader('Access-Control-Allow-Headers', '*') | ||
res.setHeader('Access-Control-Allow-Methods', 'post, get, options') | ||
next() | ||
}, upload.array('images'), (req, res, next) => { | ||
requestsData.push(req) | ||
@@ -41,0 +46,0 @@ res.send(response.body) |
@@ -45,2 +45,12 @@ /* eslint-env jest */ | ||
it('当发起任何请求的时候, 需要返回允许跨域的头', async () => { | ||
// act | ||
const response = await request(app) | ||
.get('/api/v1/images?param=1') | ||
// assert | ||
expect(response.header['access-control-allow-origin']).toEqual('*') | ||
expect(response.header['access-control-allow-headers']).toEqual('*') | ||
expect(response.header['access-control-allow-methods']).toEqual('post, get, options') | ||
}) | ||
describe('搜索 request', () => { | ||
@@ -47,0 +57,0 @@ afterEach(() => { |
@@ -12,3 +12,3 @@ { | ||
"description": "一个 server 模拟工具, 可配置响应, 获取某个请求是否接收到了", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"main": "index.js", | ||
@@ -15,0 +15,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14882
282