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

Exclude remote dependencies from deno coverage #21784

Closed
bartlomieju opened this issue Jan 4, 2024 · 0 comments · Fixed by #24008
Closed

Exclude remote dependencies from deno coverage #21784

bartlomieju opened this issue Jan 4, 2024 · 0 comments · Fixed by #24008
Assignees
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@bartlomieju
Copy link
Member

bartlomieju commented Jan 4, 2024

call.ts

// deno-lint-ignore no-explicit-any
export type CallableFn = (...args: any[]) => any;
export interface Callable<CallableFunction extends CallableFn> {
  (...args: Parameters<CallableFunction>): ReturnType<CallableFunction>;
}
export class Callable<CallableFunction extends CallableFn> extends Function {
  public constructor(callable: CallableFunction) {
    super("...args", `return this["_"](...args)`);
    // deno-lint-ignore no-explicit-any
    const t = this as any;
    t["_"] = callable;
    const _bound = this.bind(this);
    return t._bound = _bound;
  }
}
export default Callable;

call.test.ts

import { assertStrictEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import Callable from "./call.ts";
Deno.test("Creates a callable from Callable.", () => {
  const callable = new Callable((value: unknown) => value);
  for (let i = 0; i < 10; i++) {
    assertStrictEquals(callable(i), i);
    const random = Math.random();
    assertStrictEquals(callable(random), random);
  }
});
$ deno test --coverage
$ deno coverage
$ ls coverage/
01bfbaa5-81b9-4ac9-b85e-eb72eec0021f.json  87b254c9-043c-4c1c-a9bc-86dcfeef17a7.json
0900dc0c-1f4c-4e5a-b2f6-502750097aed.json  8e074a64-71f8-4844-b6c8-b43fa2bf5377.json
0a8dd72e-8f92-4ae8-b290-9482ec8e868a.json  8ef89d1b-deee-4e97-9d86-09f850d0bba3.json
17828dca-4d40-4ab0-a909-69d001858d43.json  9094bbb2-eccf-4fd2-a2a7-d2cd74e88377.json
2317162d-91c0-4658-9f0d-02ebfa4a21cc.json  9339b584-481e-4076-8baa-9588fcf4e4cd.json
25fa3cc7-59f5-49ad-beca-f1c450f1401c.json  94efde6b-dce9-4316-bfba-737c454ddd63.json
2f1c5d65-68af-4515-9ed8-c2e40b6d3b95.json  97cbf7cc-98e9-460f-9c3b-e599e15ddc4e.json
31dd9901-ceb7-4d82-bb25-1d07e42f8bb8.json  999d44be-eaad-4501-b06b-17e9def717a5.json
43faf044-2af5-4a58-8830-1aa5b52a0f6c.json  a9b22ba2-ded4-4447-9eb5-cb3e0b5eac53.json
5fa7f0d3-29f7-4ae3-a56c-f5a87ec077f7.json  b106d9be-aeb9-4c38-83bb-6eec9d8a65c0.json
61cb515a-9176-4dfb-b5ce-5954fcf68c07.json  b487fa65-dd6b-46e1-bef2-9f0a75c57db9.json
6504a7ad-4da9-4ee5-a31c-af333e75a077.json  c7538d2d-a54c-48fb-897b-da9bcda6b331.json
6777158a-0714-4993-9fc6-98249941cd74.json  cff93bda-837d-42cc-8b31-2e05347c7502.json
75c931be-ec34-48ca-a603-6b7b02dba01f.json  d2b0d8a1-52e9-40e1-80bc-433f0d7989c2.json
77c65432-970b-4ce5-b0e1-c242d936210c.json  d55b829a-333d-47ea-9f92-60abd0d3d9c8.json
7b232e79-7aed-44ef-a6e0-22a720ea3a07.json  e066322f-5455-4dca-bead-3d89dcd3eb9e.json
7d3e2826-972f-4fd3-9fbc-6f2a6a7b26d6.json  f781d20a-fd76-48c8-b221-5b0d72b4bff6.json
81485d7d-eede-40af-ac92-96b127cd03e2.json

This will generate coverage directory with multiple files in it. Out of these files only a single one is relevant for this use case - all the remaining ones are for https://deno.land/[email protected]/* modules. I think we should exclude remote dependencies (http, https, npm) from generating coverage files.

Version: Deno 1.39.1

@bartlomieju bartlomieju added bug Something isn't working correctly testing related to deno test and coverage labels Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants