-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Executed 0 of 0 ' : No tests detected with Typescript, Jasmine, Enzyme, Karma #480
Comments
I cloned your example and set a breakpoint with at node_modules\karma-typescript\dist\istanbul\coverage.js:35 with conditional 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...
That's one reason for separating out this issue from the many configurations, errors discussed in #341 (depending on what particular workaround for the 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 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 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 |
Thank you for opening this issue, I am facing a similar problem in my repo: waku-org/js-waku#230 with no test being executed Full log:
|
@D4nte so I gather in your case from #341 (comment) it was resolved by ensuring .js files are emitted. I don't know why this doesn't work in my case. Although I have 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! |
@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. |
Yes but not only. Please check my PR waku-org/js-waku#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 {
"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 |
In #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
The text was updated successfully, but these errors were encountered: