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

added e2e test for checking typescript template with unsupported node #7844

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 92 additions & 79 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,92 @@
#
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS.
#

trigger:
- master

variables:
CI: true
# Overrides the Yarn and NPM cache directories so they are on the same drive as the source. This helps improve build performance on Windows hosted agents.
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache
# Sets TEMP to be on the same drive as the cloned source on Windows. This avoids test scripts that "cd" into a directory under TEMP from failing because this directory is on a different drive from the current directory.
VSTS_OVERWRITE_TEMP: True
# Override Verdaccio package to use. This is temporary and is needed to avoid socket timeouts on hosted Windows agent (on Azure). This also changes Verdaccio to return a 503 (service unavailable) instead of a 404 (not found) when the connection to the uplink timesout.
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz
CRA_INTERNAL_TEST: true

# ******************************************************************************
# Simple test suite
# ******************************************************************************
jobs:
- template: azure-pipelines-test-job.yml
parameters:
name: Simple
testScript: tasks/e2e-simple.sh

# ******************************************************************************
# Installs test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Installs
testScript: tasks/e2e-installs.sh

# ******************************************************************************
# Kitchensink test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Kitchensink
testScript: tasks/e2e-kitchensink.sh

# ******************************************************************************
# Kitchensink Eject test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: KitchensinkEject
testScript: tasks/e2e-kitchensink-eject.sh

# ******************************************************************************
# Behavior test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Behavior
testScript: tasks/e2e-behavior.sh
configurations:
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
# WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
# WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x }
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x }

# ******************************************************************************
# Old Node test suite
# ******************************************************************************
- job: OldNode
pool:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
inputs:
versionSpec: 6.x
displayName: 'Install Node.js 6.x'
- bash: tasks/e2e-old-node.sh
displayName: 'Run tests'
#
# Azure Pipelines configuration for building and testing create-react-app on Linux, Windows, and macOS.
#

trigger:
- master

variables:
CI: true
# Overrides the Yarn and NPM cache directories so they are on the same drive as the source. This helps improve build performance on Windows hosted agents.
YARN_CACHE_FOLDER: $(Build.SourcesDirectory)/../yarn-cache
NPM_CONFIG_CACHE: $(Build.SourcesDirectory)/../npm-cache
# Sets TEMP to be on the same drive as the cloned source on Windows. This avoids test scripts that "cd" into a directory under TEMP from failing because this directory is on a different drive from the current directory.
VSTS_OVERWRITE_TEMP: True
# Override Verdaccio package to use. This is temporary and is needed to avoid socket timeouts on hosted Windows agent (on Azure). This also changes Verdaccio to return a 503 (service unavailable) instead of a 404 (not found) when the connection to the uplink timesout.
VERDACCIO_PACKAGE: https://github.com/willsmythe/verdaccio/releases/download/create-react-app/verdaccio-4.0.0-alpha.8.tgz
CRA_INTERNAL_TEST: true

# ******************************************************************************
# Simple test suite
# ******************************************************************************
jobs:
- template: azure-pipelines-test-job.yml
parameters:
name: Simple
testScript: tasks/e2e-simple.sh

# ******************************************************************************
# Installs test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Installs
testScript: tasks/e2e-installs.sh

# ******************************************************************************
# Kitchensink test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Kitchensink
testScript: tasks/e2e-kitchensink.sh

# ******************************************************************************
# Kitchensink Eject test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: KitchensinkEject
testScript: tasks/e2e-kitchensink-eject.sh

# ******************************************************************************
# Behavior test suite
# ******************************************************************************
- template: azure-pipelines-test-job.yml
parameters:
name: Behavior
testScript: tasks/e2e-behavior.sh
configurations:
LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x }
LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x }
# WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x }
# WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x }
MacNode8: { vmImage: 'macOS-10.13', nodeVersion: 8.x }
MacNode10: { vmImage: 'macOS-10.13', nodeVersion: 10.x }

# ******************************************************************************
# Old Node test suite
# ******************************************************************************
- job: OldNode
pool:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
inputs:
versionSpec: 6.x
displayName: 'Install Node.js 6.x'
- bash: tasks/e2e-old-node.sh
displayName: 'Run tests'
# ******************************************************************************
# Unsupported Node with TypeScript flag
# ******************************************************************************
- job: UnsupportedNodeWithTypeScript
pool:
vmImage: ubuntu-16.04
steps:
- task: NodeTool@0
inputs:
versionSpec: 8.9.x
displayName: 'Install Node.js 8.9.x'
- bash: tasks/e2e-typescript-unsupported-node.sh
displayName: 'Run unsupported TypeScript test'
2 changes: 1 addition & 1 deletion packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function createApp(
) {
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=8.10.0');
if (unsupportedNodeVersion && useTypeScript) {
console.log(
console.error(
chalk.red(
`You are using Node ${process.version} with the TypeScript template. Node 8.10 or higher is required to use TypeScript.\n`
)
Expand Down
61 changes: 61 additions & 0 deletions tasks/e2e-typescript-unsupported-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# Copyright (c) 2015-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# ******************************************************************************
# This is an end-to-end test intended to run on CI.
# You can also run it locally but it's slow.
# ******************************************************************************

# Start in tasks/ even if run from root directory
cd "$(dirname "$0")"

temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`

function cleanup {
echo 'Cleaning up.'
cd "$root_path"
rm -rf $temp_app_path
}

# Error messages are redirected to stderr
function handle_error {
echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2;
cleanup
echo 'Exiting with error.' 1>&2;
exit 1
}

function handle_exit {
cleanup
echo 'Exiting without error.' 1>&2;
exit
}

# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR

# Cleanup before exit on any termination signal
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP

# Echo every command being executed
set -x

# Go to root
cd ..
root_path=$PWD

# We need to install create-react-app deps to test it
cd "$root_path"/packages/create-react-app
npm install
cd "$root_path"

# If the node version is < 8.10 but greater then 8.0, the script with the typescript flag should just give an error.
cd $temp_app_path
err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version --typescript 2>&1 > /dev/null || echo ''`
[[ $err_output =~ You\ are\ using\ Node ]] && exit 0 || exit 1

# Cleanup
cleanup