From e6a18c743c6d1759482c1878560d4b3583a786e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Sat, 10 Dec 2022 21:20:04 +0200 Subject: [PATCH] fix(coverage-istanbul): clear coverage map after use (#2466) * test: add coverage snapshots * fix(coverage-istanbul): clear coverage map after use - Fixes issues where statement counts were duplicated --- packages/coverage-istanbul/src/index.ts | 8 +- .../coverage.istanbul.test.ts.snap | 1577 +++++++++++++++++ .../coverage-test/coverage.istanbul.test.ts | 30 +- 3 files changed, 1613 insertions(+), 2 deletions(-) create mode 100644 test/coverage-test/coverage-test/__snapshots__/coverage.istanbul.test.ts.snap diff --git a/packages/coverage-istanbul/src/index.ts b/packages/coverage-istanbul/src/index.ts index a88aae227082..de791bc69b33 100644 --- a/packages/coverage-istanbul/src/index.ts +++ b/packages/coverage-istanbul/src/index.ts @@ -7,5 +7,11 @@ export async function getProvider() { export function takeCoverage() { // @ts-expect-error -- untyped global - return globalThis[COVERAGE_STORE_KEY] + const coverage = globalThis[COVERAGE_STORE_KEY] + + // Reset coverage map to prevent duplicate results if this is called twice in row + // @ts-expect-error -- untyped global + globalThis[COVERAGE_STORE_KEY] = {} + + return coverage } diff --git a/test/coverage-test/coverage-test/__snapshots__/coverage.istanbul.test.ts.snap b/test/coverage-test/coverage-test/__snapshots__/coverage.istanbul.test.ts.snap new file mode 100644 index 000000000000..6999f1d883c6 --- /dev/null +++ b/test/coverage-test/coverage-test/__snapshots__/coverage.istanbul.test.ts.snap @@ -0,0 +1,1577 @@ +// Vitest Snapshot v1 + +exports[`istanbul json report 1`] = ` +{ + "/src/Counter/Counter.component.ts": { + "b": {}, + "branchMap": {}, + "f": { + "0": 1, + "1": 0, + "2": 2, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 10, + "line": 6, + }, + "start": { + "column": 2, + "line": 6, + }, + }, + "loc": { + "end": { + "column": null, + "line": 9, + }, + "start": { + "column": 10, + "line": 6, + }, + }, + "name": "(anonymous_0)", + }, + "1": { + "decl": { + "end": { + "column": 22, + "line": 12, + }, + "start": { + "column": 4, + "line": 12, + }, + }, + "loc": { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 22, + "line": 12, + }, + }, + "name": "(anonymous_1)", + }, + "2": { + "decl": { + "end": { + "column": 20, + "line": 16, + }, + "start": { + "column": 4, + "line": 16, + }, + }, + "loc": { + "end": { + "column": null, + "line": 18, + }, + "start": { + "column": 20, + "line": 16, + }, + }, + "name": "(anonymous_2)", + }, + }, + "path": "/src/Counter/Counter.component.ts", + "s": { + "0": 1, + "1": 1, + "2": 0, + "3": 2, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 18, + "line": 7, + }, + }, + "1": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 4, + "line": 8, + }, + }, + "2": { + "end": { + "column": null, + "line": 13, + }, + "start": { + "column": 6, + "line": 13, + }, + }, + "3": { + "end": { + "column": null, + "line": 17, + }, + "start": { + "column": 6, + "line": 17, + }, + }, + }, + }, + "/src/Counter/Counter.vue": { + "b": { + "0": [ + 2, + 1, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + "locations": [ + { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + ], + "type": "binary-expr", + }, + }, + "f": { + "0": 1, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + "loc": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + "name": "(anonymous_1)", + }, + }, + "path": "/src/Counter/Counter.vue", + "s": { + "0": 1, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 18, + "line": 8, + }, + }, + }, + }, + "/src/Defined.vue": { + "b": {}, + "branchMap": {}, + "f": {}, + "fnMap": {}, + "path": "/src/Defined.vue", + "s": { + "0": 1, + "1": 1, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 2, + }, + "start": { + "column": 16, + "line": 2, + }, + }, + "1": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 5, + "line": 6, + }, + }, + }, + }, + "/src/Hello.vue": { + "b": { + "0": [ + 3, + 1, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": 30, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + "locations": [ + { + "end": { + "column": 18, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + { + "end": { + "column": 30, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + ], + "type": "binary-expr", + }, + }, + "f": { + "0": 3, + "1": 2, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 30, + "line": 7, + }, + "start": { + "column": 24, + "line": 7, + }, + }, + "loc": { + "end": { + "column": 55, + "line": 7, + }, + "start": { + "column": 30, + "line": 7, + }, + }, + "name": "(anonymous_1)", + }, + "1": { + "decl": { + "end": { + "column": 18, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + "loc": { + "end": { + "column": 30, + "line": 14, + }, + "start": { + "column": 18, + "line": 14, + }, + }, + "name": "(anonymous_3)", + }, + }, + "path": "/src/Hello.vue", + "s": { + "0": 1, + "1": 1, + "2": 3, + "3": 1, + "4": 2, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 14, + "line": 6, + }, + }, + "1": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 15, + "line": 7, + }, + }, + "2": { + "end": { + "column": 55, + "line": 7, + }, + "start": { + "column": 30, + "line": 7, + }, + }, + "3": { + "end": { + "column": null, + "line": 9, + }, + "start": { + "column": 0, + "line": 9, + }, + }, + "4": { + "end": { + "column": 30, + "line": 14, + }, + "start": { + "column": 18, + "line": 14, + }, + }, + }, + }, + "/src/coverage-report/SFC.vue": { + "b": { + "0": [ + 0, + 0, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + "locations": [ + { + "end": { + "column": 18, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + ], + "type": "binary-expr", + }, + }, + "f": { + "0": 0, + "1": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 10, + "line": 5, + }, + "start": { + "column": 2, + "line": 5, + }, + }, + "loc": { + "end": { + "column": null, + "line": 9, + }, + "start": { + "column": 10, + "line": 5, + }, + }, + "name": "(anonymous_0)", + }, + "1": { + "decl": { + "end": { + "column": 18, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + "loc": { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 18, + "line": 14, + }, + }, + "name": "(anonymous_2)", + }, + }, + "path": "/src/coverage-report/SFC.vue", + "s": { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 10, + }, + "start": { + "column": 18, + "line": 4, + }, + }, + "1": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 18, + "line": 6, + }, + }, + "2": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 4, + "line": 8, + }, + }, + "3": { + "end": { + "column": null, + "line": 15, + }, + "start": { + "column": 2, + "line": 14, + }, + }, + "4": { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 18, + "line": 14, + }, + }, + }, + }, + "/src/coverage-report/math.ts": { + "b": {}, + "branchMap": {}, + "f": { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 20, + "line": 1, + }, + "start": { + "column": 16, + "line": 1, + }, + }, + "loc": { + "end": { + "column": null, + "line": 3, + }, + "start": { + "column": 42, + "line": 1, + }, + }, + "name": "add", + }, + "1": { + "decl": { + "end": { + "column": 25, + "line": 5, + }, + "start": { + "column": 16, + "line": 5, + }, + }, + "loc": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 47, + "line": 5, + }, + }, + "name": "multiply", + }, + "2": { + "decl": { + "end": { + "column": 27, + "line": 9, + }, + "start": { + "column": 16, + "line": 9, + }, + }, + "loc": { + "end": { + "column": null, + "line": 11, + }, + "start": { + "column": 49, + "line": 9, + }, + }, + "name": "untestedFn", + }, + "3": { + "decl": { + "end": { + "column": 28, + "line": 13, + }, + "start": { + "column": 16, + "line": 13, + }, + }, + "loc": { + "end": { + "column": null, + "line": 15, + }, + "start": { + "column": 50, + "line": 13, + }, + }, + "name": "untestedFn2", + }, + }, + "path": "/src/coverage-report/math.ts", + "s": { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 2, + }, + "start": { + "column": 2, + "line": 2, + }, + }, + "1": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 2, + "line": 6, + }, + }, + "2": { + "end": { + "column": null, + "line": 10, + }, + "start": { + "column": 2, + "line": 10, + }, + }, + "3": { + "end": { + "column": null, + "line": 14, + }, + "start": { + "column": 2, + "line": 14, + }, + }, + }, + }, + "/src/coverage-report/not-SFC/not-SFC.ts": { + "b": {}, + "branchMap": {}, + "f": { + "0": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 10, + "line": 4, + }, + "start": { + "column": 2, + "line": 4, + }, + }, + "loc": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 10, + "line": 4, + }, + }, + "name": "(anonymous_0)", + }, + }, + "path": "/src/coverage-report/not-SFC/not-SFC.ts", + "s": { + "0": 0, + "1": 0, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 18, + "line": 5, + }, + }, + "1": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 4, + "line": 7, + }, + }, + }, + }, + "/src/coverage-report/utils.js": { + "b": {}, + "branchMap": {}, + "f": { + "0": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 19, + "line": 1, + }, + "start": { + "column": 16, + "line": 1, + }, + }, + "loc": { + "end": { + "column": 1, + "line": 3, + }, + "start": { + "column": 26, + "line": 1, + }, + }, + "name": "add", + }, + }, + "path": "/src/coverage-report/utils.js", + "s": { + "0": 0, + }, + "statementMap": { + "0": { + "end": { + "column": 14, + "line": 2, + }, + "start": { + "column": 2, + "line": 2, + }, + }, + }, + }, + "/src/implicitElse.ts": { + "b": { + "0": [ + 1, + 0, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 2, + "line": 4, + }, + }, + "locations": [ + { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 2, + "line": 4, + }, + }, + { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 2, + "line": 4, + }, + }, + ], + "type": "if", + }, + }, + "f": { + "0": 1, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 29, + "line": 1, + }, + "start": { + "column": 16, + "line": 1, + }, + }, + "loc": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 49, + "line": 1, + }, + }, + "name": "implicitElse", + }, + }, + "path": "/src/implicitElse.ts", + "s": { + "0": 1, + "1": 1, + "2": 1, + "3": 1, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 2, + }, + "start": { + "column": 10, + "line": 2, + }, + }, + "1": { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 2, + "line": 4, + }, + }, + "2": { + "end": { + "column": null, + "line": 5, + }, + "start": { + "column": 4, + "line": 5, + }, + }, + "3": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 2, + "line": 7, + }, + }, + }, + }, + "/src/importEnv.ts": { + "b": {}, + "branchMap": {}, + "f": { + "0": 1, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 31, + "line": 1, + }, + "start": { + "column": 16, + "line": 1, + }, + }, + "loc": { + "end": { + "column": null, + "line": 3, + }, + "start": { + "column": 31, + "line": 1, + }, + }, + "name": "useImportEnv", + }, + }, + "path": "/src/importEnv.ts", + "s": { + "0": 1, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 2, + }, + "start": { + "column": 2, + "line": 2, + }, + }, + }, + }, + "/src/index.ts": { + "b": {}, + "branchMap": {}, + "f": { + "0": 1, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 27, + "line": 5, + }, + "start": { + "column": 16, + "line": 5, + }, + }, + "loc": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 49, + "line": 5, + }, + }, + "name": "pythagoras", + }, + }, + "path": "/src/index.ts", + "s": { + "0": 1, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 2, + "line": 6, + }, + }, + }, + }, + "/src/untested-file.ts": { + "b": { + "0": [ + 0, + 0, + ], + "1": [ + 0, + 0, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": null, + "line": 24, + }, + "start": { + "column": 2, + "line": 21, + }, + }, + "locations": [ + { + "end": { + "column": null, + "line": 24, + }, + "start": { + "column": 2, + "line": 21, + }, + }, + { + "end": { + "column": null, + "line": 24, + }, + "start": { + "column": 2, + "line": 21, + }, + }, + ], + "type": "if", + }, + "1": { + "loc": { + "end": { + "column": null, + "line": 29, + }, + "start": { + "column": 2, + "line": 26, + }, + }, + "locations": [ + { + "end": { + "column": null, + "line": 29, + }, + "start": { + "column": 2, + "line": 26, + }, + }, + { + "end": { + "column": null, + "line": 29, + }, + "start": { + "column": 2, + "line": 26, + }, + }, + ], + "type": "if", + }, + }, + "f": { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 39, + "line": 6, + }, + "start": { + "column": 24, + "line": 6, + }, + }, + "loc": { + "end": { + "column": null, + "line": 8, + }, + "start": { + "column": 39, + "line": 6, + }, + }, + "name": "untestedFile", + }, + "1": { + "decl": { + "end": { + "column": 13, + "line": 10, + }, + "start": { + "column": 9, + "line": 10, + }, + }, + "loc": { + "end": { + "column": null, + "line": 13, + }, + "start": { + "column": 35, + "line": 10, + }, + }, + "name": "add", + }, + "2": { + "decl": { + "end": { + "column": 18, + "line": 15, + }, + "start": { + "column": 9, + "line": 15, + }, + }, + "loc": { + "end": { + "column": null, + "line": 18, + }, + "start": { + "column": 40, + "line": 15, + }, + }, + "name": "multiply", + }, + "3": { + "decl": { + "end": { + "column": 21, + "line": 20, + }, + "start": { + "column": 16, + "line": 20, + }, + }, + "loc": { + "end": { + "column": null, + "line": 33, + }, + "start": { + "column": 64, + "line": 20, + }, + }, + "name": "math", + }, + }, + "path": "/src/untested-file.ts", + "s": { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 2, + "line": 7, + }, + }, + "1": { + "end": { + "column": null, + "line": 12, + }, + "start": { + "column": 2, + "line": 12, + }, + }, + "2": { + "end": { + "column": null, + "line": 17, + }, + "start": { + "column": 2, + "line": 17, + }, + }, + "3": { + "end": { + "column": null, + "line": 24, + }, + "start": { + "column": 2, + "line": 21, + }, + }, + "4": { + "end": { + "column": null, + "line": 23, + }, + "start": { + "column": 4, + "line": 23, + }, + }, + "5": { + "end": { + "column": null, + "line": 29, + }, + "start": { + "column": 2, + "line": 26, + }, + }, + "6": { + "end": { + "column": null, + "line": 28, + }, + "start": { + "column": 4, + "line": 28, + }, + }, + "7": { + "end": { + "column": null, + "line": 32, + }, + "start": { + "column": 2, + "line": 32, + }, + }, + }, + }, + "/src/utils.ts": { + "b": { + "0": [ + 0, + 1, + ], + }, + "branchMap": { + "0": { + "loc": { + "end": { + "column": null, + "line": 16, + }, + "start": { + "column": 2, + "line": 15, + }, + }, + "locations": [ + { + "end": { + "column": null, + "line": 16, + }, + "start": { + "column": 2, + "line": 15, + }, + }, + { + "end": { + "column": null, + "line": 16, + }, + "start": { + "column": 2, + "line": 15, + }, + }, + ], + "type": "if", + }, + }, + "f": { + "0": 1, + "1": 2, + "2": 0, + "3": 1, + "4": 0, + }, + "fnMap": { + "0": { + "decl": { + "end": { + "column": 20, + "line": 1, + }, + "start": { + "column": 16, + "line": 1, + }, + }, + "loc": { + "end": { + "column": null, + "line": 3, + }, + "start": { + "column": 42, + "line": 1, + }, + }, + "name": "add", + }, + "1": { + "decl": { + "end": { + "column": 25, + "line": 5, + }, + "start": { + "column": 16, + "line": 5, + }, + }, + "loc": { + "end": { + "column": null, + "line": 7, + }, + "start": { + "column": 47, + "line": 5, + }, + }, + "name": "multiply", + }, + "2": { + "decl": { + "end": { + "column": 23, + "line": 9, + }, + "start": { + "column": 16, + "line": 9, + }, + }, + "loc": { + "end": { + "column": null, + "line": 12, + }, + "start": { + "column": 45, + "line": 9, + }, + }, + "name": "divide", + }, + "3": { + "decl": { + "end": { + "column": 21, + "line": 14, + }, + "start": { + "column": 16, + "line": 14, + }, + }, + "loc": { + "end": { + "column": null, + "line": 19, + }, + "start": { + "column": 32, + "line": 14, + }, + }, + "name": "sqrt", + }, + "4": { + "decl": { + "end": { + "column": 22, + "line": 21, + }, + "start": { + "column": 16, + "line": 21, + }, + }, + "loc": { + "end": { + "column": null, + "line": 24, + }, + "start": { + "column": 22, + "line": 21, + }, + }, + "name": "run", + }, + }, + "path": "/src/utils.ts", + "s": { + "0": 1, + "1": 2, + "2": 0, + "3": 1, + "4": 0, + "5": 1, + "6": 0, + }, + "statementMap": { + "0": { + "end": { + "column": null, + "line": 2, + }, + "start": { + "column": 2, + "line": 2, + }, + }, + "1": { + "end": { + "column": null, + "line": 6, + }, + "start": { + "column": 2, + "line": 6, + }, + }, + "2": { + "end": { + "column": null, + "line": 11, + }, + "start": { + "column": 2, + "line": 11, + }, + }, + "3": { + "end": { + "column": null, + "line": 16, + }, + "start": { + "column": 2, + "line": 15, + }, + }, + "4": { + "end": { + "column": null, + "line": 16, + }, + "start": { + "column": 4, + "line": 16, + }, + }, + "5": { + "end": { + "column": null, + "line": 18, + }, + "start": { + "column": 2, + "line": 18, + }, + }, + "6": { + "end": { + "column": null, + "line": 23, + }, + "start": { + "column": 2, + "line": 23, + }, + }, + }, + }, +} +`; diff --git a/test/coverage-test/coverage-test/coverage.istanbul.test.ts b/test/coverage-test/coverage-test/coverage.istanbul.test.ts index eecd9b7239a6..5c131176c282 100644 --- a/test/coverage-test/coverage-test/coverage.istanbul.test.ts +++ b/test/coverage-test/coverage-test/coverage.istanbul.test.ts @@ -2,6 +2,16 @@ import fs from 'fs' import { normalize, resolve } from 'pathe' import { expect, test } from 'vitest' +interface CoverageFinalJson { + default: { + [filename: string]: { + path: string + b: Record + // ... and more unrelated keys + } + } +} + test('istanbul html report', async () => { const coveragePath = resolve('./coverage/src') const files = fs.readdirSync(coveragePath) @@ -23,6 +33,20 @@ test('istanbul lcov report', async () => { expect(lcovReportFiles).toContain('index.html') }) +test('istanbul json report', async () => { + // @ts-expect-error -- generated file + const { default: jsonReport } = await import('./coverage/coverage-final.json') as CoverageFinalJson + + const normalizedReport: CoverageFinalJson['default'] = {} + + for (const [filename, coverage] of Object.entries(jsonReport)) { + coverage.path = normalizeFilename(coverage.path) + normalizedReport[normalizeFilename(filename)] = coverage + } + + expect(normalizedReport).toMatchSnapshot() +}) + test('all includes untested files', () => { const coveragePath = resolve('./coverage/src') const files = fs.readdirSync(coveragePath) @@ -42,7 +66,7 @@ test('files should not contain query parameters', () => { test('implicit else is included in branch count', async () => { // @ts-expect-error -- generated file - const { default: coverageMap } = await import('./coverage/coverage-final.json') + const { default: coverageMap } = await import('./coverage/coverage-final.json') as CoverageFinalJson const filename = normalize(resolve('./src/implicitElse.ts')) const fileCoverage = coverageMap[filename] @@ -57,3 +81,7 @@ test('file using import.meta.env is included in report', async () => { expect(files).toContain('importEnv.ts.html') }) + +function normalizeFilename(filename: string) { + return filename.replace(normalize(process.cwd()), '') +}