Coder Social home page Coder Social logo

Comments (5)

koshic avatar koshic commented on August 15, 2024

@viveleroi c8 doesn't work with TS, because Node.js doesn't support TS. So, please provide .js source which is not covered, or complete setup (tsconfig, etc.) to reproduce it.

from c8.

viveleroi avatar viveleroi commented on August 15, 2024

It's marking the as const portion of this code snipped as "function not covered":

chrome_T4AMQ2uhcn

export const QueryModeValues = ['button', 'live'] as const
type QueryModes = (typeof QueryModeValues)[number]

We're using vite and configs are pretty standard, only real changes are the base url, paths, includes. Our tsconfig.json:

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": "app",
    "paths": {
      "@/*": ["./app/*"]
    }
  },
  "include": ["app", "./tests/components/setup.ts", ".storybook/*.ts"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

from c8.

koshic avatar koshic commented on August 15, 2024

@viveleroi it's a bit funny because you have 'noEmit: true' in tsconfig ) Sourcemaps are not enabled too. Ok, lets add all necessary things:

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "sourceMap": true
  }
}

Then create 1.ts:

export const QueryModeValues = ["button", "live"] as const;

// some code to ensure that source maps are avalid
const x: string = "lalala";

console.log(x);

Run 'yarn tsc && yarn c8 --all --include '*.js' --reporter text --reporter html node 1.js' (latest package versions, latest node)

Results:
image
image

100% coverage, as you can see

PS forget to use '--enable-source-maps' node option because I have it enabled globally.

from c8.

viveleroi avatar viveleroi commented on August 15, 2024

I don't appreciate being told my issue is funny, these configs are essentially unchanged (paths only, I didn't touch emit) from what vite created so don't act like this is my mistake. Vitest is our test runner and they're using c8 for coverage, I'm not going to run this tool outside of those packages.

from c8.

koshic avatar koshic commented on August 15, 2024

Sure, I mean only provided configuration is funny, not the problem itself - which is may be very annoying and frustrating.

BTW, we found one fact: in given setup c8 works correctly with 'as const' statements. Obvious assumption - the issue is somewhere between your code and c8.

You can try to create vitest issue, or provide minimal repo here. Without your particular setup it's impossible to find issue 'somewhere around vitest'.

from c8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.