Skip to content

Commit

Permalink
Run jest's tests in the e2e tests (#12202)
Browse files Browse the repository at this point in the history
Co-authored-by: Hu谩ng J霉nli脿ng <jlhwung@gmail.com>
  • Loading branch information
nicolo-ribaudo and JLHwung committed Oct 16, 2020
1 parent 9f83b5a commit 63567f0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
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 takes about 20mins on CircleCI. We run only a few of them
# 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

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, "*");
}
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

0 comments on commit 63567f0

Please sign in to comment.