Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run jest's tests in the e2e tests #12202

Merged
merged 13 commits into from Oct 16, 2020
11 changes: 11 additions & 0 deletions .circleci/config.yml
Expand Up @@ -153,6 +153,14 @@ jobs:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-vue-cli.sh

e2e-jest:
executor: node-executor
steps:
- checkout
- attach_workspace:
at: /tmp/verdaccio-workspace
- run: ./scripts/integration-tests/e2e-jest.sh

workflows:
version: 2
build-standalone:
Expand Down Expand Up @@ -203,3 +211,6 @@ workflows:
- e2e-vue-cli:
requires:
- publish-verdaccio
- e2e-jest:
requires:
- publish-verdaccio
54 changes: 54 additions & 0 deletions scripts/integration-tests/e2e-jest.sh
@@ -0,0 +1,54 @@
#!/bin/bash

#==============================================================================#
# SETUP #
#==============================================================================#

# Start in scripts/integration-tests/ even if run from root directory
cd "$(dirname "$0")" || exit
root="$PWD"

source utils/local-registry.sh
source utils/cleanup.sh

# Echo every command being executed
set -x

# Clone jest
git clone --depth=1 https://github.com/facebook/jest /tmp/jest
cd /tmp/jest || exit

# Update @babel/* dependencies
bump_deps="$root/utils/bump-babel-dependencies.js"
node "$bump_deps"
for d in ./packages/*/
do
(cd "$d"; node "$bump_deps")
done

#==============================================================================#
# ENVIRONMENT #
#==============================================================================#
node -v
yarn --version
python --version

#==============================================================================#
# TEST #
#==============================================================================#

startLocalRegistry "$root"/verdaccio-config.yml
yarn install
yarn dedupe '@babel/*'
yarn build

# The full test suite take about 20mins on CircleCI. We run only a few of them
nicolo-ribaudo marked this conversation as resolved.
Show resolved Hide resolved
# to speed it up.
# The goals of this e2e test are:
# 1) Check that the typescript compilation isn't completely broken
# 2) Make sure that we don't accidentally break jest's usage of the Babel API
CI=true yarn test-ci-partial packages
CI=true yarn test-ci-partial e2e/__tests__/babel
CI=true yarn test-ci-partial e2e/__tests__/transform
Comment on lines +50 to +52
Copy link
Contributor

@SimenB SimenB Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do yarn test-ci-partial --ci packages e2e/__tests__/babel e2e/__tests__/transform?

FWIW I just landed jestjs/jest#10653 which adds test-ci-partial:parallel (which just removes the -i argument) so if you have multiple cores available on CI you can speed it up.

yarn test-ci-partial:parallel --ci --max-workers $(nproc) packages e2e/__tests__/babel e2e/__tests__/transform or something like that


cleanup
10 changes: 5 additions & 5 deletions scripts/integration-tests/utils/bump-babel-dependencies.js
Expand Up @@ -5,23 +5,23 @@ const packageJSONPath = path.resolve(cwd, "./package.json");
const content = JSON.parse(fs.readFileSync(packageJSONPath));

let bumped = false;
function bumpBabelDependency(dependencies) {
function bumpBabelDependency(dependencies, version) {
for (const dep of Object.keys(dependencies)) {
if (dep.startsWith("@babel/") && !dependencies[dep].includes(":")) {
dependencies[dep] = "latest";
dependencies[dep] = version;
bumped = true;
}
}
}

if ("peerDependencies" in content) {
bumpBabelDependency(content.peerDependencies);
bumpBabelDependency(content.peerDependencies, "*");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because yarn was throwing for latest in the peerDependencies

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can simply remove peerDependencies 😈.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will cause problems if one of the packages we test starts using PnP 😛

}
if ("devDependencies" in content) {
bumpBabelDependency(content.devDependencies);
bumpBabelDependency(content.devDependencies, "latest");
}
if ("dependencies" in content) {
bumpBabelDependency(content.dependencies);
bumpBabelDependency(content.dependencies, "latest");
}

if (bumped) {
Expand Down
1 change: 1 addition & 0 deletions scripts/integration-tests/utils/local-registry.sh
Expand Up @@ -19,6 +19,7 @@ function startLocalRegistry {
export YARN_NPM_PUBLISH_REGISTRY="$custom_registry_url"
export YARN_NPM_REGISTRY_SERVER="$custom_registry_url"
export YARN_NPM_AUTH_IDENT="username:password"
export YARN_UNSAFE_HTTP_WHITELIST="localhost"
}

function loginLocalRegistry {
Expand Down