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

nyc report returns instrumented files instead of raw code #1576

Open
4 tasks done
1dukky opened this issue Jul 25, 2024 · 0 comments
Open
4 tasks done

nyc report returns instrumented files instead of raw code #1576

1dukky opened this issue Jul 25, 2024 · 0 comments

Comments

@1dukky
Copy link

1dukky commented Jul 25, 2024

Here is a setup that I am using:
I have an angular app that I instrument using nyc instrument --in-place command.
Then, I build a dev build npm run build:dev and serve it via http-server
I then run a set of tests using cypress after following the guide for cypress to understand and use the instrumentation (https://docs.cypress.io/guides/tooling/code-coverage).
After tests complete I recieve .nyc_output and coverage folders (inside cypress folder), which indicates cypress actually uses the instrumentation correctly, but code inside is instrumented, which makes it unreadable for human.
(while application is located in ./main/app, tests are located in ./main/tests)

.nycrc file:

{
  "parser-plugins": [
    "typescript",
    "decorators"
  ],
  "include": [
    "**/*.component.ts",
    "**/*.service.ts"
  ],
  "source-map": true,
  "cache": false,
  "require": [
    "ts-node/register",
    "source-map-support/register"
  ]
}

webpack-config.js file (one that is used in cypress):

module: {
    rules: [
      {
        test: /\.m?js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              ['@babel/preset-env', { targets: 'defaults' }],
            ],
            plugins: ['@babel/plugin-transform-runtime'],
          },
        },
      },
    ],
  },

Expected Behavior

Inside the lcov' or html` report, I recieve raw application code which allows me to check which functions/methods are used inside the components.

Observed Behavior

Inside the lcov or html report, I recieve instrumented code instead of raw, image below
image

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config
  • tried adding various babel plugins
  • added typescript and decorators to parser-plugins
  • tried moving .nyc-output file to "main" application folder (main/app) and generating new report using nyc report --reporter=html

Environment Information

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1
    Memory: 185.83 MB / 16.00 GB
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    pnpm: 7.30.0 - ~/.nvm/versions/node/v16.16.0/bin/pnpm
  npmPackages:
    @babel/plugin-proposal-optional-chaining: ^7.21.0 => 7.21.0
    @babel/plugin-transform-optional-chaining: ^7.24.7 => 7.24.7
    @babel/plugin-transform-runtime: ^7.24.7 => 7.24.7
    babel-plugin-istanbul: ^7.0.0 => 7.0.0
    typescript: ~4.0.2 => 4.0.8
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

1 participant