Skip to content

Commit

Permalink
chore: Fix coverage test (#14802)
Browse files Browse the repository at this point in the history
* chore: Improve test-cov

* rebase
  • Loading branch information
liuxingbaoyu committed Jul 27, 2022
1 parent 029fa17 commit a151c13
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Expand Up @@ -210,8 +210,7 @@ $ OVERWRITE=true TEST_ONLY=babel-plugin-transform-classes make test-only
To test the code coverage, use:

```sh
$ BABEL_ENV=cov make build
$ ./scripts/test-cov.sh
make test-cov
```

#### Troubleshooting Tests
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Expand Up @@ -81,6 +81,9 @@ fix-json:
clean:
$(MAKEJS) clean

test-cov:
$(MAKEJS) test-cov

test: lint test-only

clone-license:
Expand Down Expand Up @@ -137,14 +140,12 @@ update-env-corejs-fixture:
OVERWRITE=true $(YARN) jest packages/babel-preset-env

test-ci: build-standalone-ci
BABEL_ENV=test $(YARN) jest --maxWorkers=4 --ci
BABEL_ENV=test $(YARN) jest --maxWorkers=100% --ci
$(MAKE) test-clean

# Does not work on Windows
test-ci-coverage: SHELL:=/bin/bash
test-ci-coverage:
BABEL_COVERAGE=true BABEL_ENV=test $(MAKE) bootstrap
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
BABEL_ENV=test BABEL_COVERAGE=true $(MAKE) bootstrap
BABEL_ENV=test BABEL_COVERAGE=true $(YARN) jest --maxWorkers=100% --ci

bootstrap-flow:
rm -rf build/flow
Expand Down
2 changes: 1 addition & 1 deletion Makefile.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Makefile.source.mjs
Expand Up @@ -377,6 +377,19 @@ target["test-only"] = function (args = []) {
yarn(["jest", ...args]);
};

target["test-cov"] = function () {
env(
() => {
target["build"]();
yarn(["jest", "--coverage"]);
},
{
BABEL_ENV: "test",
BABEL_COVERAGE: "true",
}
);
};

/**
* PUBLISH
*/
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Expand Up @@ -37,7 +37,7 @@ module.exports = {
// in production builds. They are marked using the .skip-bundled.js extension.
...(isPublishBundle ? ["\\.skip-bundled\\.js$"] : []),
// Ignore @babel/standalone test in coverage testing because it is not built
...(process.env.TEST_TYPE === "cov"
...(process.env.BABEL_COVERAGE === "true"
? ["<rootDir>/packages/babel-standalone/"]
: []),
],
Expand Down
11 changes: 0 additions & 11 deletions scripts/test-cov.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/test.sh
Expand Up @@ -10,7 +10,7 @@ if [ "$TEST_DEBUG" ]; then
fi

if [ -n "$CI" ]; then
jestArgs+=("--maxWorkers=4")
jestArgs+=("--maxWorkers=100%")
jestArgs+=("--ci")
fi

Expand Down

0 comments on commit a151c13

Please sign in to comment.