mocha
mocha copied to clipboard
mocha.growl() should be aware of the file: protocol and not bother as you are always asked for permission and never get any notifications.
Prerequisites
- [X] Checked that your issue hasn't already been filed by cross-referencing issues with the
faq
label - [X] Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
- [X] 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- [X] Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
mocha.growl() shouldn't bother if running from the file: protocol as it just keeps asking the user for permission in some browsers.
Steps to Reproduce
- Create a browser based mocha test page and add mocha.growl() to it.
- Open the page in Chrome from the file: protocol instead of through a web server.
- When you run the page you will be asked to give permission for notifications.
- Select to allow notifications.
- You will not be shown a notification when the tests finish.
- When you reload the page you will be asked again for permission to allow notifications.
- Even if you click the replay for specific tests you will be asked to allow notifications.
- (Tested in Google Chrome. Firefox itself ignores the notification request on file: protocol pages.)
Expected behavior: [What you expect to happen]
Suggest the mocha.growl function detect the file: protocol and ignores in that case so it doesn't keep asking the user to give permission but not perform the notification.
Actual behavior: [What actually happens] User is asked every time the page refreshes or a test is replayed
Reproduces how often: [What percentage of the time does it reproduce?] Always
Versions
mocha 8.3.2 Version 88.0.4324.150 (Official Build) unknown (64-bit)
Additional Information
I put this in my startup code to get around it. if (document && document.location && document.location.protocol !== 'file:') { mocha.growl(); }