-
Notifications
You must be signed in to change notification settings - Fork 18
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
Coverage of untested files not collected #90
Comments
note - this is a hack/workaround 🔨 @marekdedic - was stuck with same issue, couldn't find a proper solution for this, but was able to find a workaround for it based on this - jestjs/jest#1211 (comment) the linked issue, creates a file at runtime and with all require statements, instead i added a dummy spec file const glob = require('glob');
const cwd = require('path').join(process.cwd(), 'app', 'modules');
const pattern = '*.svelte';
glob
.sync(pattern, { cwd, matchBase: true, nosort: true })
.forEach((file) => require(file)); |
Can you try to change your I think you have to set this as well: Can you provide a sample repo, where the bug surfaces? |
Hi,I have previously tried both of these, but not both of them at once, which works! Switching back to babel however makes the tests error out completely :/ You can see it in action on this branch of my repo: https://github.com/skaut/shared-drive-mover/tree/svelte-jester-coverage-test |
+1 I also get the same error:
Here is my jest config - import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
verbose: true,
testMatch: ['<rootDir>/src/**/*.test.(js|ts)'],
transform: {
'^.+\\.svelte$': [
'svelte-jester',
{
preprocess: true
}
],
'\\.svg$': '<rootDir>/transformSvg.js',
'^.+\\.(ts|js)$': 'ts-jest',
'.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform'
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleFileExtensions: ['js', 'ts', 'svelte'],
moduleDirectories: ['node_modules', '<rootDir>/src'],
coverageProvider: 'babel', // v8 is still experimental and outputs incorrect coverage stats for us
collectCoverageFrom: ['<rootDir>/src/**/*.(svelte|ts)', '!<rootDir>/src/**/*.stories.svelte'],
coveragePathIgnorePatterns: ['\\.svg$', '/node_modules/'],
};
export default config; Once I add the untested file to a test case, the error for it disappears => @rvisharma thanks for your workaround! |
This issue remains, replicated and documented here: https://github.com/raurir/svelte-code-linting#testing |
+1 having same issue |
I am also experiencing the same issue that @tobiasbueschel and @raurir mentioned, though I am not using Babel in my setup. Here is my module.exports = {
moduleFileExtensions: ['js', 'ts', 'svelte'],
transform: {
'^.+\\.svelte$': [
'svelte-jester',
{
preprocess: true
}
],
'^.+\\.ts$': 'ts-jest'
},
coverageReporters: ['json', 'lcov', 'text', 'clover', 'html'],
collectCoverageFrom: ['src/**/*.{ts,svelte}', '!src/*.d.ts']
}; I get the same error message:
Edit: I added |
I've bumped the jest version from
when trying to include --coverage argument. I get the above error message when using However when using
|
Hi,
in my configuration, I am testing svelte files written in typescript. In my
jest.config.json
I have:With this, coverage is not collected from untested svelte files - I do get coverage of any svelte file that has a test, however, files without any tests are not listed in the coverage report.
I am using
[email protected]
and[email protected]
- I've found similar issues here, but they should've been fixed with these versions...The text was updated successfully, but these errors were encountered: