From cc22041d5e196124be38a7aaa139ad275b541707 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 27 May 2020 15:57:47 -0400 Subject: [PATCH] Fix issue with coverage report. Unfortunately, this codepath is not under test and the changes from a prior PR left it in an invalid state. * The REQUEST_ASYNC variable was no longer present, and therefore referencing it threw an error * The guard around `xhr.responseText` was no longer needed (we only ever get `JSON`, and `xhr.response` is already parsed properly for us) We ultimately need to refactor to get this coverage reporting under test (plausibly an end-to-end acceptance test that confirms the expected JSON reporter output after running all the tests). --- lib/templates/test-body-footer.html | 9 +-------- test/unit/index-test.js | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 39b8c7f3..d9c61631 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -12,7 +12,7 @@ var data = JSON.stringify(coverageData || {}); var request = new XMLHttpRequest(); - request.open('POST', '/write-coverage', REQUEST_ASYNC); + request.open('POST', '/write-coverage'); request.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); request.responseType = 'json'; request.send(data); @@ -43,13 +43,6 @@ function handleCoverageResponse(xhr, callback) { var data = xhr.response; - // avoid InvalidStateError by incorrectly accessing xhr.responseText property - if (!data && (xhr.responseType === '' || xhr.responseType === 'text')) { - data = xhr.responseText; - } else { - throw new Error(`ember-cli-code-coverage: invalid data ${JSON.stringify(data)} received for responseType ${xhr.responseType}`); - } - if (!data) { return; } diff --git a/test/unit/index-test.js b/test/unit/index-test.js index 1f5c61d9..1c125069 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -59,7 +59,7 @@ describe('index.js', function() { }); it('includes the project name in the template for test-body-footer', function() { - expect(Index.contentFor('test-body-footer')).to.match(/`["some/module", "some/other/module"`]/); + expect(Index.contentFor('test-body-footer')).to.include(`["some/module","some/other/module"]`); }); }); }); @@ -544,4 +544,4 @@ describe('index.js', function() { }); -}); \ No newline at end of file +});