karma-runner / karma-runner/karma

basePath does not append trailing slash in preprocessors

Open
#2,520 3 comments 0 reactions 0 assignees View on GitHub
needs: test
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Expected behaviour
Karma automatically adds a trailing slash to baseBath for files defined in the files array. So if you set
{
basePath: "../my/other/folder",
files: ["file.js"]
}

karma serves `../my/other/folder/files.js` and not `../my/other/folderfile.js`.

When you define the same pattern for a preprocessor, karma should also append a trailing slash -- or, karma should list a WARN message that the pattern did not match any files because the trailing slash is missing.

### Actual behaviour
In karma 1.1.0 this behaved as expected. Karma added the trailing slash to both the files array and to preprocessors.

In karma 1.3.0 karma does not add a trailing slash to preprocessors file patterns, but it _does_ add a trailing slash to the files array. This makes the file pattern appear valid (because no WARN is generated) but the preprocessor still does not run.

### Environment Details

- Karma version (output of `karma --version`): 1.3.0
- Relevant part of your `karma.config.js` file
{
basePath: ".",
preprocessors: {
"MyApp/\*\*/\*.js": ["my-preprocessor"]
},
files: [
//...
"MyApp/\*\*/\*.js"
]
}

### Steps to reproduce the behaviour
In karma.conf
1. Set a basePath with no trailing slash
2. Add a preprocessor with a valid file pattern
3. Add the same pattern to the files array
4. Run karma - the preprocessor will not process any files

Contributor guide

Open the contributing guide

Research direction

Start with the karma.conf configuration shown in the issue, comparing how basePath is applied to the files and preprocessors patterns. Reproduce the case with a basePath lacking a trailing slash and verify that the preprocessor runs for the matching files, or that a warning is emitted when no files match.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.