MSW expects parentheses to be escaped in URLs but pretender does not. This prevents mirage-msw being a drop in replacement. Currently in my mirage setup I'm using a helper function to escape URL strings that contain parentheses if the test suite is running using mirage-msw. Migrating large number on mirage endpoint, small PR by small PR so need to support both MSW and pretender while migrating.
export default function mswEscapeUrl(stringUrl) {
if (ENV.useMsw) {
return stringUrl.replaceAll('(', '\\(').replaceAll(')', '\\)');
}
return stringUrl;
}
Here's the MSW test and mock showing this behaviour