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

HTML Reporter for angular (karma) always runs all specs #1906

Closed
jlpstolwijk opened this issue Apr 16, 2021 · 3 comments
Closed

HTML Reporter for angular (karma) always runs all specs #1906

jlpstolwijk opened this issue Apr 16, 2021 · 3 comments

Comments

@jlpstolwijk
Copy link

jlpstolwijk commented Apr 16, 2021

Expected Behavior

When clicking a spec in the html report, only that spec should be run.
(Using karma-jasmine-html-reporter, but issue should be fixed in jasmine itself, see below).

Current Behavior

When clicking a spec in the html report, the full page reloads, running all specs again. Both in regular report and in debug mode.

This seems to be caused by the combination of 2 things:

  1. the href of the specs have only a query string, without url path, e.g. <a title="should be created" href="?spec=ConfirmService%20should%20be%20created">should be created</a>
  2. both the context.html and the debug.html page have <base href="/"> in the header. The angular team apparently added this in response to this issue.

See also this issue, filed on karma repo (also not picked up there, because it belongs to jasmine), and this one on karma-jasmine repo.

Possible Solution

I'm working on a PR, which I will link to this issue. This involves adding the url pathname + query string to the href of the spec, instead of only adding the query string.
This solution was inspired by this issue + PR on karma-jasmine-html-reporter, which was rejected because that repo basically copies its code from jasmine. I hope the current PR can be incorporated in jasmine and then copied to karma-jasmine-html-reporter.

Suite that reproduces the behavior (for bugs)

npm install -g @angular/cli
ng new test-app
cd test-app
ng test

Then click on a single spec
=> notice that page reloads, and all specs are run again.
Same issue happens in debug mode.

Your Environment

  • Environment name and version: Chrome 90.0.4430.72 (Official Build) (64-bit), Node: 14.16.1
  • Operating System and version (desktop or mobile): Windows 10 desktop, x64
  • Packages:
   "@angular-devkit/build-angular": "^0.1102.9",
   "@angular/cli": "^11.2.9",
   "@angular/compiler-cli": "^11.2.10",
   "jasmine-core": "^3.7.1",
   "jasmine-spec-reporter": "^7.0.0",
   "karma": "^6.3.2",
   "karma-chrome-launcher": "^3.1.0",
   "karma-cli": "^2.0.0",
   "karma-jasmine": "^4.0.1",
   "karma-jasmine-html-reporter": "^1.5.4",

jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Apr 16, 2021
jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 3, 2021
jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 3, 2021
jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 3, 2021
jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 14, 2021
sgravrock added a commit that referenced this issue Jun 28, 2021
… comment + test"

Reverted because it breaks the option checkboxes in the HTML reporter, both
in the standalone distribution and in jasmine-browser-runner.

Reopens #1906.

This reverts commit 1e4f0d1.
@sgravrock
Copy link
Member

@jlpstolwijk Sorry, but I reverted your fix for this because it breaks the functionality of the options checkboxes (accessed via the options button in the top right corner). If you'd like to submit another fix for the Karma issue that doesn't break existing functionality, I'd be happy to review it.

@sgravrock sgravrock reopened this Jun 28, 2021
@jlpstolwijk
Copy link
Author

ah too bad, sorry about that! I'll have a look

jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 29, 2021
jlpstolwijk pushed a commit to jlpstolwijk/jasmine that referenced this issue Jun 29, 2021
@jlpstolwijk
Copy link
Author

I've create a new PR that doesn't break existing functionality, as far as I can see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants