Open cefn opened 3 years ago
I cloned your example and set a breakpoint with at node_modules\karma-typescript\dist\istanbul\coverage.js:35 with conditional emitOutput.outputText == undefined
and it was hit with App.test.tsx. When inspecting this.config.coverageOptions.exclude I saw that this was set to /\\.(d|spec|test)\\.ts$/i
. Looks like karma-typescript does not exclude *.test.tsx files from coverage instrumentation by default. But this also raises the question, why there is no output for App.test.tsx. I didn't have more time to investigate further, but hope this helped you a little already.
I don't think this needs a seperate issue, as this seems to be configuration error in the project. Nevertheless I agree that this might probably need some better handling or a more understandable message, but I would propose to leave that discussion in #341.
Just to clarify, Tim. I am not particularly concerned regarding coverage, and would accept any configuration which actually makes tests run. Crucially I currently get this output...
Chrome 91.0.4472.114 (Linux x86_64): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
Chrome 91.0.4472.114 (Linux x86_64): Executed 0 of 0 SUCCESS (0.001 secs / 0 secs)
That's one reason for separating out this issue from the many configurations, errors discussed in #341 (depending on what particular workaround for the startsWith
error is attempted).
Additionally having 0 tests detected is an error with a complete repro where this detail is absent in #341 making it well-scoped.
So to refocus this issue explicitly away from property 'startsWith'
, what variation do I have to make for Karma to see any of my tests and run them in any form, regardless of coverage?
I can close if you instruct me to, and if you feel the scope of this error really is the same as the 'startsWith' issue, but I don't think I've understood how the startsWith
error and the 0 of 0 SUCCESS
error are the same thing currently.
I'll change the title to reflect the intended scope.
With the modification of the title this seems to be scoped better. 👍
Wrapping the Typescript compilation process rather than going full webpack
and full babel
is my preference. Seems more elegant and don't have to dance through hoops for sourcemaps etc. I have a workaround for now following the babel route (with all the horrid extra packages, config). This means I can run Karma tests in my personal project so it's less urgent, I wanted to at least share a repro of a pretty minimal problem case config back to karma-typescript
for it to be worked on. I'm puzzling what's different about how me (and others) have approached composing our project which triggers a bug, since presumably everyone else is using the utility perfectly well.
Thank you for opening this issue, I am facing a similar problem in my repo: https://github.com/status-im/js-waku/pull/230 with no test being executed Chrome 91.0.4472.114 (Linux x86_64): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
Full log:
/usr/bin/node /usr/lib/node_modules/npm/bin/npm-cli.js run test:karma --scripts-prepend-node-path=auto
> js-waku@0.7.0 test:karma
> karma start
14 07 2021 11:57:57.910:DEBUG [config]: Loading config /home/froyer/src/status-im/js-waku/karma.conf.js
14 07 2021 11:57:57.915:DEBUG [config]: autoWatch set to false, because of singleRun
14 07 2021 11:57:57.919:DEBUG [karma-server]: Final config Config {
LOG_DISABLE: 'OFF',
LOG_ERROR: 'ERROR',
LOG_WARN: 'WARN',
LOG_INFO: 'INFO',
LOG_DEBUG: 'DEBUG',
frameworks: [ 'mocha', 'karma-typescript' ],
protocol: 'http:',
port: 9876,
listenAddress: '0.0.0.0',
hostname: 'localhost',
httpsServerConfig: {},
basePath: '/home/froyer/src/status-im/js-waku',
files: [
Pattern {
pattern: '/home/froyer/src/status-im/js-waku/src/**/*browser.spec.ts',
served: true,
included: true,
watched: true,
nocache: false,
weight: [ 1, 1, 1, 0, 0, 0 ],
type: undefined,
isBinary: undefined
}
],
browserConsoleLogOptions: { level: 'debug', format: '%b %T: %m', terminal: true },
customContextFile: null,
customDebugFile: null,
customClientContextFile: null,
exclude: [ '/home/froyer/src/status-im/js-waku/karma.conf.js' ],
logLevel: 'DEBUG',
colors: true,
autoWatch: false,
autoWatchBatchDelay: 250,
restartOnFileChange: false,
usePolling: true,
reporters: [ 'progress', 'karma-typescript' ],
singleRun: true,
browsers: [ 'Chromium' ],
captureTimeout: 60000,
pingTimeout: 5000,
proxies: {},
proxyValidateSSL: true,
preprocessors: [Object: null prototype] {
'/home/froyer/src/status-im/js-waku/**/*.ts': [ 'karma-typescript' ]
},
preprocessor_priority: {},
urlRoot: '/',
upstreamProxy: undefined,
reportSlowerThan: 0,
loggers: [
{
type: 'console',
layout: { type: 'pattern', pattern: '%[%d{DATE}:%p [%c]: %]%m' }
}
],
transports: [ 'polling', 'websocket' ],
forceJSONP: false,
plugins: [
{
'framework:mocha': [
'factory',
[Function: initMocha] {
'$inject': [ 'config.files', 'config' ]
}
]
},
{
'framework:karma-typescript': [
'factory',
[Function (anonymous)] { '$inject': [ 'config', 'logger' ] }
],
'preprocessor:karma-typescript': [ 'factory', [Function (anonymous)] { '$inject': [ 'logger' ] } ],
'reporter:karma-typescript': [
'type',
[Function (anonymous)] {
'$inject': [ 'baseReporterDecorator', 'logger', 'config' ]
}
]
},
{
'launcher:Chrome': [
'type',
[Function: ChromeBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
'launcher:ChromeHeadless': [
'type',
[Function: ChromeHeadlessBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
'launcher:ChromeCanary': [
'type',
[Function: ChromeCanaryBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
'launcher:ChromeCanaryHeadless': [
'type',
[Function: ChromeCanaryHeadlessBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
'launcher:Chromium': [
'type',
[Function: ChromiumBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
'launcher:ChromiumHeadless': [ 'type', [Function: ChromiumHeadlessBrowser] ],
'launcher:Dartium': [
'type',
[Function: DartiumBrowser] {
'$inject': [ 'baseBrowserDecorator', 'args' ]
}
],
test: {
isJSFlags: [Function: isJSFlags],
sanitizeJSFlags: [Function: sanitizeJSFlags],
headlessGetOptions: [Function: headlessGetOptions],
canaryGetOptions: [Function: canaryGetOptions]
}
}
],
client: {
args: [],
useIframe: true,
runInParent: false,
captureConsole: true,
clearContext: true
},
defaultClient: {
args: [],
useIframe: true,
runInParent: false,
captureConsole: true,
clearContext: true
},
browserDisconnectTimeout: 2000,
browserDisconnectTolerance: 0,
browserNoActivityTimeout: 30000,
processKillTimeout: 2000,
concurrency: Infinity,
failOnEmptyTestSuite: true,
retryLimit: 2,
detached: false,
crossOriginAttribute: true,
browserSocketTimeout: 20000,
cmd: 'start',
configFile: '/home/froyer/src/status-im/js-waku/karma.conf.js',
karmaTypescriptConfig: {
tsconfig: './tsconfig.dev.json',
coverageOptions: { instrumentation: false }
}
}
14 07 2021 11:57:57.920:DEBUG [plugin]: Loading inline plugin defining framework:mocha.
14 07 2021 11:57:57.920:DEBUG [plugin]: Loading inline plugin defining framework:karma-typescript, preprocessor:karma-typescript, reporter:karma-typescript.
14 07 2021 11:57:57.920:DEBUG [plugin]: Loading inline plugin defining launcher:Chrome, launcher:ChromeHeadless, launcher:ChromeCanary, launcher:ChromeCanaryHeadless, launcher:Chromium, launcher:ChromiumHeadless, launcher:Dartium, test.
14 07 2021 11:57:57.925:DEBUG [coverage.karma-typescript]: Initializing
14 07 2021 11:57:57.931:DEBUG [compiler.karma-typescript]: Setting up deferred project compilation
14 07 2021 11:57:57.932:DEBUG [coverage.karma-typescript]: Configuring coverage preprocessor
14 07 2021 11:57:57.940:DEBUG [resolver.karma-typescript]: {
assert: '/home/froyer/src/status-im/js-waku/node_modules/assert/build/assert.js',
buffer: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/node_modules/buffer/index.js',
child_process: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
cluster: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
console: '/home/froyer/src/status-im/js-waku/node_modules/console-browserify/index.js',
constants: '/home/froyer/src/status-im/js-waku/node_modules/constants-browserify/constants.json',
crypto: '/home/froyer/src/status-im/js-waku/node_modules/crypto-browserify/index.js',
dgram: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
dns: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
domain: '/home/froyer/src/status-im/js-waku/node_modules/domain-browser/source/index.js',
events: '/home/froyer/src/status-im/js-waku/node_modules/events/events.js',
fs: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
http: '/home/froyer/src/status-im/js-waku/node_modules/stream-http/index.js',
https: '/home/froyer/src/status-im/js-waku/node_modules/https-browserify/index.js',
module: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
net: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
os: '/home/froyer/src/status-im/js-waku/node_modules/os-browserify/browser.js',
path: '/home/froyer/src/status-im/js-waku/node_modules/path-browserify/index.js',
punycode: '/home/froyer/src/status-im/js-waku/node_modules/punycode/punycode.js',
querystring: '/home/froyer/src/status-im/js-waku/node_modules/querystring-es3/index.js',
readline: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
repl: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
stream: '/home/froyer/src/status-im/js-waku/node_modules/stream-browserify/index.js',
_stream_duplex: '/home/froyer/src/status-im/js-waku/node_modules/readable-stream/lib/_stream_duplex.js',
_stream_passthrough: '/home/froyer/src/status-im/js-waku/node_modules/readable-stream/lib/_stream_passthrough.js',
_stream_readable: '/home/froyer/src/status-im/js-waku/node_modules/readable-stream/lib/_stream_readable.js',
_stream_transform: '/home/froyer/src/status-im/js-waku/node_modules/readable-stream/lib/_stream_transform.js',
_stream_writable: '/home/froyer/src/status-im/js-waku/node_modules/readable-stream/lib/_stream_writable.js',
string_decoder: '/home/froyer/src/status-im/js-waku/node_modules/string_decoder/lib/string_decoder.js',
sys: '/home/froyer/src/status-im/js-waku/node_modules/util/util.js',
timers: '/home/froyer/src/status-im/js-waku/node_modules/timers-browserify/main.js',
tls: '/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/bundler/resolve/empty.js',
tty: '/home/froyer/src/status-im/js-waku/node_modules/tty-browserify/index.js',
url: '/home/froyer/src/status-im/js-waku/node_modules/url/url.js',
util: '/home/froyer/src/status-im/js-waku/node_modules/util/util.js',
vm: '/home/froyer/src/status-im/js-waku/node_modules/vm-browserify/index.js',
zlib: '/home/froyer/src/status-im/js-waku/node_modules/browserify-zlib/lib/index.js',
_process: '/home/froyer/src/status-im/js-waku/node_modules/process/browser.js'
}
14 07 2021 11:57:57.942:DEBUG [resolver.karma-typescript]: No bower detected, skipping
14 07 2021 11:57:57.943:DEBUG [framework.karma-typescript]: Configuration:
{
"loggers": {
"bundler": {
"category": "bundler.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"compiler": {
"category": "compiler.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"dependencyWalker": {
"category": "dependency-walker.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"project": {
"category": "project.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"resolver": {
"category": "resolver.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"sourceMap": {
"category": "source-map.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"sourceReader": {
"category": "source-reader.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"threshold": {
"category": "threshold.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"transformer": {
"category": "transformer.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
},
"validator": {
"category": "validator.karma-typescript",
"context": {},
"parseCallStack": "function defaultParseCallStack(data, skipIdx = 4) {\n const stacklines = data.stack.split(\"\\n\").slic..."
}
},
"callbacks": [
"function () {\n _this.log.debug(\"Setting up deferred project compilation\");\n _t...",
"function () {\n _this.log.debug(\"Configuring coverage preprocessor\");\n _this.in..."
],
"karma": {
"LOG_DISABLE": "OFF",
"LOG_ERROR": "ERROR",
"LOG_WARN": "WARN",
"LOG_INFO": "INFO",
"LOG_DEBUG": "DEBUG",
"frameworks": [
"mocha",
"karma-typescript"
],
"protocol": "http:",
"port": 9876,
"listenAddress": "0.0.0.0",
"hostname": "localhost",
"httpsServerConfig": {},
"basePath": "/home/froyer/src/status-im/js-waku",
"files": [
{
"included": true,
"pattern": "/tmp/karma-typescript-bundle--1818820-VQspEMw9h1pb-.js",
"served": true,
"watched": true
},
{
"pattern": "/home/froyer/src/status-im/js-waku/node_modules/mocha/mocha.js",
"included": true,
"served": true,
"watched": false
},
{
"pattern": "/home/froyer/src/status-im/js-waku/node_modules/karma-mocha/lib/adapter.js",
"included": true,
"served": true,
"watched": false
},
{
"pattern": "/home/froyer/src/status-im/js-waku/src/**/*browser.spec.ts",
"served": true,
"included": true,
"watched": true,
"nocache": false,
"weight": [
1,
1,
1,
0,
0,
0
]
},
{
"included": true,
"pattern": "/home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/client/commonjs.js",
"served": true,
"watched": false
}
],
"browserConsoleLogOptions": {
"level": "debug",
"format": "%b %T: %m",
"terminal": true
},
"customContextFile": null,
"customDebugFile": null,
"customClientContextFile": null,
"exclude": [
"/home/froyer/src/status-im/js-waku/karma.conf.js"
],
"logLevel": "DEBUG",
"colors": true,
"autoWatch": false,
"autoWatchBatchDelay": 250,
"restartOnFileChange": false,
"usePolling": true,
"reporters": [
"progress",
"karma-typescript"
],
"singleRun": true,
"browsers": [
"Chromium"
],
"captureTimeout": 60000,
"pingTimeout": 5000,
"proxies": {},
"proxyValidateSSL": true,
"preprocessors": {
"/home/froyer/src/status-im/js-waku/**/*.ts": [
"karma-typescript"
]
},
"preprocessor_priority": {},
"urlRoot": "/",
"reportSlowerThan": 0,
"loggers": [
{
"type": "console",
"layout": {
"type": "pattern",
"pattern": "%[%d{DATE}:%p [%c]: %]%m"
}
}
],
"transports": [
"polling",
"websocket"
],
"forceJSONP": false,
"plugins": [
{
"framework:mocha": [
"factory",
"function (files, config) {\n var mochaPath = path.dirname(require.resolve('mocha'))\n files.unshift(..."
]
},
{
"framework:karma-typescript": [
"factory",
"function (karmaConfig, logger) {\n _this.log = logger.create(\"framework.karma-typescript\")..."
],
"preprocessor:karma-typescript": [
"factory",
"function (logger) {\n _this.log = logger.create(\"preprocessor.karma-typescript\");\n ..."
],
"reporter:karma-typescript": [
"type",
"function (baseReporterDecorator, logger) {\n var _this = this;\n baseReporterDec..."
]
},
{
"launcher:Chrome": [
"type",
"function (baseBrowserDecorator, args) {\n baseBrowserDecorator(this)\n\n var flags = args.flags || []..."
],
"launcher:ChromeHeadless": [
"type",
"function (baseBrowserDecorator, args) {\n ChromeBrowser.apply(this, arguments)\n\n var parentOptions ..."
],
"launcher:ChromeCanary": [
"type",
"function (baseBrowserDecorator, args) {\n ChromeBrowser.apply(this, arguments)\n\n var parentOptions ..."
],
"launcher:ChromeCanaryHeadless": [
"type",
"function (baseBrowserDecorator, args) {\n ChromeCanaryBrowser.apply(this, arguments)\n\n var parentOp..."
],
"launcher:Chromium": [
"type",
"function (baseBrowserDecorator, args) {\n baseBrowserDecorator(this)\n\n var flags = args.flags || []..."
],
"launcher:ChromiumHeadless": [
"type",
"function (baseBrowserDecorator, args) {\n ChromiumBrowser.apply(this, arguments)\n\n var parentOption..."
],
"launcher:Dartium": [
"type",
"function () {\n ChromeBrowser.apply(this, arguments)\n\n var checkedFlag = '--checked'\n var dartFlag..."
],
"test": {
"isJSFlags": "function isJSFlags (flag) {\n return flag.indexOf('--js-flags=') === 0\n}...",
"sanitizeJSFlags": "function sanitizeJSFlags (flag) {\n var test = /--js-flags=(['\"])/.exec(flag)\n if (!test) {\n ret...",
"headlessGetOptions": "function headlessGetOptions (url, args, parent) {\n var mergedArgs = parent.call(this, url, args).co...",
"canaryGetOptions": "function canaryGetOptions (url, args, parent) {\n // disable crankshaft optimizations, as it causes ..."
}
}
],
"client": {
"args": [],
"useIframe": true,
"runInParent": false,
"captureConsole": true,
"clearContext": true,
"mocha": {}
},
"defaultClient": {
"args": [],
"useIframe": true,
"runInParent": false,
"captureConsole": true,
"clearContext": true,
"mocha": {}
},
"browserDisconnectTimeout": 2000,
"browserDisconnectTolerance": 0,
"browserNoActivityTimeout": 30000,
"processKillTimeout": 2000,
"concurrency": null,
"failOnEmptyTestSuite": true,
"retryLimit": 2,
"detached": false,
"crossOriginAttribute": true,
"browserSocketTimeout": 20000,
"cmd": "start",
"configFile": "/home/froyer/src/status-im/js-waku/karma.conf.js",
"karmaTypescriptConfig": {
"tsconfig": "./tsconfig.dev.json",
"coverageOptions": {
"instrumentation": false
}
}
},
"karmaTypescriptConfig": {
"tsconfig": "./tsconfig.dev.json",
"coverageOptions": {
"instrumentation": false
}
},
"logAppenders": {
"console0": {
"type": "console",
"layout": {
"type": "pattern",
"pattern": "%[%d{DATE}:%p [%c]: %]%m"
}
}
},
"bundlerOptions": {
"acornOptions": {
"ecmaVersion": 10,
"sourceType": "module"
},
"addNodeGlobals": true,
"constants": {},
"entrypoints": {},
"exclude": [],
"ignore": [],
"noParse": [],
"resolve": {
"alias": {},
"directories": [
"node_modules"
],
"extensions": [
".js",
".json",
".mjs",
".ts",
".tsx"
]
},
"sourceMap": false,
"transforms": [],
"validateSyntax": true
},
"hasCoverageThreshold": false,
"coverageOptions": {
"exclude": {},
"instrumentation": false,
"instrumenterOptions": {},
"threshold": {
"file": {
"branches": 0,
"excludes": [],
"functions": 0,
"lines": 0,
"overrides": {},
"statements": 0
},
"global": {
"branches": 0,
"excludes": [],
"functions": 0,
"lines": 0,
"statements": 0
}
}
},
"compilerDelay": 250,
"defaultTsconfig": {
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"module": "commonjs",
"sourceMap": true,
"target": "ES5"
},
"exclude": [
"node_modules"
]
},
"tsconfig": "./tsconfig.dev.json",
"stopOnFailure": true,
"transformPath": "function (filepath) {\n return filepath.replace(/\\.(ts|tsx)$/, \".js\");\n }...",
"reports": {
"html": "coverage"
},
"asserted": true
}
14 07 2021 11:57:57.944:DEBUG [web-server]: Instantiating middleware
14 07 2021 11:57:57.957:DEBUG [reporter]: Trying to load reporter: karma-typescript
14 07 2021 11:57:57.958:DEBUG [reporter]: Trying to load color-version of reporter: karma-typescript (karma-typescript_color)
14 07 2021 11:57:57.958:DEBUG [reporter]: Couldn't load color-version.
14 07 2021 11:57:58.001:DEBUG [preprocessor.karma-typescript]: Processing "/home/froyer/src/status-im/js-waku/src/lib/waku.browser.spec.ts". 818
14 07 2021 11:57:58.254:INFO [compiler.karma-typescript]: Compiling project using Typescript 4.2.4
14 07 2021 11:57:58.261:DEBUG [project.karma-typescript]: File system changed, resolving tsconfig
14 07 2021 11:57:58.261:DEBUG [project.karma-typescript]: Using /home/froyer/src/status-im/js-waku/tsconfig.dev.json
14 07 2021 11:57:58.270:DEBUG [project.karma-typescript]: Resolved configFileJson:
{
"config": {
"extends": "./tsconfig",
"compilerOptions": {
"noEmit": true
},
"exclude": [
"node_modules/**"
]
}
}
14 07 2021 11:57:58.289:DEBUG [project.karma-typescript]: Resolved tsconfig:
{
"options": {
"incremental": true,
"target": 4,
"rootDir": "/home/froyer/src/status-im/js-waku/src",
"moduleResolution": 2,
"module": 1,
"declaration": true,
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"traceResolution": false,
"listEmittedFiles": false,
"listFiles": false,
"pretty": true,
"skipLibCheck": true,
"lib": [
"lib.es2017.d.ts",
"lib.dom.d.ts"
],
"types": [
"node",
"mocha"
],
"typeRoots": [
"/home/froyer/src/status-im/js-waku/node_modules/@types",
"/home/froyer/src/status-im/js-waku/src/types"
],
"noEmit": true,
"configFilePath": "/home/froyer/src/status-im/js-waku/tsconfig.dev.json",
"suppressOutputPathCheck": true
},
"fileNames": [
"/home/froyer/src/status-im/js-waku/src/index.ts",
"/home/froyer/src/status-im/js-waku/src/lib/delay.ts",
"/home/froyer/src/status-im/js-waku/src/lib/discover.ts",
"/home/froyer/src/status-im/js-waku/src/lib/select_peer.ts",
"/home/froyer/src/status-im/js-waku/src/lib/utils.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku.browser.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku.ts",
"/home/froyer/src/status-im/js-waku/src/lib/chat_message/index.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/chat_message/index.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_light_push/index.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_light_push/index.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_light_push/push_rpc.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_message/index.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_message/index.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_message/version_1.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_message/version_1.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_relay/constants.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_relay/get_relay_peers.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_relay/index.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_relay/index.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_relay/relay_heartbeat.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_store/history_rpc.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_store/index.spec.ts",
"/home/froyer/src/status-im/js-waku/src/lib/waku_store/index.ts",
"/home/froyer/src/status-im/js-waku/src/proto/index.ts",
"/home/froyer/src/status-im/js-waku/src/proto/chat/v2/chat_message.ts",
"/home/froyer/src/status-im/js-waku/src/proto/waku/v2/light_push.ts",
"/home/froyer/src/status-im/js-waku/src/proto/waku/v2/message.ts",
"/home/froyer/src/status-im/js-waku/src/proto/waku/v2/store.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/async_fs.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/constants.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/index.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/log_file.spec.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/log_file.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/nim_waku.spec.ts",
"/home/froyer/src/status-im/js-waku/src/test_utils/nim_waku.ts",
"/home/froyer/src/status-im/js-waku/src/types/types.d.ts"
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"extends": "./tsconfig",
"compilerOptions": {
"noEmit": true
},
"exclude": [
"node_modules/**"
],
"compileOnSave": false,
"include": [
"src/**/*.ts"
]
},
"errors": [],
"wildcardDirectories": {
"/home/froyer/src/status-im/js-waku/src": 1
},
"compileOnSave": false
}
14 07 2021 11:58:04.062:INFO [compiler.karma-typescript]: Compiled 38 files in 5772 ms.
14 07 2021 11:58:04.570:DEBUG [bundler.karma-typescript]: Project has 3 import/require statements, code will be bundled
14 07 2021 11:58:05.058:INFO [bundler.karma-typescript]: Bundled imports for 1 file(s) in 494 ms.
14 07 2021 11:58:05.072:DEBUG [coverage.karma-typescript]: Excluding file /home/froyer/src/status-im/js-waku/src/lib/waku.browser.spec.ts from instrumentation
14 07 2021 11:58:05.085:DEBUG [bundler.karma-typescript]: Karma callbacks for 1 file(s) in 521 ms.
14 07 2021 11:58:05.098:INFO [karma-server]: Karma v6.3.4 server started at http://localhost:9876/
14 07 2021 11:58:05.099:INFO [launcher]: Launching browsers Chromium with concurrency unlimited
14 07 2021 11:58:05.119:INFO [launcher]: Starting browser Chromium
14 07 2021 11:58:05.120:DEBUG [launcher]: null -> BEING_CAPTURED
14 07 2021 11:58:05.121:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-12166445
14 07 2021 11:58:05.122:DEBUG [launcher]: chromium --user-data-dir=/tmp/karma-12166445 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling http://localhost:9876/?id=12166445
14 07 2021 11:58:05.893:DEBUG [web-server]: serving: /home/froyer/src/status-im/js-waku/node_modules/karma/static/client.html
14 07 2021 11:58:05.922:DEBUG [web-server]: serving: /home/froyer/src/status-im/js-waku/node_modules/karma/static/karma.js
14 07 2021 11:58:05.975:DEBUG [karma-server]: A browser has connected on socket jTbzVUD8UYJRMEyeAAAB
14 07 2021 11:58:05.977:DEBUG [web-server]: upgrade /socket.io/?EIO=4&transport=websocket&sid=tmsdGiXusnnj5QetAAAA
14 07 2021 11:58:05.998:DEBUG [Chrome 91.0.4472.114 (Linux x86_64)]: undefined -> CONNECTED
14 07 2021 11:58:05.998:INFO [Chrome 91.0.4472.114 (Linux x86_64)]: Connected on socket jTbzVUD8UYJRMEyeAAAB with id 12166445
14 07 2021 11:58:05.999:DEBUG [launcher]: BEING_CAPTURED -> CAPTURED
14 07 2021 11:58:05.999:DEBUG [launcher]: Chromium (id 12166445) captured in 0.9 secs
14 07 2021 11:58:06.000:DEBUG [Chrome 91.0.4472.114 (Linux x86_64)]: CONNECTED -> CONFIGURING
14 07 2021 11:58:06.003:DEBUG [web-server]: serving: /home/froyer/src/status-im/js-waku/node_modules/karma/static/favicon.ico
14 07 2021 11:58:06.011:DEBUG [middleware:karma]: custom files null null null
14 07 2021 11:58:06.012:DEBUG [middleware:karma]: Serving static request /context.html
14 07 2021 11:58:06.013:DEBUG [web-server]: serving: /home/froyer/src/status-im/js-waku/node_modules/karma/static/context.html
14 07 2021 11:58:06.052:DEBUG [middleware:source-files]: Requesting /absolute/tmp/karma-typescript-bundle--1818820-VQspEMw9h1pb-.js?da39a3ee5e6b4b0d3255bfef95601890afd80709
14 07 2021 11:58:06.052:DEBUG [middleware:source-files]: Fetching /tmp/karma-typescript-bundle--1818820-VQspEMw9h1pb-.js
14 07 2021 11:58:06.054:DEBUG [middleware:source-files]: Requesting /base/node_modules/mocha/mocha.js?0ee141af383d01d8134ef30c5313e9ce8c00a3f2
14 07 2021 11:58:06.055:DEBUG [middleware:source-files]: Fetching /home/froyer/src/status-im/js-waku/node_modules/mocha/mocha.js
14 07 2021 11:58:06.055:DEBUG [web-server]: serving (cached): /home/froyer/src/status-im/js-waku/node_modules/mocha/mocha.js
14 07 2021 11:58:06.060:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-mocha/lib/adapter.js?a0f4bbc139407501892ac58d70c2791e7adec343
14 07 2021 11:58:06.060:DEBUG [middleware:source-files]: Fetching /home/froyer/src/status-im/js-waku/node_modules/karma-mocha/lib/adapter.js
14 07 2021 11:58:06.060:DEBUG [web-server]: serving (cached): /home/froyer/src/status-im/js-waku/node_modules/karma-mocha/lib/adapter.js
14 07 2021 11:58:06.061:DEBUG [middleware:source-files]: Requesting /base/src/lib/waku.browser.spec.js?860cb6ad18e275755b5d20bf240bf758d1cbc837
14 07 2021 11:58:06.061:DEBUG [middleware:source-files]: Fetching /home/froyer/src/status-im/js-waku/src/lib/waku.browser.spec.js
14 07 2021 11:58:06.061:DEBUG [web-server]: serving (cached): /home/froyer/src/status-im/js-waku/src/lib/waku.browser.spec.js
14 07 2021 11:58:06.062:DEBUG [web-server]: serving: /home/froyer/src/status-im/js-waku/node_modules/karma/static/context.js
14 07 2021 11:58:06.065:DEBUG [web-server]: serving: /tmp/karma-typescript-bundle--1818820-VQspEMw9h1pb-.js
14 07 2021 11:58:06.068:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-typescript/dist/client/commonjs.js?f5014f1e344ba3e2f0d92afe67b92f3001c46c90
14 07 2021 11:58:06.069:DEBUG [middleware:source-files]: Fetching /home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/client/commonjs.js
14 07 2021 11:58:06.069:DEBUG [web-server]: serving (cached): /home/froyer/src/status-im/js-waku/node_modules/karma-typescript/dist/client/commonjs.js
14 07 2021 11:58:06.236:DEBUG [Chrome 91.0.4472.114 (Linux x86_64)]: CONFIGURING -> EXECUTING
Chrome 91.0.4472.114 (Linux x86_64): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
Chrome 91.0.4472.114 (Linux x86_64): Executed 0 of 0 SUCCESS (0.003 secs / 0 secs)
14 07 2021 11:58:06.241:DEBUG [launcher]: CAPTURED -> BEING_KILLED
14 07 2021 11:58:06.242:DEBUG [launcher]: BEING_KILLED -> BEING_FORCE_KILLED
14 07 2021 11:58:06.242:DEBUG [Chrome 91.0.4472.114 (Linux x86_64)]: CONNECTED -> DISCONNECTED
TOTAL: 0 SUCCESS
14 07 2021 11:58:06.246:DEBUG [karma-server]: Run complete, exiting.
14 07 2021 11:58:06.246:DEBUG [launcher]: Disconnecting all browsers
14 07 2021 11:58:06.247:DEBUG [launcher]: BEING_FORCE_KILLED -> BEING_FORCE_KILLED
14 07 2021 11:58:06.247:DEBUG [proxy]: Destroying proxy agents
14 07 2021 11:58:06.248:DEBUG [reporter.karma-typescript]: Writing coverage to coverage/Chrome 91.0.4472.114 (Linux x86_64)/html
14 07 2021 11:58:06.275:DEBUG [launcher]: Process Chromium exited with code 0 and signal null
14 07 2021 11:58:06.276:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-12166445
14 07 2021 11:58:06.331:DEBUG [launcher]: Finished all browsers
14 07 2021 11:58:06.331:DEBUG [launcher]: BEING_FORCE_KILLED -> FINISHED
14 07 2021 11:58:06.332:DEBUG [launcher]: FINISHED -> FINISHED
@D4nte so I gather in your case from https://github.com/monounity/karma-typescript/issues/341#issuecomment-879531928 it was resolved by ensuring .js files are emitted.
I don't know why this doesn't work in my case. Although I have noEmit:false
https://github.com/cefn/karma-typescript-failure/blob/master/tsconfig.json#L7 I still get 0 of 0 tests.
It was a shame but I ended up having to completely transform how I built my whole project to be able to use Karma - no longer relying directly on Typescript tooling and having to go via babel=>webpack route. I put together a reference repository with working tests but the different build system at https://github.com/cefn/typescript-karma-counter#readme
I would much rather use karma-typescript!
When inspecting this.config.coverageOptions.exclude I saw that this was set to /\.(d|spec|test)\.ts$/i. Looks like karma-typescript does not exclude *.test.tsx files from coverage instrumentation by default. But this also raises the question, why there is no output for App.test.tsx.
@cefn did you have a chance to take a further look into this? My experience with Karma is that sometimes build errors don't crash the run but cause trouble later in the browser. I could imagine that karma-typescript does not compile tsx files by default and the 0 of 0 in the browser is caused by the test-file failing to load the compilation result.
I did what I could to nudge karma-typescript into doing the right thing with...
https://github.com/cefn/karma-typescript-failure/blob/master/karma.conf.js#L8-L9
https://github.com/cefn/karma-typescript-failure/blob/master/karma.conf.js#L18
https://github.com/cefn/karma-typescript-failure/blob/master/tsconfig.json#L17
However, I think it might take a karma-typescript expert to know what directives it respects, and if there's another one it needs, since this is all 'declarative' so I can't even really step through the procedure to see where it goes wrong.
@D4nte so I gather in your case from #341 (comment) it was resolved by ensuring .js files are emitted.
Yes but not only. Please check my PR https://github.com/status-im/js-waku/pull/230, it took me an afternoon to better understand karma and karma-typescript config options so I can fine tune to perfect. See below:
process.env.CHROME_BIN = require('puppeteer').executablePath(); // Puppeteer installs Chrome for in GitHub Action CI
module.exports = function (config) {
config.set({
frameworks: ['mocha', 'karma-typescript'], // Using mocha and karma-typescript
files: [
'src/lib/**/*.ts', // This contains my library files that can all be ran in the browser
'src/proto/**/*.ts', // Note I have some NodeJS files to help with some test setup, they are NOT in these folders
],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
plugins: [
require('karma-mocha'),
require('karma-typescript'),
require('karma-chrome-launcher'),
],
reporters: ['progress', 'karma-typescript'],
browsers: ['ChromeHeadless'],
singleRun: true,
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /src\/tests\/browser\/.*\.spec\.ts$/, // This is maybe what is missing, I explicitly state what are the test files
},
tsconfig: './tsconfig.karma.json', // See below
coverageOptions: {
instrumentation: false,
},
},
});
};
and tsconfig.karma.json
{
"extends": "./tsconfig",
"compilerOptions": {
"noEmit": false // this should not be necessary but it ensures JS files are emitted
},
"include": [ // I override this value to ONLY include files that can run in the browser, excluding NodeJS test utils (that uses fs, etc)
"src/lib/**/*.ts",
"src/proto/**/*.ts",
"src/tests/browser/**/*.ts"
],
"exclude": ["node_modules/**"] // my `tsconfig.json` files excludes test files to ensure they are not include in the NPM package so I override it to allow the test files to be compiled and ran in the browser.
}
Here is an alternative to avoid the separate tsconfig file, note how I need to use mode: 'replace'
to make it work: d12430e
(#231)
In https://github.com/monounity/karma-typescript/issues/341 many reporters shared an issue they encountered.
After an apparent fix to suppress issues when calculating coverage, we have the remaining situation where karma-typescript runs, but detects 0 tests.
For many it was a dead end meaning they couldn't get karma-typescript to work at all, and could have been that way for 2 years. It's probably just a common misconfiguration but knowing the workaround, or maybe improving error messages could be key to people not getting totally stuck.
REPRODUCING
Since #341 might have quite a few different issues going on for the different posters, I have put together a minimal repro of the configuration which led me to encounter the narrow issue of
Executed 0 of 0
at https://github.com/cefn/karma-typescript-failure and I am reporting it as a new issue.It can be reproduced by running...
The run fails presumably because it has detected 0 tests but I don't know why it doesn't detect the App.test.tsx, although it seems to load the corresponding file.
I don't know if istanbul is connected to the no-detected-tests error, but note, the option
coverageOptions: { instrumentation: false },
was added tokarmaTypescriptConfig
to avoid the fatal error03 07 2021 17:01:22.970:ERROR [karma-server]: UncaughtException: TypeError: Cannot read property 'startsWith' of undefined at Coverage.hasNoOutput (/home/cefn/Desktop/karma-typescript-failure/node_modules/karma-typescript/dist/istanbul/coverage.js:56:38)
THEORY
Theory so far is that some kind of js file output is expected but none actually takes place, meaning App.test.js doesn't exist. However, I don't know what the correct mechanism is meant to be for karma-typescript to hand over the transpiled files, and it claims to 'serve cached'.
03 07 2021 16:59:44.765:DEBUG [middleware:source-files]: Fetching /home/cefn/Desktop/karma-typescript-failure/test/App.test.js 03 07 2021 16:59:44.766:DEBUG [web-server]: serving (cached): /home/cefn/Desktop/karma-typescript-failure/test/App.test.js
FULL FAILING OUTPUT