fix: exclude test entry points from karma sourceFiles patterns
In karma 6, files matched by earlier patterns aren't overridden by later patterns. The sourceFiles patterns like `cms/**/!(*spec|djangojs).js` matched test entry files (e.g., `cms/js/spec/main.js`) because they don't end with "spec" or "djangojs". This prevented runFiles from setting `included: true` on these files, so tests never started. Split the sourceFiles patterns to precisely exclude spec/main*.js test entry points while still serving other source files: - Direct children of the js directory - Subdirectories except spec/ - spec/ subdirectory, excluding main* files This allows runFiles to control test entry point inclusion. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,10 @@ var options = {
|
||||
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
|
||||
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
|
||||
sourceFiles: [
|
||||
{pattern: 'cms/**/!(*spec|djangojs).js'},
|
||||
// Split cms/ patterns to exclude spec/main*.js test entry points (handled by runFiles)
|
||||
{pattern: 'cms/js/!(*spec|djangojs).js'}, // Direct children of cms/js/
|
||||
{pattern: 'cms/js/!(spec)/**/!(*spec|djangojs).js'}, // Subdirs of cms/js/ except spec/
|
||||
{pattern: 'cms/js/spec/**/!(*spec|djangojs|main*).js'}, // spec/ subdir, excluding main* files
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'}
|
||||
],
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ var options = {
|
||||
// Make sure the patterns in sourceFiles and specFiles do not match the same file.
|
||||
// Otherwise Istanbul which is used for coverage tracking will cause tests to not run.
|
||||
sourceFiles: [
|
||||
{pattern: 'cms/js/**/!(*spec|djangojs).js'},
|
||||
// Split cms/js/ patterns to exclude spec/main*.js test entry points (handled by runFiles)
|
||||
{pattern: 'cms/js/!(*spec|djangojs).js'}, // Direct children of cms/js/
|
||||
{pattern: 'cms/js/!(spec)/**/!(*spec|djangojs).js'}, // Subdirs of cms/js/ except spec/
|
||||
{pattern: 'cms/js/spec/**/!(*spec|djangojs|main*).js'}, // spec/ subdir, excluding main* files
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'}
|
||||
],
|
||||
|
||||
|
||||
@@ -60,7 +60,9 @@ var commonFiles = {
|
||||
],
|
||||
|
||||
sourceFiles: [
|
||||
{pattern: 'common/js/!(spec_helpers)/**/!(*spec).js'}
|
||||
// Split common/js/ to exclude spec/main*.js test entry points (handled by runFiles)
|
||||
{pattern: 'common/js/!(spec_helpers|spec)/**/!(*spec).js'}, // all non-spec, non-spec_helpers dirs
|
||||
{pattern: 'common/js/spec/**/!(*spec|main*).js'} // spec dir, excluding spec and main* files
|
||||
],
|
||||
|
||||
specFiles: [
|
||||
|
||||
@@ -34,7 +34,10 @@ var options = {
|
||||
{pattern: 'discussion/js/**/!(*spec).js'},
|
||||
{pattern: 'js/**/!(*spec|djangojs).js'},
|
||||
{pattern: 'learner_profile/**/!(*spec).js'},
|
||||
{pattern: 'lms/js/**/!(*spec).js'},
|
||||
// Split lms/js/ to exclude spec/main*.js test entry points (handled by runFiles)
|
||||
{pattern: 'lms/js/!(*spec).js'}, // Direct children of lms/js/
|
||||
{pattern: 'lms/js/!(spec)/**/!(*spec).js'}, // Subdirs of lms/js/ except spec/
|
||||
{pattern: 'lms/js/spec/**/!(*spec|main*).js'}, // spec/ subdir, excluding main* files
|
||||
{pattern: 'support/js/**/!(*spec).js'},
|
||||
{pattern: 'teams/js/**/!(*spec).js'},
|
||||
{pattern: 'completion/js/**/!(*spec).js'}
|
||||
|
||||
Reference in New Issue
Block a user