From 548bd49efa2839c28287a745ae0f374898ebdba2 Mon Sep 17 00:00:00 2001 From: AriPerkkio Date: Sat, 31 Dec 2022 12:51:14 +0200 Subject: [PATCH] test: add failing test case for #2540 --- .../__snapshots__/c8.report.test.ts.snap | 356 +----------------- .../istanbul.report.test.ts.snap | 35 ++ .../src/Counter/Counter.component.ts | 4 + 3 files changed, 44 insertions(+), 351 deletions(-) diff --git a/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap b/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap index bf75cc04c8a3..52f3cb922d85 100644 --- a/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap +++ b/test/coverage-test/coverage-report-tests/__snapshots__/c8.report.test.ts.snap @@ -4,369 +4,23 @@ exports[`c8 json report 1`] = ` { "/src/Counter/Counter.component.ts": { "all": false, - "b": { - "0": [ - 1, - ], - "1": [ - 2, - ], - }, - "branchMap": { - "0": { - "line": 6, - "loc": { - "end": { - "column": 4, - "line": 9, - }, - "start": { - "column": 2, - "line": 6, - }, - }, - "locations": [ - { - "end": { - "column": 4, - "line": 9, - }, - "start": { - "column": 2, - "line": 6, - }, - }, - ], - "type": "branch", - }, - "1": { - "line": 16, - "loc": { - "end": { - "column": 6, - "line": 18, - }, - "start": { - "column": 4, - "line": 16, - }, - }, - "locations": [ - { - "end": { - "column": 6, - "line": 18, - }, - "start": { - "column": 4, - "line": 16, - }, - }, - ], - "type": "branch", - }, - }, - "f": { - "0": 1, - "1": 0, - "2": 2, - }, - "fnMap": { - "0": { - "decl": { - "end": { - "column": 4, - "line": 9, - }, - "start": { - "column": 2, - "line": 6, - }, - }, - "line": 6, - "loc": { - "end": { - "column": 4, - "line": 9, - }, - "start": { - "column": 2, - "line": 6, - }, - }, - "name": "setup", - }, - "1": { - "decl": { - "end": { - "column": 6, - "line": 14, - }, - "start": { - "column": 4, - "line": 12, - }, - }, - "line": 12, - "loc": { - "end": { - "column": 6, - "line": 14, - }, - "start": { - "column": 4, - "line": 12, - }, - }, - "name": "uncoveredMethod", - }, - "2": { - "decl": { - "end": { - "column": 6, - "line": 18, - }, - "start": { - "column": 4, - "line": 16, - }, - }, - "line": 16, - "loc": { - "end": { - "column": 6, - "line": 18, - }, - "start": { - "column": 4, - "line": 16, - }, - }, - "name": "coveredMethod", - }, - }, + "b": {}, + "branchMap": {}, + "f": {}, + "fnMap": {}, "path": "/src/Counter/Counter.component.ts", "s": { "0": 1, - "1": 1, - "10": 1, - "11": 1, - "12": 0, - "13": 0, - "14": 1, - "15": 1, - "16": 2, - "17": 2, - "18": 1, - "19": 1, - "2": 1, - "3": 1, - "4": 1, - "5": 1, - "6": 1, - "7": 1, - "8": 1, - "9": 1, }, "statementMap": { "0": { "end": { - "column": 42, - "line": 1, - }, - "start": { "column": 0, "line": 1, }, - }, - "1": { - "end": { - "column": 0, - "line": 2, - }, - "start": { - "column": 0, - "line": 2, - }, - }, - "10": { - "end": { - "column": 12, - "line": 11, - }, "start": { "column": 0, - "line": 11, - }, - }, - "11": { - "end": { - "column": 23, - "line": 12, - }, - "start": { - "column": 0, - "line": 12, - }, - }, - "12": { - "end": { - "column": 46, - "line": 13, - }, - "start": { - "column": 0, - "line": 13, - }, - }, - "13": { - "end": { - "column": 6, - "line": 14, - }, - "start": { - "column": 0, - "line": 14, - }, - }, - "14": { - "end": { - "column": 0, - "line": 15, - }, - "start": { - "column": 0, - "line": 15, - }, - }, - "15": { - "end": { - "column": 21, - "line": 16, - }, - "start": { - "column": 0, - "line": 16, - }, - }, - "16": { - "end": { - "column": 42, - "line": 17, - }, - "start": { - "column": 0, - "line": 17, - }, - }, - "17": { - "end": { - "column": 6, - "line": 18, - }, - "start": { - "column": 0, - "line": 18, - }, - }, - "18": { - "end": { - "column": 4, - "line": 19, - }, - "start": { - "column": 0, - "line": 19, - }, - }, - "19": { - "end": { - "column": 2, - "line": 20, - }, - "start": { - "column": 0, - "line": 20, - }, - }, - "2": { - "end": { - "column": 32, - "line": 3, - }, - "start": { - "column": 0, - "line": 3, - }, - }, - "3": { - "end": { - "column": 18, - "line": 4, - }, - "start": { - "column": 0, - "line": 4, - }, - }, - "4": { - "end": { - "column": 0, - "line": 5, - }, - "start": { - "column": 0, - "line": 5, - }, - }, - "5": { - "end": { - "column": 11, - "line": 6, - }, - "start": { - "column": 0, - "line": 6, - }, - }, - "6": { - "end": { - "column": 24, - "line": 7, - }, - "start": { - "column": 0, - "line": 7, - }, - }, - "7": { - "end": { - "column": 20, - "line": 8, - }, - "start": { - "column": 0, - "line": 8, - }, - }, - "8": { - "end": { - "column": 4, - "line": 9, - }, - "start": { - "column": 0, - "line": 9, - }, - }, - "9": { - "end": { - "column": 0, - "line": 10, - }, - "start": { - "column": 0, - "line": 10, + "line": 1, }, }, }, diff --git a/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap b/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap index 721462d2ba83..1a268c4af53e 100644 --- a/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap +++ b/test/coverage-test/coverage-report-tests/__snapshots__/istanbul.report.test.ts.snap @@ -9,6 +9,7 @@ exports[`istanbul json report 1`] = ` "0": 1, "1": 0, "2": 2, + "3": 0, }, "fnMap": { "0": { @@ -80,6 +81,29 @@ exports[`istanbul json report 1`] = ` }, "name": "(anonymous_2)", }, + "3": { + "decl": { + "end": { + "column": 37, + "line": 20, + }, + "start": { + "column": 4, + "line": 20, + }, + }, + "loc": { + "end": { + "column": null, + "line": 22, + }, + "start": { + "column": 37, + "line": 20, + }, + }, + "name": "(anonymous_3)", + }, }, "path": "/src/Counter/Counter.component.ts", "s": { @@ -87,6 +111,7 @@ exports[`istanbul json report 1`] = ` "1": 1, "2": 0, "3": 2, + "4": 0, }, "statementMap": { "0": { @@ -129,6 +154,16 @@ exports[`istanbul json report 1`] = ` "line": 17, }, }, + "4": { + "end": { + "column": null, + "line": 21, + }, + "start": { + "column": 6, + "line": 21, + }, + }, }, }, "/src/Counter/Counter.vue": { diff --git a/test/coverage-test/src/Counter/Counter.component.ts b/test/coverage-test/src/Counter/Counter.component.ts index 372a62ad459a..fb1e1f16566b 100644 --- a/test/coverage-test/src/Counter/Counter.component.ts +++ b/test/coverage-test/src/Counter/Counter.component.ts @@ -16,5 +16,9 @@ export default defineComponent({ coveredMethod() { return 'This line should be covered' }, + + uncoveredMethodUsingImportMeta() { + return `Source maps tend to break when import meta is used: ${import.meta.env.BASE_URL}` + }, }, })