diff --git a/src/platform/web/lib/transport/fetchrequest.ts b/src/platform/web/lib/transport/fetchrequest.ts index 0b80921fcf..f6c1b3c79b 100644 --- a/src/platform/web/lib/transport/fetchrequest.ts +++ b/src/platform/web/lib/transport/fetchrequest.ts @@ -38,6 +38,8 @@ export default function fetchRequest( rest ? rest.options.timeouts.httpRequestTimeout : Defaults.TIMEOUTS.httpRequestTimeout ); + console.log({ uri, _method, headers, body }); + fetch(uri + '?' + new URLSearchParams(params || {}), { method: _method, headers: fetchHeaders, @@ -47,6 +49,8 @@ export default function fetchRequest( .then((res) => { clearTimeout(timeout); const contentType = res.headers.get('Content-Type'); + console.log(`Request to ${uri + '?' + new URLSearchParams(params || {})}`); + console.log(`Response status: ${res.status} with Content-Type: ${contentType}`); if (!res.ok) { if (!contentType) { // TODO @@ -55,6 +59,8 @@ export default function fetchRequest( } if (contentType && contentType.indexOf('application/json') > -1) { res.json().then((body) => { + console.log('here'); + console.log(body); const err = getAblyError(body, res.headers) || new ErrorInfo( @@ -75,10 +81,23 @@ export default function fetchRequest( return; } if (contentType.indexOf('application/json') > -1) { - res.json().then((body) => { + res.text().then((text) => { + console.log({ text }); + const body = JSON.parse(text); callback(null, body, res.headers, true, res.status); - return; }); + // res + // .json() + // .then((body) => { + // callback(null, body, res.headers, true, res.status); + // return; + // }) + // .catch((err) => { + // console.log(err); + // res.text().then((body) => { + // console.log(body); + // }); + // }); } if (contentType.indexOf('application/x-msgpack') > -1) { res.arrayBuffer().then((body) => { diff --git a/test/rest/push.test.js b/test/rest/push.test.js index 6b782e4dfe..de18d628c8 100644 --- a/test/rest/push.test.js +++ b/test/rest/push.test.js @@ -30,7 +30,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async }, }; - describe('rest/push', function () { + describe.only('rest/push', function () { this.timeout(60 * 1000); before(function (done) { @@ -39,7 +39,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async }); }); - it('Get subscriptions', function (done) { + it.only('Get subscriptions', function (done) { var subscribes = []; var deletes = []; var subsByChannel = {}; diff --git a/test/support/runPlaywrightTests.js b/test/support/runPlaywrightTests.js index 030cded919..7b24eaa10c 100644 --- a/test/support/runPlaywrightTests.js +++ b/test/support/runPlaywrightTests.js @@ -28,6 +28,10 @@ const runTests = async (browserType) => { console.log(detail); }); + page.on('console', (msg) => { + console.log(msg.text()); + }); + // Expose a function inside the playwright browser to exit with the right status code when tests pass/fail page.exposeFunction('onTestResult', ({ detail }) => { console.log(`${browserType.name()} tests complete: ${detail.passes}/${detail.total} passed`);