From c8d5dab261c3de9619d6b1041dc3c5c5e65b44bd Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 18:46:00 +0800 Subject: [PATCH 1/7] feat: mts coverage --- packages/vitest/src/defaults.ts | 2 +- test/coverage-test/src/{index.ts => index.mts} | 0 test/coverage-test/test/coverage.test.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename test/coverage-test/src/{index.ts => index.mts} (100%) diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index 2f2144c1f540..fa7be64ed08a 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -36,7 +36,7 @@ const coverageConfigDefaults = { allowExternal: false, // default extensions used by c8, plus '.vue' and '.svelte' // see https://github.com/istanbuljs/schema/blob/master/default-extension.js - extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte'], + extension: ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte'], } as ResolvedCoverageOptions export const fakeTimersDefaults = { diff --git a/test/coverage-test/src/index.ts b/test/coverage-test/src/index.mts similarity index 100% rename from test/coverage-test/src/index.ts rename to test/coverage-test/src/index.mts diff --git a/test/coverage-test/test/coverage.test.ts b/test/coverage-test/test/coverage.test.ts index 945b0b99167a..218547bf77ef 100644 --- a/test/coverage-test/test/coverage.test.ts +++ b/test/coverage-test/test/coverage.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { pythagoras } from '../src' +import { pythagoras } from '../src/index.mjs' import { implicitElse } from '../src/implicitElse' import { useImportEnv } from '../src/importEnv' From 7044cfe44894fb1a63bcb515be05213df91f01f2 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 19:43:02 +0800 Subject: [PATCH 2/7] test: fix --- test/coverage-test/coverage-test/coverage.istanbul.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/coverage-test/coverage-test/coverage.istanbul.test.ts b/test/coverage-test/coverage-test/coverage.istanbul.test.ts index eecd9b7239a6..2bbdf3c99b4e 100644 --- a/test/coverage-test/coverage-test/coverage.istanbul.test.ts +++ b/test/coverage-test/coverage-test/coverage.istanbul.test.ts @@ -7,7 +7,7 @@ test('istanbul html report', async () => { const files = fs.readdirSync(coveragePath) expect(files).toContain('index.html') - expect(files).toContain('index.ts.html') + expect(files).toContain('index.mts.html') expect(files).toContain('Hello.vue.html') }) From 22f991f6d4dda264f0c7c2461ef7b9c2dc39ce02 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 19:56:45 +0800 Subject: [PATCH 3/7] fix: snapslot --- .../__snapshots__/c8.report.test.ts.snap | 4 +- .../istanbul.report.test.ts.snap | 40 +++++++++---------- 2 files changed, 22 insertions(+), 22 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 f176dbf905c3..2542914a37ee 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 @@ -1426,7 +1426,7 @@ exports[`c8 json report 1`] = ` }, }, }, - "/src/index.ts": { + "/src/index.mts": { "all": false, "b": { "0": [ @@ -1544,7 +1544,7 @@ exports[`c8 json report 1`] = ` "name": "get", }, }, - "path": "/src/index.ts", + "path": "/src/index.mts", "s": { "0": 1, "1": 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 772f7c45f5c1..affeefe9bc20 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 @@ -413,7 +413,7 @@ exports[`istanbul json report 1`] = ` "/src/implicitElse.ts": { "b": { "0": [ - 1, + 2, 0, ], }, @@ -455,7 +455,7 @@ exports[`istanbul json report 1`] = ` }, }, "f": { - "0": 1, + "0": 2, }, "fnMap": { "0": { @@ -484,10 +484,10 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/implicitElse.ts", "s": { - "0": 1, - "1": 1, - "2": 1, - "3": 1, + "0": 2, + "1": 2, + "2": 2, + "3": 2, }, "statementMap": { "0": { @@ -536,7 +536,7 @@ exports[`istanbul json report 1`] = ` "b": {}, "branchMap": {}, "f": { - "0": 1, + "0": 2, }, "fnMap": { "0": { @@ -565,7 +565,7 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/importEnv.ts", "s": { - "0": 1, + "0": 2, }, "statementMap": { "0": { @@ -580,11 +580,11 @@ exports[`istanbul json report 1`] = ` }, }, }, - "/src/index.ts": { + "/src/index.mts": { "b": {}, "branchMap": {}, "f": { - "0": 1, + "0": 2, }, "fnMap": { "0": { @@ -611,9 +611,9 @@ exports[`istanbul json report 1`] = ` "name": "pythagoras", }, }, - "path": "/src/index.ts", + "path": "/src/index.mts", "s": { - "0": 1, + "0": 2, }, "statementMap": { "0": { @@ -909,7 +909,7 @@ exports[`istanbul json report 1`] = ` "b": { "0": [ 0, - 1, + 2, ], }, "branchMap": { @@ -950,10 +950,10 @@ exports[`istanbul json report 1`] = ` }, }, "f": { - "0": 1, - "1": 2, + "0": 2, + "1": 4, "2": 0, - "3": 1, + "3": 2, "4": 0, }, "fnMap": { @@ -1075,12 +1075,12 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/utils.ts", "s": { - "0": 1, - "1": 2, + "0": 2, + "1": 4, "2": 0, - "3": 1, + "3": 2, "4": 0, - "5": 1, + "5": 2, "6": 0, }, "statementMap": { From 6b3e1d3bc63aeb2a8b8aec78a74fd96d1af05888 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 20:04:28 +0800 Subject: [PATCH 4/7] docs: coverage --- docs/config/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/index.md b/docs/config/index.md index bb45d30e206a..a8d089e50792 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -534,7 +534,7 @@ List of files included in coverage as glob patterns #### extension - **Type:** `string | string[]` -- **Default:** `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx', '.vue', '.svelte']` +- **Default:** `['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte']` - **Available for providers:** `'c8' | 'istanbul'` #### exclude From e1bf837b2e71c285cf42c7580fa3a6d0220bf991 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 20:06:42 +0800 Subject: [PATCH 5/7] fix: snapslot --- .../istanbul.report.test.ts.snap | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) 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 affeefe9bc20..721462d2ba83 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 @@ -413,7 +413,7 @@ exports[`istanbul json report 1`] = ` "/src/implicitElse.ts": { "b": { "0": [ - 2, + 1, 0, ], }, @@ -455,7 +455,7 @@ exports[`istanbul json report 1`] = ` }, }, "f": { - "0": 2, + "0": 1, }, "fnMap": { "0": { @@ -484,10 +484,10 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/implicitElse.ts", "s": { - "0": 2, - "1": 2, - "2": 2, - "3": 2, + "0": 1, + "1": 1, + "2": 1, + "3": 1, }, "statementMap": { "0": { @@ -536,7 +536,7 @@ exports[`istanbul json report 1`] = ` "b": {}, "branchMap": {}, "f": { - "0": 2, + "0": 1, }, "fnMap": { "0": { @@ -565,7 +565,7 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/importEnv.ts", "s": { - "0": 2, + "0": 1, }, "statementMap": { "0": { @@ -584,7 +584,7 @@ exports[`istanbul json report 1`] = ` "b": {}, "branchMap": {}, "f": { - "0": 2, + "0": 1, }, "fnMap": { "0": { @@ -613,7 +613,7 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/index.mts", "s": { - "0": 2, + "0": 1, }, "statementMap": { "0": { @@ -909,7 +909,7 @@ exports[`istanbul json report 1`] = ` "b": { "0": [ 0, - 2, + 1, ], }, "branchMap": { @@ -950,10 +950,10 @@ exports[`istanbul json report 1`] = ` }, }, "f": { - "0": 2, - "1": 4, + "0": 1, + "1": 2, "2": 0, - "3": 2, + "3": 1, "4": 0, }, "fnMap": { @@ -1075,12 +1075,12 @@ exports[`istanbul json report 1`] = ` }, "path": "/src/utils.ts", "s": { - "0": 2, - "1": 4, + "0": 1, + "1": 2, "2": 0, - "3": 2, + "3": 1, "4": 0, - "5": 2, + "5": 1, "6": 0, }, "statementMap": { From acccdd9c1dc43b38d2dfb7438af8c44c3d99c2d0 Mon Sep 17 00:00:00 2001 From: yoho <907415276@qq.com> Date: Mon, 12 Dec 2022 20:09:16 +0800 Subject: [PATCH 6/7] chore: update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ari Perkkiƶ --- test/coverage-test/test/coverage.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/coverage-test/test/coverage.test.ts b/test/coverage-test/test/coverage.test.ts index 218547bf77ef..772f0d7da94c 100644 --- a/test/coverage-test/test/coverage.test.ts +++ b/test/coverage-test/test/coverage.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { pythagoras } from '../src/index.mjs' +import { pythagoras } from '../src/index.mts' import { implicitElse } from '../src/implicitElse' import { useImportEnv } from '../src/importEnv' From 14fb2f803d31b783a5f228bfe853ffdfb8195c65 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 12 Dec 2022 20:14:04 +0800 Subject: [PATCH 7/7] chore: reset --- test/coverage-test/test/coverage.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/coverage-test/test/coverage.test.ts b/test/coverage-test/test/coverage.test.ts index 772f0d7da94c..218547bf77ef 100644 --- a/test/coverage-test/test/coverage.test.ts +++ b/test/coverage-test/test/coverage.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { pythagoras } from '../src/index.mts' +import { pythagoras } from '../src/index.mjs' import { implicitElse } from '../src/implicitElse' import { useImportEnv } from '../src/importEnv'