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

Add FAQ questions from gitter #25

Closed
10 of 32 tasks
jennifer-shehane opened this issue Sep 6, 2017 · 16 comments
Closed
10 of 32 tasks

Add FAQ questions from gitter #25

jennifer-shehane opened this issue Sep 6, 2017 · 16 comments

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Sep 6, 2017

@jennifer-shehane commented on Tue Aug 08 2017

There are some questions that are asked in the Cypress gitter chat that we'd like to have in a searchable, centralized place - our FAQ.

Please take note of the categories we have in terms of our FAQ:

  • General Questions: Questions someone could ask without ever using Cypress. Maybe they have questions about how it works in general or what we support before diving in.
  • Using Cypress: Questions about how to use Cypress including the API, the Desktop GUI, or running the tests.
  • Dashboard - Questions about our Dashboard service.
  • Company - Questions about Cypress as a company.

Make sure to place it in the correct category. When in doubt, just ask!

The list below is a rough draft. Some questions have rough answers taken from the chat, some have no answers. The questions and answers should be formatted clearly and edited.

Check off any questions from the list after adding it to the examples. Reference the PR to this issue #335.

Questions about Cypress:

  • Is there a way to ignore an exception thrown from my own application or a 3rd party library?
    Read about some of our suggestions for this in our issue here.

  • Could Cypress be used as a replacement for protractor?
    Protractor is essentially a wrapper around Selenium. In most cases Cypress can replace it just fine. There are some limitations to the way Cypress tests are ran (i.e. not via WebDriver, but within the browser under test itself). From my limited experience with Cypress (using it for few weeks now, I'm still evaluating) here are a few things you could test with Selenium (and hence Protractor) but you can't with Cypress:

    • Test in Firefox / IE / Edge.
    • Assert on clipboard contents.
    • Test TAB key (you can write your own .tab() command though, it's just not part of Cypress' API yet)
    • cypress CLI tool doesn't let you to execute a single test, just a single test suite. Not a big deal as you can just use it.only, but would be nice to have (and is offered by many Selenium-based runners)
    • Can't operate native browser dialogs / alerts.
  • can anyone tell me how much the dashboard feature costs?
    We have not released pricing on the Dashboard yet but anticipate it being free for open source projects and having paid plan starting at $99/month

  • Does anyone know if it's possible to write Cypress tests in Typescript?

  • Is there a way to get a project recording link from a successful run/upload?
    I think this is what you're asking for - cypress run --record should print the URL to the cypress.io dashboard cypress#494
    In which case, not right now.

  • Is there any documentation about interacting with saving a file using the system dialog? As soon as the system dialog comes up it just waits forever, never times out.
    You can't do this in Cypress currently. You'll need to bypass the way it normally works. Basically you could simply test the behavior before file prompting, like testing that an anchor has the right href. Or you could use cy.request() to programmatically download the file. You don't really need to test that a browser downloads a file because you would expect this to work. You just need to test the mechanism that would cause your application to prompt for file download and retain 100% coverage.

  • Is there any way can take screenshot with console?
    No, not when running headlessly. The console would have to be open the whole time tests are run, then automatically failed when there are JavaScript errors on the page.

  • How do I make Cypress wait for an XHR request?

  • is there CLI option to run in chrome? Or is electron the only way to run headlessly?

  • How do I make conditional based assertions / control flow?

  • How do I run my tests in another browser?

  • Where do I get the key to run my tests in CI?

  • Can I create more than one key for CI?

  • I have an app that needs to be tested across multiple user sessions, like a chat app across 2 browsers. How do I test that?

  • I want to test clicking a link that navigates, how do I wait and check the resulting location url?

  • Is there a way to watch for an xhr request and assert that the response code came back a certain way?

  • How do I pass data to my webserver from Cypress?

  • How do I test drag-n-drop?

  • How do I wait for an element not to exist?

  • How do I do different things depending on what’s currently in the dom/url/cookies/localstore?

  • Any plans to add "Find React component in DOM" ability, like cy.getReactComponent() or something? (I'd guess you'd want to keep it separate from cy.get())
    you could likely write this as a custom command yourself. Since you have the ability to access window globals, so long as your react application is exposed it should be possible to traverse the trees and access it that way (same as react dev tools essentially)

  • Is it possible to use cypress on .jspa?
    Yes. Cypress works on anything rendered to a browser.

  • Is is possible to catch the promise chain in Cypress?
    No. You cannot add a .catch error handler to a failed command. Read more about how the Cypress commands are not Promises

  • Is there a way to modify the screenshots/video resolution?
    Not at the moment. There is an open issue for this.

  • Can I run cypress on another browser other than Chrome?
    You can read about our currently available browsers here.

  • Does Cypress support ES7?
    Not currently. It uses browserify and babelify with the presets/plugins are hard-coded. There is an open issue for making this configurable.

  • How does one determine what the latest version of Cypress is?
    There are a few ways.

    • The easiest way is probably to check our changelog.
    • You can also check the latest version here.
    • Once we're open source (soon!), we'll have it tagged in the repo too.
  • Is there an ESLint plugin for Cypress or a list of globals?
    describe/it/beforeEach etc globals come from Mocha. So you can use ESLint plugins for Mocha like this one.

  • When I visit my site directly, the certificate is verified, however the browser launched through Cypress is showing it as "Not Secure". Why?
    This is normal. Cypress modifies the traffic between your server and the browser. The browser notices this and displays a certificate warning. However, this is purely cosmetic and does not alter the way your application under test runs in any way, so you can safely ignore this warning.

  • My question is, there's any option to run cypress with devtools open? We want to track network and console issues.
    Yeah, this is definitely the motivation behind Capture + Display all logs for everything that happens in Cypress cypress#448, there is not a way to run cypress headlessly with devtools open. You may try running the tests locally and select the Electron browser, that's as close as you'll get with devtools open to replicating the environment that was run headlessly.

  • Can I test my Electron app?
    Testing your Electron app will not 'just work', as Cypress is designed to test anything that runs in a browser and Electron is a browser + node.

    That being said, we use Cypress to test our own Desktop app's front end - by stubbing events from Electron. Example: https://github.com/cypress-io/cypress-core-desktop-gui/blob/master/cypress/integration/login_spec.coffee

  • So what benefits would one get for converting one's unit tests from Karma or Jest to Cypress?
    Unit tests are not something we are really trying to solve right now. Most of the cy commands are useless in unit tests. The biggest benefit of writing unit tests in Cypress is that they run in a browser, which has debugger support built in.

    We have internally experimented at doing DOM based component unit testing in Cypress - and that has the possibility of being an excellent "sweet spot" for unit tests. You'd get full DOM support, screenshot support, snapshot testing, and you could then use other cy commands (if need be). But as I mentioned this isn't something we're actively pushing, it just remains a thing that's possible if we wanted to go down that route.

    With that said - we actually believe the best form of testing in Cypress is a combination of a "unit test" mixed with an "e2e test". We don't believe in a "hands off" approach. We want you to modify the state of your application, take shortcuts as much as possible (because you have native access to all objects including your app). In other words, we want you to think in unit tests while you write integration tests.


Add example of using request headers to cy.request doc:

cy.request({ url: 'http://xxx', headers: { 'Content-Type': 'application/vnd.api+json' } })
@jennifer-shehane jennifer-shehane changed the title docs: Add FAQ questions from gitter Add FAQ questions from gitter Sep 6, 2017
@brian-mann
Copy link
Member

brian-mann commented Sep 21, 2017

  • can I run cypress headlessly from the command line / terminal?
  • how do I assert on the text in an element
  • how do i wait for an element to be visible / not visibile

@ValerieThoma
Copy link
Contributor

ValerieThoma commented Apr 6, 2018

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented Apr 12, 2018

  • How do I wait for my application to load?

-- In CI, how do I make sure my server has started - npm module that gleb has, use npm wait-on
-- If my page is done loading - Cypress waits for the load event of websites.
-- Lastly, wait for your requests to complete? - cy.route() and cy.wait() - for each resource the view depends on. If you don't wait - the API could respond super slow one time and then your test fails.

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented Apr 12, 2018

  • Is there any way to assert if the <head> tag contains specific content?

-- experiment and figure it out - you can't use 'contains' only looks at body element.
-- cy.request() - literally html page
-- cy.get() ??

#624

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented Apr 12, 2018

  • Is there were a way to make Cypress wait until something is visible in the DOM

-- remind them about the fundamentals - we already do this https://docs.cypress.io/guides/core-concepts/introduction-to-cypress.html#Applying-Timeouts

@jennifer-shehane
Copy link
Member Author

  • Is there a way to test than an iframe has already loaded?

-- I have no idea actually, needs to be tested

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented Apr 18, 2018

@jennifer-shehane
Copy link
Member Author

jennifer-shehane commented May 3, 2018

  • Can Cypress just wait for all of my Ajax request?

  • No.....how could cypress know what your web application needs to wait on to display correctly.

@ValerieThoma
Copy link
Contributor

From main comment. We updated cypress run spec args in docs. Should we still add this to FAQ? Maybe with screenshots? Or just with abbreviated answer, i.e. yes?

Is there a way to get a project recording link from a successful run/upload?
I think this is what you're asking for - cypress-io/cypress#494
In which case, not right now.

  • UPDATE This is available in 3.0.0

We are now capturing the performance and timings data of every test when using --record mode and are beginning to offer the first analytics and insights into the health of your tests on our Dashboard service.

@jennifer-shehane
Copy link
Member Author

Yeah - this can be added to the FAQ for 3.0.0 appropriate response

@ValerieThoma
Copy link
Contributor

ValerieThoma commented Jun 14, 2018

  • "Can I use global hooks to log Cypress events?"

I think this is an FAQ question too: @jennifer-shehane / @ValerieThoma if it's not, it should be, possibly a recipe as well.

cypress-io/cypress#1949 (comment)
(🙄I'm so useless, I can't figure out how to link issues from another repo)

  • edit cheers guys!

@jennifer-shehane
Copy link
Member Author

You just past the link from the other repo directly. I think there may be some kind of shortcut if it's in the same org, but I don't know it.

@brian-mann
Copy link
Member

For the same org you just type # and it will autocomplete. For everything else you just paste the URL as @jennifer-shehane said.

@gautejohan
Copy link

Hi, I don't know if this is the right place, but is it possible to get a better description of which events that needs to be stubbed to get it to work?

Thanks for an awesome testing tool!

@jennifer-shehane
Copy link
Member Author

Hey @gautejohan, I'm not sure what you are asking. What events? To get what to work exactly?

Also, I'd recommend asking questions relating to how to use Cypress be asked in our community chat. ☺️

jennifer-shehane pushed a commit that referenced this issue Jul 11, 2019
error-messages.md translated into Chinese completed.
@kavitha24

This comment has been minimized.

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

No branches or pull requests

5 participants