Giter VIP home page Giter VIP logo

cypressautomocker's People

Contributors

abdallatif avatar apolatnick avatar jennifer-shehane avatar marekjavurek avatar nicholasboll avatar scottschafer avatar timjohnson-valtech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cypressautomocker's Issues

Clarification about the web hooks

Step: "Add the cypress web hooks to your application."
Where exactly do those lines go? Into the application itself? Or somewhere in cypress. Is there any other way to do it? I am testing a web app that is already deployed to a server, so I can't change any of the application files themselves

Queries not being recorded on POST requests

The query is blank for these for me:
{
"method": "POST",
"path": "",
"query": "",
"request": "",
"response": "",
"status": 402,
"statusText": "Payment Required",
"contentType": "text/html; charset=utf-8"
},

This is preventing the failing query case and successful query case from working correect.

addEventListener is missing in XHRRequest mock

We were trying to use it in ng6 app test
But got error regarding missing addEventListener method

i was able to fix it using

addEventListener: function(callback) {
        this.object.addEventListener(callback);
    }

Stubbed request aborted

I have a request in my application that it is correctly being writen to its mockup but after running the test it always gets aborted.

Here is an example of the mocked call

{
      "url": "http://localhost:4200/translate/translate/invoices-payments/en_US",
      "method": "GET",
      "status": 200,
      "body": null,
      "response": {
        "views.document_center.reference_searcher.select_reference_type": "Reference Type",
        "views.lien_release.message_confirmation_description1": "Massive Request submitted"
      }
}

Everything looks ok, but I don't know why the XHR stub gets aborted. Any ideas?

MOCKING ON, but letting this fall through

Mocking seems to work for most of my calls but some are saying MOCKING ON, but letting this fall through. Why is that? Seems to happen to calls that it does a lot of to the same endpoint but different querystring.
The endpoints are recorded and saved as json.

What method of testing are you using now?

You mention on the README that:

we are using a different approach to testing now and so keeping this updated is not a top priority for me.

What method are you using now?

TypeScript

Looks very promising, but I couldn't get it to work under TypeScript.
My specs as well as my commands are written in TypeScript and when I try to import the "cypressautomocker/include-in-tests" it doesn't work:

  • After setting the tsconfig noImplicitAny to false it doesn't give me a compilation error no more
  • But as soon as I try to run a test I get this error (inside of cypress): Uncaught TypeError: include_in_tests_1.default is not a function...

Would be great if someone has figured out how to use cypressautomocker alongside TypeScript.
Thanks in advance for all hints!

AlertMedia AutoMock repo

Hi,

I'm working for AlertMedia and we are making some improvements on the automocker and such (https://github.com/alertmedia/cypress-auto-mock). We were wondering if you were open to having us merge our changes to your branch so we can help maintain it. Our changeset deviates quite a bit, so we'll likely need to refactor to get it working wit yours.

A couple of bugs fix and changes are:

  • Add responseHeaders to the code (so we can use HEAD request)
  • Added params for GET and HEAD request as a way to match keys
  • Add more verbose logging
  • We added functions at the global level so on our App can add stuff to the apiMockLists and such. (We integrate the ability t mock cy.request)
  • Fix some bugs
  • Update some tests

Let us know what your thoughts are. We are heavily invested in automock so we want to make sure that we can help maintain in any way possible.

Joeny

Test fails when I add cypressautomocker

Hey thanks for the lib! I was able to get it to work in 1 test. But another test passed before and is now failing. Now I get this error and it never finishes:

image

This is after adding

const MOCK_FILENAME = 'bookTripSpecRecording'

  before(() => {
    cy.automock(MOCK_FILENAME);
  })

  after(() => {
    cy.automockEnd()
  })

The test that fails is an, "expected id of element to contain 'text' kind of assertion.

I'm not sure if it times out in my test or in waiting for automock to complete - any ideas? Thanks!

Request and response objects are empty in mock files

Situation:

We've got a create-react-app where we are using the Fetch API extensively. Now we know Cypress doesn't understand the Fetch API just yet so we do the following in support/commands.js:

beforeEach(function() {
  // If we remove window.fetch(), the polyfill will revert to XHR.
  // Cypress only supports XHR stubbing, so this is a needed evil polyfill trigger
  Cypress.on('window:before:load', win => {
    win.fetch = null;
  });

So far so good and this actually works while testing the app. The responses are coming in and tests pass based on those responses. However, the responses and requests are not saved in the automock files.

This is an example file of the automock we're getting:

[
  {
    "method": "GET",
    "path": "/api/user/preferences/something",
    "query": "",
    "request": "",
    "response": {},
    "status": 200,
    "statusText": "OK",
    "contentType": "application/json;charset=UTF-8"
  },
]

I'm happy to help and I'll investigate on my own as well, but any pointers on why this would break are more than welcome. We're very close to adopting Cypress in our projects, but the auto-mocking library really makes or breaks the DX for us.

What I've already tried:

  • Removing all polyfills from the application. We are using polyfill.io to automatically polyfill a bunch of things, but even removing that completely does not help.
  • Checked the network panel in the web inspector while running Cypress. API calls are coming in just fine, response data looks great.
  • Checked the console, it does say it's RECORDING when I remove the mockfiles and MOCKING when I run those tests again.

Research findings:
In autoMockCommands.js on line 178 and 181, the objects are empty. The XHR object itself does contain the responses and requests, but, it is a Blob. It silently errors in the following block:

                try {
                  responseObject = JSON.parse(responseObject);
                  console.log({ responseObject });
                } catch (e) {
                  console.log(e);
                  debugger;
                }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.