ftmocks-utils 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +7 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ftmocks-utils",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "Util functions for FtMocks",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -216,26 +216,16 @@ async function initiatePlaywrightRoutes (page, ftmocksConifg, testName) {
216
216
  let mockData = getMatchingMockData({testMockData, defaultMockData, url, options, testConfig: ftmocksConifg, testName});
217
217
  if (mockData) {
218
218
  console.debug('mocked', url, options);
219
- } else {
220
- console.debug('missing mock data', url, options);
221
- return route.fulfill({
222
- status: 404,
223
- headers: new Map([['content-type', 'application/json']]),
224
- json: () => Promise.resolve({ error: 'Mock data not found' }),
225
- });
226
- }
227
-
228
- const { content, headers, status } = mockData.response;
229
-
230
- const json = {
231
- status,
232
- headers,
233
- json: () => Promise.resolve(JSON.parse(content)),
234
- };
219
+ const { content, headers, status } = mockData.response;
220
+ const json = {
221
+ status,
222
+ headers,
223
+ body: content,
224
+ };
235
225
 
236
- if(json) {
237
226
  await route.fulfill(json);
238
227
  } else {
228
+ console.debug('missing mock data', url, options);
239
229
  await route.fallback();
240
230
  }
241
231
  });