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

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

Closed
4 tasks done
danny0838 opened this issue Feb 27, 2024 · 1 comment · Fixed by #5224
Closed
4 tasks done
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer

Comments

@danny0838
Copy link
Contributor

danny0838 commented Feb 27, 2024

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
Contributor 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(/^&/, '?');

@JoshuaKGoldberg JoshuaKGoldberg added status: accepting prs Mocha can use your help with this one! and removed status: in triage a maintainer should (re-)triage (review) this issue labels Jul 2, 2024
danny0838 added a commit to danny0838/mocha that referenced this issue Oct 12, 2024
- `grep` may not work as expected if a previous `fgrep` or `invert` parameter exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants