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

Regression in v2.0.8 using webpack file-loader #284

Closed
gdetrez opened this issue Dec 14, 2017 · 10 comments · Fixed by #285 or JetBrains/ring-ui#42
Closed

Regression in v2.0.8 using webpack file-loader #284

gdetrez opened this issue Dec 14, 2017 · 10 comments · Fixed by #285 or JetBrains/ring-ui#42

Comments

@gdetrez
Copy link

gdetrez commented Dec 14, 2017

I'm submitting a bug report

Webpack version: 3.10.0

Webpack Karma version: 2.0.8

Karma version: 1.7.1

Please tell us about your environment: Linux

Browser: Chrome

Current behavior:
I have tests that looks a bit like this:

import image from './test.png';
...
fetch(image).then(response => /* some test that use the image */)'

This used to work fine but with the release of 2.0.8, it doesn't work anymore.
In the output, I can see that:

14 12 2017 15:53:46.483:WARN [web-server]: 404: /tmp/gregoire/_karma_webpack_8a5c1d368c47a24658318f24915284d7.png

I think that the introduction of the tmpdir is preventing karma from finding the image emitted by webpack...

Expected/desired behavior:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
    I made a repository that shows the problem: https://github.com/gdetrez/karma-webpack-issue

  • What is the expected behavior?
    The image variable should contain the path where karma serves the image.

  • What is the motivation / use case for changing the behavior?
    Regression?

@darsee
Copy link
Contributor

darsee commented Dec 14, 2017

Should there be a trailing slash here?

@michael-ciniawsky
Copy link
Contributor

@darsee I think so, could you spin up a quick PR ? :)
@gdetrez Could you please try out the fix suggested by @darsee locally ?

@michael-ciniawsky michael-ciniawsky added this to the 2.0.7 milestone Dec 14, 2017
@darsee
Copy link
Contributor

darsee commented Dec 14, 2017

Also, I think prior to 2.0.8, webpackOptions.output.path would have a trailing slash if indexPath was empty but now it won't. Likewise webpackOptions.output.publicPath if publicPath was empty.

Sure, I'll attempt a PR :)

@michael-ciniawsky
Copy link
Contributor

michael-ciniawsky commented Dec 14, 2017

@darsee Thx very much in advance 🤗 , hopefully #279 didn't break more then that 🤕

darsee added a commit to darsee/karma-webpack that referenced this issue Dec 14, 2017
Prior to codymikol#297, the following paths would always end with a slash:
- `webpackOptions.output.publicPath`
- `webpackOptions.output.publicPath`
- `webpackMiddlewareOptions.publicPath`

Fixes codymikol#284
joshwiens pushed a commit that referenced this issue Dec 14, 2017
Prior to #297, the following paths would always end with a slash:
- `webpackOptions.output.publicPath`
- `webpackOptions.output.publicPath`
- `webpackMiddlewareOptions.publicPath`

Fixes #284
@michael-ciniawsky michael-ciniawsky removed this from the 2.0.10 milestone Dec 18, 2017
@gdetrez
Copy link
Author

gdetrez commented Dec 20, 2017

Sorry for the delay. I just tried 2.0.9 and the problem is still there. I can't re-open the issue though, should I create a new one?

@gdetrez
Copy link
Author

gdetrez commented Dec 22, 2017

The trailing slash is an improvement but I still get a 404:

22 12 2017 14:57:05.039:WARN [web-server]: 404: /tmp/gregoire/_karma_webpack_/8a5c1d368c47a24658318f24915284d7.png 

@PSpSynedra
Copy link

PSpSynedra commented Feb 5, 2018

We still get 404 errors using:

  • webpack-3.10.0
  • file-loader-1.1.6
  • karma-1.7.1
  • karma-webpack-2.0.9
  • jasmine-core-2.8.0

An URL generated by file-loader results in a 404 in the log, when actually being requested:

import TestImageURL from '!!file-loader!images/test_image.jpg';

fdescribe('static file handling', () => {
	it('should load the requested file', (done) => {
		fetch(TestImageURL).then( response => {
			expect( response.status ).toBe(200);
			done();
		});
	});
});

05 02 2018 14:47:09.323:WARN [web-server]: 404: /tmp/_karma_webpack_/d400964494249568d17dd633f90b836d.jpg

It was still working with karma-webpack-2.0.6, though.

@gdetrez: did you open a new issue or sovle this somehow?

@gdetrez
Copy link
Author

gdetrez commented Feb 12, 2018

@PSpSynedra No, I haven't opened a new issue. There's #291 that seems a bit similar but I haven't looked in details so maybe not. My current solution is to pin the version of karma-webpack to 2.0.7.

@gdetrez
Copy link
Author

gdetrez commented Feb 28, 2018

@michael-ciniawsky @PSpSynedra At least for our use case, it seems that 2.0.13 finally solved this issue 🎉

@PSpSynedra
Copy link

@gdetrez Same here. With 2.0.13 it is gone and everything works fine.

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