You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the matcher is not working, here is my config
export default [
{
/**
* regular expression of URL
*/
pattern: process.env.REACT_APP_API_ENDPOINT,
/**
* returns the data
*
* @param match array Result of the resolution of the regular expression
* @param params object sent by 'send' function
* @param headers object set by 'set' function
* @param context object the context of running the fixtures function
*/
fixtures: function(match, params, headers, context) {
if (/\/events\/[\d|\w]+$/.test(match[1])) {
return {
title: "Test"
}
}
},
/**
* returns the result of the GET request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
get: function(match, data) {
return {
body: data
}
},
/**
* returns the result of the POST request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
post: function(match, data) {
return {
status: 201
}
}
}
]
The node env is equal to
https://example.com/api
I'm using a server setup like so
import request from "superagent"
import su from "superagent-use"
import prefix from "superagent-prefix"
import config from "../config/superagent-mock"
import superagentMock from "superagent-mock"
const agent = su(request)
agent.use(prefix(process.env.REACT_APP_API_ENDPOINT))
const logger = function(log) {
console.log("superagent call", log)
}
export const setupMockServer = () => {
return superagentMock(agent, config, logger)
}
And then I later in the code I'm testing make a request like so
It seems the matcher is not working, here is my config
The node env is equal to
https://example.com/api
I'm using a server setup like so
And then I later in the code I'm testing make a request like so
API
here is a reference to a different file that the whole app usesAn example full URL might be
https://example.com/api/events/1234
When I log out the
match
argument I see this in myjest
terminal outputIt seems the implementation suggested in the config is not working
The text was updated successfully, but these errors were encountered: