My application has the following structure:
Web (Asp net core)
|
|--wwwroot
|--ClientApp
| |--app
| | |-- ... (typescript modules, *.spec.js files etc.)
| |
| |--karma.config.js
| |--test-main.js
|
|--Controllers
|--config.json files for web etc.
When I run the command npm test
in the console from the ClientApp folder, I encounter the following error:
File C:\Users\...\Web\karma.conf.js does not exist!
Why is it searching for the karma.conf.js
file in the Web folder?
How can I specify the correct location? The error persists even when I navigate to the app folder.
If I try moving the karma.conf.js file to where it's expected, I face several other errors such as:
cannot find module requirejs
I'm quite perplexed and would greatly appreciate any assistance.
Here is the content of the karma.conf.js file:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'requirejs'],
files: [
'test-main.js',
{pattern: 'test/**/*spec.js', included: false},
{pattern: '*.js', included: false}
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome', 'Firefox'],
singleRun: false,
concurrency: Infinity
})
}
And here is the content of test-main.js:
var allTestFiles = []
var TEST_REGEXP = /(spec|test)\.js$/i
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
var normalizedTestModule = file.replace(/^\/base\/|\.js$/g, '')
allTestFiles.push(normalizedTestModule)
}
})
require.config({
baseUrl: '/base',
deps: allTestFiles,
callback: window.__karma__.start
})