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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug: test links in the browser reporter keep the original fgrep and invert params #5102

Open
3 of 4 tasks
danny0838 opened this issue Feb 27, 2024 · 1 comment
Open
3 of 4 tasks
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer

Comments

@danny0838
Copy link

Bug Report Checklist

  • I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
  • I have searched for related issues and issues with the faq label, but none matched my issue.
  • I have '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, my usage of Mocha, or Mocha itself.
  • I want to provide a PR to resolve this

Expected

A link of the browser reporter should remove fgrep and invert parameters in the original URL.

Actual

A link of the browser reporter keeps the original fgrep and invert parameters in the original URL.

Minimal, Reproducible Example

  1. Create a test page like:
<!DOCTYPE html>
<meta charset="UTF-8">
<link rel="stylesheet" href="mocha.css">
<div id="mocha"></div>
<script src="mocha.js"></script>
<script>
mocha.setup('bdd');

describe('tests', function () {
  it('test1', function () {});
  it('test2', function () {});
});

mocha.run();
</script>
  1. Open the page in the browser.

  2. Append ?fgrep=tests in the address and visit it.

  3. Wait for the test to complete, and click the replay link of test1.

Versions

mocha@10.3.0 in javascript ES2018

Additional Info

No response

@danny0838 danny0838 added status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer labels Feb 27, 2024
@danny0838
Copy link
Author

This issue should be able to be fixed by replacing this line:

search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');

with:

search = search.replace(/[?&](?:f?grep|invert)=[^&\s]*/g, '').replace(/^&/, '?');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in triage a maintainer should (re-)triage (review) this issue type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

1 participant