-
Notifications
You must be signed in to change notification settings - Fork 219
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
Build not getting cancelled when webpack fails to compile the file #49
Comments
have you tried the |
I did some more research yesterday (I forgot to do it initially) and as far as I can tell this is not really an issue of
To require all our specs and are using the |
I'm also having this issue. I guess one way to handle it would be to just specify all the tests individually... |
@cedrics did you find an elegant solution for this issue? |
Hi @mroderick, sadly I didn't. We are currently not working on the project using this setup and therefore did not run into the problem again and so I didn't spend anymore time on it / forgot all about it. |
@cedrics thanks |
Morgan, On Thu, Dec 3, 2015 at 12:25 AM, Morgan Roderick [email protected]
|
I've done some investigation on this and it appears that at least for me the chain of cause-and-effect is:
Importing single test files with |
+1. Also encountering the same issue. |
Thanks for the insight into the optional modules and warnings, @codazzo. Based on that I wrote a mini webpack plugin that shows all warnings and then prevents the tests from running by pretending no assets were generated. It's available at https://gist.github.com/Stuk/6b574049435df532e905 and can be simply added to your karma webpack config plugins. Hope this helps people! |
@Stuk, with your plugin tests are not run but instead process with test run hangs (after showing warnings and before running tests). Is it possible to fail the test run instead? |
You may be able to replace the I use this in watch mode, hence the waiting. On January 29, 2016 8:51:46 AM PST, Petar Paar [email protected] wrote:
|
That worked, thanks! |
I've created another plugin which also prevents Karma from hanging https://gist.github.com/mvgijssel/d3b121ad50e34c09a124 |
Closing this one, issue has multiple resolutions & the issue with karma-webpack not respecting |
@mvgijssel that plugin fixed the issue for me - thanks! |
I don't think this is the same as the bail issue. When running karma in watch mode it's troublesome to have karma report passing tests after fatal compilation errors. I'm using a variation of @Stuk's plugin myself, except I'm clearing the stats on errors instead of warnings. It blocks the compilation until I fix the errors. Only then does it re-run the tests in Karma. |
@d3viant0ne I don't think this issue should be closed or is resolved. These plugins are workarounds. Tests should not run/pass if the code doesn't build. If your using karma start it will fail to build, karma's connection to the browser will timeout, and karma just sits there not exiting and not running tests. |
For those looking for a webpack v4 solution - https://gist.github.com/jonesmac/9ef456153c714db56be0ec24b61c6fbb Seems to work for my use case but be interested to know if it works for others. |
For TypeScript it is sufficient to add to tsconfig.json
|
I'm using |
We ended up using this with Webpack 5:
import { Compiler } from 'webpack';
/**
* `karma-webpack` will just hang forever if there are compilation errors.
* This plugin makes it so that the process actually ends with an error.
*/
export default class WebpackKarmaDieHardPlugin {
public apply(compiler: Compiler) {
compiler.hooks.failed.tap('WebpackKarmaDieHardPlugin', (error) => {
console.error(error);
process.exit(1);
});
}
} Would it be possible to have |
I got it to work by adding this to my buildWebpack: {
failureCb: () => {
setTimeout(() => {
process.exit(1);
});
},
},
|
I am not really sure if this is an error with our configuration,
karma
,karma-webpack
orwebpack
😄We are compiling
cjsx
(coffee
andjsx
) files using webpack and then run our tests using jasmine. Everything is working fine as long as you do not have a syntax error in your coffee file. At that point the tests just run using an outdated version of our code, which often means they just stay green :).With webpack being quieted this does not result in any output and even if you output the error it can easily be overlooked because of the test run afterwards (which scrolls the error out of my terminal).
I would expect the tests to not be run and an error output to the displayed in karma.
Is this an issue that should be fixed here in the plugin or should this work out of the box and I am just too stupid to configure
karma-webpack
.I already tried implementing this using
failed
callback of webpack. Is this the way to go here? I will try some more after work.The text was updated successfully, but these errors were encountered: