Replies: 3 comments 2 replies
-
great I like it, just can´t forget the this is the way I use nock in nodejs nock("http://localhost:4444/").get("/123/oauth2/v2.0/token").reply(200,
(uri, reqBody: any, cb) => {
expect("grant_type=client_credentials&client_id=12345&client_secret=mock&scope=123").toEqual(reqBody);
cb(null, {"access_token": "mock-token"});
}); then cb is a callback I will return after the expect it will return wdyt? |
Beta Was this translation helpful? Give feedback.
-
sharing what's on my local machine and I'm not working on it anymore (for now), it didn't make sense to be in a branch so I'm putting it here framework: (ns moclojer.framework
(:require [io.pedestal.http :as http]
[io.pedestal.test :refer [response-for]]
[moclojer.router :as router]))
(defn service-start!
"starts the service"
[endpoints]
(-> {::http/routes (router/smart-router {::router/config endpoints})}
http/default-interceptors
http/dev-interceptors
http/create-servlet
::http/service-fn))
(comment
(let [service-fn (service-start!
[{:endpoint {:method "GET"
:path "/hello/:username"
:response {:status 200
:headers {:Content-Type "application/json"}
:body {:hello "{{path-params.username}}!"}}}}])]
(-> service-fn
(response-for :get "/hello/world")
:body))) test: (ns moclojer.specs.moclojer-test
(:require [clojure.test :refer [deftest is]]
[moclojer.specs.moclojer :as moclojer]))
(def external-body
{:path "test/moclojer/resources/external-body-{{ path-params.name }}.yml"
:provider "json"})
(def request
{:path-params {:name "json"}})
(deftest render-template-test
(let [template "Hello, {{ path-params.name }}!"]
(is (= (moclojer/render-template template request)
"Hello, json!"))))
(deftest enrich-external-body-test
(is (= (moclojer/enrich-external-body external-body request)
{:path "test/moclojer/resources/external-body-json.yml"
:provider "json"})))
(deftest build-body-test
(let [response {:external-body external-body}]
(is (= (moclojer/build-body response request)
(slurp "test/moclojer/resources/external-body-json.yml"))))) |
Beta Was this translation helpful? Give feedback.
-
First Clojure version released v0.3.0, documentation here. Now we need to support ClojureScript, can @matheusfrancisco work on the implementation? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Using the same Clojure code base, support moclojer as a library, making it possible to import moclojer into JavaScript (transposed from ClojureScript).
Mock Service Worker is an API mocking library that allows you to write client-agnostic mocks and reuse them across any frameworks, tools, and environments.
References:
Clojure syntax
service-start!
: imported moclojer server, receives anarray
of endpoints as a parameteryaml
,edn
andopenapi
file reading functions) orarray
(written directly)JavaScript syntax
Beta Was this translation helpful? Give feedback.
All reactions