Skip to content

Commit c602be9

Browse files
authored
chore: use c8 for coverage testing (#14961)
* test * fix * fix * test * test * test * test * c8 * d.ts * c8 ci * fix * fix * codecov v3
1 parent 5a9b421 commit c602be9

17 files changed

Lines changed: 99 additions & 32 deletions

File tree

.c8rc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"all": true,
3+
"reporter":["lcov", "text"],
4+
"include": [
5+
"packages/*/lib/**/*.{js,cjs,mjs,ts}",
6+
"codemods/*/lib/**/*.{js,cjs,mjs,ts}",
7+
"eslint/*/lib/**/*.{js,cjs,mjs,ts}"
8+
],
9+
"exclude":[
10+
"packages/babel-standalone/**",
11+
"packages/babel-types/**/generated/*",
12+
"packages/babel-helpers/*/helpers/*",
13+
"packages/babel-core/*/vendor/*"
14+
]
15+
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
make -j test-ci-coverage
6868
yarn test:esm
6969
- name: Upload coverage report
70-
uses: codecov/codecov-action@v1
70+
uses: codecov/codecov-action@v3
7171

7272
test-esm:
7373
name: Test ESM version

Gulpfile.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function generateTraverseHelpers(helperKind) {
154154
return generateHelpers(
155155
`./packages/babel-traverse/scripts/generators/${helperKind}.js`,
156156
`./packages/babel-traverse/src/path/generated/`,
157-
`${helperKind}.ts`,
157+
`${helperKind}.d.ts`,
158158
`@babel/traverse -> ${helperKind}`
159159
);
160160
}

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ test-ci: build-standalone-ci
144144
$(MAKE) test-clean
145145

146146
test-ci-coverage:
147-
BABEL_ENV=test BABEL_COVERAGE=true $(MAKE) bootstrap
148-
BABEL_ENV=test BABEL_COVERAGE=true $(YARN) jest --maxWorkers=100% --ci --coverage
147+
BABEL_ENV=test $(MAKE) bootstrap
148+
BABEL_ENV=test BABEL_COVERAGE=true $(YARN) c8 jest --maxWorkers=100% --ci
149+
rm -rf coverage/tmp
149150

150151
bootstrap-flow:
151152
rm -rf build/flow

Makefile.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile.source.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,11 @@ target["test-only"] = function (args = []) {
374374
};
375375

376376
target["test-cov"] = function () {
377+
target["build"]();
378+
377379
env(
378380
() => {
379-
target["build"]();
380-
yarn(["jest", "--coverage"]);
381+
yarn(["c8", "jest"]);
381382
},
382383
{
383384
BABEL_ENV: "test",

babel.config.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module.exports = function (api) {
2121

2222
const sources = ["packages/*/src", "codemods/*/src", "eslint/*/src"];
2323

24-
const includeCoverage = process.env.BABEL_COVERAGE === "true";
25-
2624
const envOpts = {
2725
shippedProposals: true,
2826
modules: false,
@@ -293,12 +291,6 @@ module.exports = function (api) {
293291
].filter(Boolean),
294292
};
295293

296-
// we need to do this as long as we do not test everything from source
297-
if (includeCoverage) {
298-
config.auxiliaryCommentBefore = "istanbul ignore next";
299-
config.plugins.push("babel-plugin-istanbul");
300-
}
301-
302294
return config;
303295
};
304296

jest.config.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ module.exports = {
1919
runner: supportsESMAndJestLightRunner ? "jest-light-runner" : "jest-runner",
2020

2121
snapshotFormat: { escapeString: true, printBasicPrototype: true },
22+
coverageProvider: "v8",
23+
coverageReporters: ["lcov", "text"],
2224
collectCoverageFrom: [
23-
"packages/*/src/**/*.{js,cjs,mjs,ts}",
24-
"codemods/*/src/**/*.{js,cjs,mjs,ts}",
25-
"eslint/*/src/**/*.{js,cjs,mjs,ts}",
25+
"packages/*/lib/**/*.{js,cjs,mjs,ts}",
26+
"codemods/*/lib/**/*.{js,cjs,mjs,ts}",
27+
"eslint/*/lib/**/*.{js,cjs,mjs,ts}",
2628
],
27-
// coveragePathIgnorePatterns Doesn't work on windows
2829
coveragePathIgnorePatterns: [
2930
"/node_modules/",
3031
"<rootDir>/packages/babel-standalone/",
3132
"/test/(fixtures|tmp|__data__)/",
3233
".*\\.d\\.ts",
3334
"<rootDir>/packages/babel-standalone/.*",
34-
"<rootDir>/packages/babel-types/src/.*/generated/.*",
35-
"<rootDir>/packages/babel-helpers/src/helpers/.*",
36-
"<rootDir>/packages/babel-core/src/vendor/.*",
35+
"<rootDir>/packages/babel-types/.*/generated/.*",
36+
"<rootDir>/packages/babel-helpers/.*/helpers/.*",
37+
"<rootDir>/packages/babel-core/.*/vendor/.*",
3738
],
3839

3940
// The eslint/* packages is tested against ESLint v8, which has dropped support for Node v10.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@typescript-eslint/eslint-plugin": "^5.36.1",
4343
"@typescript-eslint/parser": "^5.36.1",
4444
"babel-plugin-transform-charcodes": "^0.2.0",
45+
"c8": "^7.12.0",
4546
"chalk": "^5.0.0",
4647
"charcodes": "^0.2.0",
4748
"core-js": "^3.25.1",

packages/babel-helper-compilation-targets/src/types.ts renamed to packages/babel-helper-compilation-targets/src/types.d.ts

File renamed without changes.

0 commit comments

Comments
 (0)