question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support browser specific protocols (chrome extensions)

See original GitHub issue

Support cy.visit() with protocols other than http/https such as:

  • chrome://
  • chrome-extension://
  • resource://

Most notably, chrome-extension:// will allow users to test the UI of a chrome extension.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:176
  • Comments:53 (11 by maintainers)

github_iconTop GitHub Comments

18reactions
kepicommented, May 2, 2020

I belive there should be way to test extension in real Chrome. Not under web server, not stubbing anything. With doing all this extra work, there is huge space to introduce new bugs and worse - to miss some real bugs.

I didn’t check the source code of Cypress or Chrome so I’m really not sure how it is working under the hood. But isn’t it possible to navigate to chrome:// and chrome-extension:// in exact same way as to http://? Isn’t it only alias to http and working over http protocol?

Btw. I started to play with Cypress only because I need to test extension, I wouldn’t give it a try if it wouldn’t look like it can do this from docs. As other tools are lacking in this area too, it my be great to provide better support for extension authors.

12reactions
Kocalcommented, Aug 24, 2018

My popup is now successfuly tested, thanks you all! 😎

capture d ecran de 2018-08-24 17-26-59

Some tips for people who wants to spec their extension’s views and mocking chrome* API:

  • Build your extension (e.g.: output in dist folder)
  • Run a local server pointing on your dist folder (serve is pretty nice)
  • Update your Cypress configuration:
{
  "baseUrl": "http://localhost:5000"
}
  • Into your spec:
describe('App', () => {
  before(() => {

    // Load your popup
    cy.visit('/popup/popup.html', {

      // If you need to stub `chrome*` API, you should do it there:
      onBeforeLoad(win) {
        win.chrome = win.chrome || {};
        win.chrome.runtime = {
          sendMessage(message, cb) {
            // ...
            cb(some_data);
          },
        };
      },
    });
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Set Chrome policies for users or browsers - Google Support
Specifies whether Chrome browser can use the legacy CORS protocol, which is less secure and strict than Out-Of-Renderer CORS. ... Available on ChromeOS...
Read more >
Extensions quality guidelines FAQ - Chrome Developers
To maintain the quality of the Chrome user experience, we require Chrome extensions to have a single purpose. For an overview of the...
Read more >
Chrome incompatibilities - Mozilla - MDN Web Docs
Extensions built with WebExtension APIs are designed to be compatible with Chrome and Opera extensions. As far as possible, extensions ...
Read more >
Chrome Extension : Custom Protocol? - Stack Overflow
... but it can also be used for supporting fake schemes. Unfortunately, the extension would be quite specific to the user's search settings, ......
Read more >
45 Browser Extensions to Perform Accessibility Testing ...
Accessible Web Helper for Google Chrome is a powerful (and free) Google Chrome extension built to help you test your website's accessibility and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found