Uncaught Error: Can't find ./Foo [/.../Foo.ts] (required by /Foo/FooTest.ts)
burtonator opened this issue · comments
Kevin Burton commented
I'm getting a really weird error with karma-typescript
Uncaught Error: Can't find ./IndexedDBCacheProviders [/Users/burton/projects/polar-app/packages/polar-app-public/polar-snapshot-cache/src/cache_providers/IndexedDBCacheProviders.ts] (required by /Users/burton/projects/polar-app/packages/polar-app-public/polar-snapshot-cache/src/cache_providers/IndexedDBCacheProvidersTest.ts)
But what's weird is that
/Users/burton/projects/polar-app/packages/polar-app-public/polar-snapshot-cache/src/cache_providers/IndexedDBCacheProviders.ts
exists and is the right file.
Here's my karma.conf.js file:
// Karma configuration
// Generated on Thu Jan 28 2021 18:52:09 GMT-0700 (Mountain Standard Time)
const fs = require('fs');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '.',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'karma-typescript'],
// list of files / patterns to load in the browser
files: [
'src/**/*Test.ts'
],
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"src/**/*.ts": "karma-typescript" // *.tsx for React Jsx
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'karma-typescript'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
// karmaTypescriptConfig: JSON.parse(fs.readFileSync('./tsconfig.json').toString())
karmaTypescriptConfig: {
compilerOptions: {
module: "commonjs"
},
tsconfig: "./tsconfig.json",
bundlerOptions: {
transforms: [
require("karma-typescript-es6-transform")()
]
}
}
})
}
and my tsconfig.json
{
"compilerOptions": {
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": false,
"alwaysStrict": true,
"listEmittedFiles": false,
"noImplicitReturns": true,
"removeComments": true,
"strictFunctionTypes": true,
"inlineSourceMap": true,
"inlineSources": true,
"target": "ES2015",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": false,
"stripInternal": true,
"checkJs": false,
"jsx": "react",
"esModuleInterop": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"]
},
"lib": ["es2019", "dom"]
},
"include": [
"src/**/*"
],
"exclude": [
]
}
Alex Gustafsson commented
Did you ever find a solution to this? I'm struggling with the same issue.