percy/percy-cypress

Can't use assets via cypress `fileServerFolder`

cassus opened this issue · 2 comments

I link to a local CSS file served via cypress fileServerFolder. This is with experimentalComponentTesting. The CSS works well for cypress native screenshots but is missing from percy screenshots.

cypress.json:

{ "experimentalComponentTesting": true, "fileServerFolder": "cypress/dist" }

in the page head I have

<link id="tailWindImport" href="/tailwind.css" rel="stylesheet" type="text/css">

Percy log about discovering and saving this file

[percy] processing response: http://localhost:55639/tailwind.css for width: 1280 | Fri Mar 05 2021 20:49:20 GMT+0100 (Central European Standard Time)
[percy] Making local copy of redirected response: http://localhost:55639/tailwind.css | Fri Mar 05 2021 20:49:20 GMT+0100 (Central European Standard Time)
[percy] Skipping file copy [already_copied]: http://localhost:55639/tailwind.css | Fri Mar 05 2021 20:49:20 GMT+0100 (Central European Standard Time)
[percy] creating resource | Fri Mar 05 2021 20:49:20 GMT+0100 (Central European Standard Time)
[percy] -> response: http://localhost:55639/tailwind.css
[percy] -> copyFilePath: /var/folders/j7/8gfplftj3_31nr39skx3y3nr0000gn/T/bbc00db16f1449d1d28092c547877bebe48824689ac96acd6d8ba6e8387deed1
[percy] -> resourceUrl: http://localhost:55639/tailwind.css
[percy] -> localPath: /var/folders/j7/8gfplftj3_31nr39skx3y3nr0000gn/T/bbc00db16f1449d1d28092c547877bebe48824689ac96acd6d8ba6e8387deed1
[percy] -> sha: bbc00db16f1449d1d28092c547877bebe48824689ac96acd6d8ba6e8387deed1
[percy] -> contentType: text/html; charset=utf-8
[percy] -> assetDiscoveryService.browser.newPage

Oh no, it's a redirect and text/html! Somethings not right! Let's look into the file it cached!

/var/folders/j7/8gfplftj3_31nr39skx3y3nr0000gn/T/bbc00db16f1449d1d28092c547877bebe48824689ac96acd6d8ba6e8387deed1:

<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cypress</title>

    <link href="/__cypress/static/favicon.ico" rel="icon">

    <link rel="stylesheet" href="/__cypress/runner/cypress_runner.css">
  </head>
  <body>
    <div id="app">
      <div class="runner automation-failure">
        <div class="automation-message">
          <p>Whoops, we can't run your tests.</p>
          <div>
            <p class="muted">This browser was not launched through Cypress. Tests cannot run.</p>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

Related: cypress-io/cypress#15349

Hey @cassus thanks for the report! Unfortunately it looks like this isn't something that we can fix or do anything about (unless there's a way to authenticate our requests with Cypress).

With that, I'm going to close since we can't action on this. But I'll be watching the linked issue for updates 👍🏼

Just ran into this - may I suggest noting this caveat somewhere in Percy docs for Cypress integration?

Thanks a lot to everyone working on Percy