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

No coverage when using self-references #460

Closed
RebeccaStevens opened this issue Mar 23, 2023 · 2 comments
Closed

No coverage when using self-references #460

RebeccaStevens opened this issue Mar 23, 2023 · 2 comments

Comments

@RebeccaStevens
Copy link

  • Version: v18.15.0
  • Platform: Linux Beka-PC 5.10.102.1-microsoft-standard-WSL2 Detailed coverage #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

I'm trying to use self-referencing in my test files, but when I do so, I no longer get the correct coverage results.
(A relative import gets the right results).

import foo from "../src/index.ts"; // Finds coverage.
import foo from "my-package";      // Doesn't finds coverage.

My tsconfig.json file contains the dev mapping:

{
  "rootDir": ".",
  "paths": {
    "my-package": ["./src/index.ts"],
  }
}

And my package.json contains the dist mappings:

{
  "name": "my-package",
  "exports": {
    "types": {
      "import": "./dist/index.d.mts",
      "require": "./dist/index.d.cts"
    },
    "import": "./dist/index.mjs",
    "require": "./dist/index.cjs"
  }
}

I'm using ava to run the tests, here's its config (ava.config.mjs):

const avaConfig = {
  files: ["tests/**/*.test.*"],
  timeout: "5m",
  extensions: {
    ts: "module",
  },
  require: [
    "tsconfig-paths/register"
  ],
  nodeArguments: [
    "--loader=ts-node/esm",
    "--experimental-specifier-resolution=node",
  ],
};

export default avaConfig;
@RebeccaStevens
Copy link
Author

Looks like this issue might be that the dist files are being loaded, not the src files.
I'll need to do some more testing; I'll close if this is indeed the cause.

@RebeccaStevens
Copy link
Author

Looks like it was that issue. Using --loader=ts-paths-esm-loader fixed the issue.

@RebeccaStevens RebeccaStevens closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2023
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