Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content-type based mocks #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

denpolischuk
Copy link

@denpolischuk denpolischuk commented Jan 30, 2020

So I tried to use cypress-autorecord in one of the project I am working on and faced an issue with XHR responses which content-types are different from application/json. If the XHR response data is oversized (isFileOversized) then it is being written to fixtures/<fixture_name>.json and on the next run of tests when they are trying to get data from those mock fixtures the JSON validation error is being thrown.

My solution:

IF content-type == 'application/json'
THEN
    IF isFileOversized
    THEN
        writeDataToFixture('<fixture-name>.json')
    ELSE 
        writeDataToMock('<test-name>.spec.json')
ELSE
    writeDataToFixture('<fixture-name>.<fixture-extantion>')

Currently it handles only text/html and application/json content types. For all other types it adds '.odt' extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant