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

Error formatting misleads when URL ends base/ #2209

Closed
mthx opened this issue Jun 27, 2016 · 4 comments · Fixed by #2499 or karronoli/redpen#10 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132
Closed

Error formatting misleads when URL ends base/ #2209

mthx opened this issue Jun 27, 2016 · 4 comments · Fixed by #2499 or karronoli/redpen#10 · May be fixed by Omrisnyk/npm-lockfiles#122 or Omrisnyk/npm-lockfiles#132

Comments

@mthx
Copy link

mthx commented Jun 27, 2016

Actual behavior

I had a test that ultimately boiled down to the following Jasmine expectation:

expect('http://www.google.com/base/').toEqual('http://www.example.com/base/');

As the failure message, I get:

Expected '' to equal ''

This was quite puzzling and a pain to isolate to karma in my real scenario.

Expected behavior

Clear message as given by Jasmine directly:

Expected 'http://www.google.com/base/' to equal 'http://www.example.com/base/'.

I think this issue relates to the URL_REGEXP in Karma's reporter.js but I haven't dived deep enough to follow what's going on there.

Environment Details

  • Karma version (output of karma --version):

Karma version: 1.1.0

  • Relevant part of your karma.config.js file

Minimal jasmine config.

Steps to reproduce the behaviour

  1. Checkout https://github.com/mthx/karma-error-reporting-issue
  2. npm install
  3. npm run test-jasmine
  4. npm run test-karma
  5. Note the failures from the latter have empty strings as URLs in the error message
@wesleycho
Copy link
Member

wesleycho commented Dec 6, 2016

What is happening here is that karma is truncating the strings before base/

@wesleycho
Copy link
Member

@dignifiedquire what are your thoughts on perhaps making a breaking change to choose a unique name for the base url, such as karma-base/? It would be much less likely to conflict than a common name like base is alone.

@dignifiedquire
Copy link
Member

If we are switching we should be switching to something more specific, like__karma__base__/. But to fix this issue we should be able to adjust the matcher, such that it only replaces inside urls where the host is the same as config.hostname.

@wesleycho
Copy link
Member

wesleycho commented Dec 11, 2016

So maybe a configurable option like config.basename would work?

Edit: oh, I think I misunderstood - basically fix the regex. I think I read this at 6 am and misread it.

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