eykrehbein / strest

⚡️ CI-ready tests for REST APIs configured in YAML
MIT License
1.74k stars 59 forks source link

Postman to stREST #88

Open jgroom33 opened 6 years ago

jgroom33 commented 6 years ago

strest foo.postman.json --postman

This would convert a postman collection into a set of directories and files.

There's no reasonable way to convert all the functionality (javascripts) so this should focus on creating the requests only.

jgroom33 commented 6 years ago

@eykrehbein help on this would be appreciated: https://github.com/eykrehbein/strest/blob/feature/postman_import/src/postman.ts#L80

to test: node dist/main.js tests/postman/Postman\ Import.postman_collection.json -m

eykrehbein commented 6 years ago

I'm on it 👍 @jgroom33

eykrehbein commented 6 years ago

@jgroom33 is the param of .to.have.jsonBody an object?

jgroom33 commented 6 years ago

Looks like the .to.have.jsonBody can test whether the param exists and whether it is equal to a value. I'm assuming we could only currently support:

validate:
  jsonpath:
    args.foo2: bar2

curl https://postman-echo.com/get?foo1=bar1&foo2=bar2 returns:

{
    "args": {
        "foo1": "bar1",
        "foo2": "bar2"
    },
    "headers": {
        "x-forwarded-proto": "https",
        "host": "postman-echo.com",
        "accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "cookie": "sails.sid=s%3ApXoOiKY5-aoRZBuqlwdN0MJ2krjLjx21.c8qegiylITH2DQ9vyj%2BFMe74GEDtC%2BVmi1Y1TxO4fDQ",
        "user-agent": "PostmanRuntime/7.3.0",
        "x-forwarded-port": "443"
    },
    "url": "https://postman-echo.com/get?foo1=bar1&foo2=bar2"
}

tests:

pm.test("response body has json with request queries", function () {
    pm.response.to.have.jsonBody('args')
        .and.have.jsonBody('args.foo2', 'bar2')
    pm.response.to.have.jsonBody('args.foo1', 'bar1');
    pm.response.to.have.jsonBody('headers')
});