-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add jsonp middleware for mock #8
base: master
Are you sure you want to change the base?
Conversation
应该也要能从 package.json 的 spm.server.jsonp 中获取配置,这样多人协作的时候就不需要每个人都加 |
@sorrycc 好 我补充下 |
@@ -36,6 +37,10 @@ function Server(compiler, opts) { | |||
|
|||
var app = this.app = koa(); | |||
|
|||
// support jsonp | |||
if(opts.jsonp || opts.pkg.spm.jsonp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放在 server 里? 另外,opts.pkg.spm.jsonp 要做兼容,pkg 和 spm 都有可能不存在。
request(app.listen()) | ||
.get('/x.json') | ||
.expect(function(res){ | ||
if(res.text.should.be.eql('{\n "hello": "world"\n}\n') === 0) throw new Error('Can not get right json content'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
res.text.should.be.eql(...)
不就行了么,不用自己抛出异常吧?
能否说明下这个的场景,为什么不是默认支持? |
feat: add jsonp middleware for mock