Closed icatalina closed 7 years ago
I also would like this. But maybe instead there should be a way to pass arbitrary options to jsdom.env
?
I like both ideas. I'm thinking about both having an option to simply redirect console to the native console, as well as being able to pass options directly to jsdom. What do you think about something along these lines, @sfrdmn?
// karma.conf.js
module.exports = function(config) {
config.set({
browsers: ['jsdom'],
jsdom: {
userAgent: 'foobar'
}
});
};
@badeball Looks good! Could also consider { jsdomLauncher: { enableConsole: true, jsdom : { userAgent: 'thing' } } }
to ensure there are no conflicts but ¯_(ツ)_/¯
I think that's a good idea. I've implemented it like that in 9d7b0e8 and it is configured as shown below.
// karma.conf.js
module.exports = function(config) {
config.set({
browsers: ['jsdom'],
jsdomLauncher: {
jsdom: {
userAgent: 'foobar'
}
}
});
};
Additionally, I've implemented a redirectConsole: true
option in 64ca79d. However, it defaults to false, to retain backwards compatibility. What do you think if that, @icatalina?
I think this was somewhat hastily thrown together by myself, hence is also why I haven't released the above mentioned changes. It turns out that Karma is actually supposed to do this by itself. However, some time after karma-1.4.1, things went a bit sideways in terms of breakage, ref. karma#2582.
In other words, this is supposed to work by itself. It seems that the regression has been fixed in karma@master, ref karma#2676. In the meantime, the workaround is to override the default level
of browserConsoleLogOptions
, as shown below.
// karma.conf.js
module.exports = function(config) {
config.set({
browsers: ['jsdom'],
browserConsoleLogOptions: {
level: 'log'
}
});
};
Thus, I am closing this. Feel free to comment if there's still an issue.
Thanks 😄 This is Great!
Thanks!
\cc @cangoektas
Enable console in when using jsdom