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

create folder path if it does not exist #3735

Merged
merged 1 commit into from Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/server.js
Expand Up @@ -265,6 +265,8 @@ class Server extends KarmaEventEmitter {
const configLevel = config.browserConsoleLogOptions.level || 'debug'
const configFormat = config.browserConsoleLogOptions.format || '%b %T: %m'
const configPath = config.browserConsoleLogOptions.path
const configPathDir = path.dirname(configPath)
if (!fs.existsSync(configPathDir)) fs.mkdirSync(configPathDir, { recursive: true })
this.log.info(`Writing browser console to file: ${configPath}`)
const browserLogFile = fs.openSync(configPath, 'w+')
const levels = ['log', 'error', 'warn', 'info', 'debug']
Expand Down
23 changes: 23 additions & 0 deletions test/e2e/browser_console.feature
Expand Up @@ -152,6 +152,29 @@ Feature: Browser Console Configuration
.
Chrome Headless
"""

Scenario: Execute logging path when a folder does not exist
Given a configuration with:
"""
files = ['browser-console/log.js', 'browser-console/test.js'];
browsers = ['ChromeHeadlessNoSandbox'];
plugins = [
'karma-jasmine',
'karma-chrome-launcher'
];
browserConsoleLogOptions = {
path: 'sandbox/nested/folder/console.log',
format: '%t:%T:%m',
level: 'warn'
};
"""
When I start Karma
Then the file at sandbox/nested/folder/console.log contains:
"""
log:LOG:'foo'
warn:WARN:'foobar'
error:ERROR:'barbaz'
"""

Scenario: Execute logging program and disabling terminal
Given a configuration with:
Expand Down