Code Monkey home page Code Monkey logo

Comments (5)

fengmk2 avatar fengmk2 commented on May 18, 2024

下面的那个是方便开发者直接查看一个html页面请求所使用的数据全貌

Sent from my iPhone

On Nov 21, 2014, at 11:03 AM, hui [email protected] wrote:

if (!view) {
return this.body = data;
}
if (IS_JSON_RE.test(this.path)) {
return this.body = data;
}
就是有点疑问, 如果我需要mock的是一个 json, 那么我准备的 mock 数据理论上就不应该有 __view. 那么直接在第一个判断就返回了.

如果我请求的 user.json 是一个页面, 那么就算我准备了一个__view 那么还是会渲染成 json.

那什么情况下, 我请求一个 json 的 mock, 我还会提供一个__view呢?


Reply to this email directly or view it on GitHub.

from mock.

leoner avatar leoner commented on May 18, 2024

比如呢? 请求类似那个 url呢?

from mock.

leoner avatar leoner commented on May 18, 2024

是这个场景?

it('should render with logined data', function (done) {
      request(app.listen())
      .get('/home?__scene=logined')
      .expect('\n欢迎回来, 苏千\n\n', done);
});

it('should show json logined data', function (done) {
    request(app.listen())
    .get('/home.json?__scene=logined')
    .expect({
        name: '苏千',
        logined: true,
        __view: 'home.html'
    }, done);
});

from mock.

fengmk2 avatar fengmk2 commented on May 18, 2024

是的,就是这种 html 页面的场景

from mock.

leoner avatar leoner commented on May 18, 2024

好, 通过这种方式也行, 我原来想法是把这个 json 展现可以独立出来一个单独的功能, 因为有些情况下我是想看这个页面真实的 json 数据, 并不是 mock 的. 毕竟 mock 的数据大部分自己都很清楚(不过存在数据合并的话,是个例外)

from mock.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.