Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Last active September 22, 2021 09:48
Show Gist options
  • Save sabesansathananthan/b898ab53afdfecd341cac27ccfaef675 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/b898ab53afdfecd341cac27ccfaef675 to your computer and use it in GitHub Desktop.
mock network request in Jest
import { DataMapper } from "../../src";
const data: DataMapper = {
"/api/setCounter": [
{
request: {
method: "POST",
data: '{"id":1,"operate":1}',
},
response: {
status: 200,
json: {
result: 0,
},
},
},
{
request: {
method: "POST",
data: /"id":2,"operate":-1/,
},
response: {
status: 200,
json: {
result: -100,
},
},
},
],
};
export default data;
import { DataMapper } from "../../src";
const data: DataMapper = {
"/api/setCounter": [
{
request: {
method: "POST",
data: /"id":3,"operate":-1/,
},
response: {
status: 200,
json: {
result: -100,
},
},
},
],
};
export default data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment