Skip to content
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

Incorrect code coverage shown for ts svelte files #32

Closed
juzerzarif opened this issue Mar 18, 2021 · 2 comments
Closed

Incorrect code coverage shown for ts svelte files #32

juzerzarif opened this issue Mar 18, 2021 · 2 comments

Comments

@juzerzarif
Copy link

Hello, I'm using svelte-jester along with svelte-preprocess to test typescript svelte files but the istanbul code coverage shows uncovered branches that don't exist in the svelte file source code.

Jest config:

export default {
  collectCoverage: true,
  collectCoverageFrom: ['src/**/*.ts', 'src/**/*.svelte'],
  coverageDirectory: 'coverage',
  coveragePathIgnorePatterns: ['src/types'],
  coverageReporters: ['json', 'html', 'text'],
  coverageThreshold: {
    global: {
      statements: -10,
      branches: 90,
      functions: 90,
      lines: 90,
    },
  },
  moduleFileExtensions: ['js', 'ts', 'svelte'],
  moduleNameMapper: {
    '\\.html$': '<rootDir>/__mocks__/htmlMock.ts',
  },
  preset: 'ts-jest',
  roots: [process.cwd()],
  setupFiles: ['mutationobserver-shim'],
  setupFilesAfterEnv: ['./jest.setup.ts'],
  testEnvironment: 'jsdom',
  testMatch: ['**/tests/**/*.test.ts'],
  transform: {
    '^.+\\.svelte$': ['svelte-jester', { preprocess: true }],
    '^.+\\.ts$': 'ts-jest',
  },
};

svelte.config.js:

const sveltePreprocess = require('svelte-preprocess');
const tailwind = require('tailwindcss');
const postcssNested = require('postcss-nested');

module.exports = {
  preprocess: sveltePreprocess({
    postcss: {
      plugins: [tailwind, postcssNested],
    },
  }),
};

Coverage report (html):
image

I'm assuming I've got some gaps in configuration, could someone help troubleshoot how I could get a more accurate coverage report?

@mihar-22
Copy link
Collaborator

Hey @juzerzarif this is a duplicate of #28, thanks for raising!

@mihar-22
Copy link
Collaborator

Heads up this is fixed in svelte-jester@1.3.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants