Skip to content

The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json') #244

@alankyshum

Description

@alankyshum

Error log

Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json').

As suggested from the error log, foo.responseText was called, but foo.responseType === json.

How to reproduce?

This should happen whenever REQUEST_ASYNC === true && request.readyState === 4

https://github.com/kategengler/ember-cli-code-coverage/blob/046e445b47e4a5da0aa5ea4d27380d9288cbedd0/lib/templates/test-body-footer.html#L22-L29

Reason

https://github.com/kategengler/ember-cli-code-coverage/blob/046e445b47e4a5da0aa5ea4d27380d9288cbedd0/lib/templates/test-body-footer.html#L53-L56

When responseType === 'json', the handleCoverageResponse is still called and xhr.responseText would cause an error, and halt the whole test.

ok 138 Chrome 80.0 - [0 ms] - ember-qunit: Ember.onerror validation: Ember.onerror is functioning properly

Manual stack trace

Function that handles the /write-coverage and sends the data without response property

https://github.com/kategengler/ember-cli-code-coverage/blob/d6e2262923e7caeeb383fb6ccdf7b46e227f5715/lib/attach-middleware.js#L75-L78

Function that creates the data sent as a response

https://github.com/kategengler/ember-cli-code-coverage/blob/d6e2262923e7caeeb383fb6ccdf7b46e227f5715/lib/attach-middleware.js#L57

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions