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

chore(test): enable all tests #11725

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
with:
node-version: '14'
cache: 'npm'
- name: Install npm@7
run: npm i -g npm@7
- name: Install npm@8
run: npm i -g npm@8
- name: Install
run: npm ci --prefer-offline
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install npm@7
run: npm i -g npm@7
- name: Install npm@8
run: npm i -g npm@8
- name: Install yarn
run: npm i -g yarn
- name: Install packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
with:
node-version: '14'
cache: 'npm'
- name: Install npm@7
run: npm i -g npm@7
- name: Install npm@8
run: npm i -g npm@8
- name: Install
run: npm ci --prefer-offline
- name: Alex
Expand Down
4 changes: 2 additions & 2 deletions azure-pipelines-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
versionSpec: $(nodeVersion)
displayName: 'Install Node.js'

- script: npm i -g npm@7
displayName: 'Update npm to v7'
- script: npm i -g npm@8
displayName: 'Update npm to v8'

- script: npm ci
displayName: 'Run npm ci'
Expand Down
30 changes: 15 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ jobs:
# ******************************************************************************
# Kitchensink Eject test suite
# ******************************************************************************
# - template: azure-pipelines-test-job.yml
# parameters:
# name: KitchensinkEject
# testScript: tasks/e2e-kitchensink-eject.sh
- 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:
# LinuxNode14: { vmImage: 'ubuntu-latest', nodeVersion: 14.x }
# LinuxNode16: { vmImage: 'ubuntu-latest', nodeVersion: 16.x }
# WindowsNode14: { vmImage: 'windows-2019', nodeVersion: 14.x }
# WindowsNode16: { vmImage: 'windows-2019', nodeVersion: 16.x }
# MacNode14: { vmImage: 'macOS-10.15', nodeVersion: 14.x }
# MacNode16: { vmImage: 'macOS-10.15', nodeVersion: 16.x }
- template: azure-pipelines-test-job.yml
parameters:
name: Behavior
testScript: tasks/e2e-behavior.sh
configurations:
LinuxNode14: { vmImage: 'ubuntu-latest', nodeVersion: 14.x }
LinuxNode16: { vmImage: 'ubuntu-latest', nodeVersion: 16.x }
WindowsNode14: { vmImage: 'windows-2019', nodeVersion: 14.x }
WindowsNode16: { vmImage: 'windows-2019', nodeVersion: 16.x }
MacNode14: { vmImage: 'macOS-10.15', nodeVersion: 14.x }
MacNode16: { vmImage: 'macOS-10.15', nodeVersion: 16.x }

# ******************************************************************************
# Old Node test suite
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"screencast:error": "svg-term --cast jyu19xGl88FQ3poMY8Hbmfw8y --out screencast-error.svg --window --at 12000 --no-cursor",
"alex": "alex .",
"test:integration": "jest test/integration",
"test:behavior": "jest test/fixtures",
"test": "cd packages/react-scripts && node bin/react-scripts.js test",
"format": "prettier --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
},
Expand Down
11 changes: 1 addition & 10 deletions tasks/e2e-behavior.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ set -x
cd ..
root_path=$PWD

if hash npm 2>/dev/null
then
npm i -g --force npm@latest
fi

# Bootstrap monorepo
npm install

# ******************************************************************************
# First, publish the monorepo.
# ******************************************************************************
Expand All @@ -84,8 +76,7 @@ publishToLocalRegistry
# ******************************************************************************

# Run all tests
cd test/
CI=true ../node_modules/.bin/jest -w 2
CI=true npm run test:behavior -- -w 2

# Cleanup
cleanup
8 changes: 0 additions & 8 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ set -x
cd ..
root_path=$PWD

if hash npm 2>/dev/null
then
npm i -g npm@latest
fi

# Bootstrap monorepo
npm install

# ******************************************************************************
# First, publish the monorepo.
# ******************************************************************************
Expand Down
8 changes: 0 additions & 8 deletions tasks/e2e-kitchensink-eject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ if [ "$AGENT_OS" == 'Windows_NT' ]; then
root_path=$(cmd //c cd)
fi

if hash npm 2>/dev/null
then
npm i -g npm@latest
fi

# Bootstrap monorepo
npm install

# ******************************************************************************
# First, publish the monorepo.
# ******************************************************************************
Expand Down
8 changes: 0 additions & 8 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ if [ "$AGENT_OS" == 'Windows_NT' ]; then
root_path=$(cmd //c cd)
fi

if hash npm 2>/dev/null
then
npm i -g npm@latest
fi

# Bootstrap monorepo
npm install

# ******************************************************************************
# First, publish the monorepo.
# ******************************************************************************
Expand Down
22 changes: 7 additions & 15 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,17 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then
exit 1
fi

if hash npm 2>/dev/null
then
npm i -g npm@latest
fi

# Bootstrap monorepo
npm install

# Start the local NPM registry
startLocalRegistry "$root_path"/tasks/verdaccio.yaml

# Lint own code
./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/
./node_modules/.bin/eslint --max-warnings 0 packages/confusing-browser-globals/
./node_modules/.bin/eslint --max-warnings 0 packages/create-react-app/
./node_modules/.bin/eslint --max-warnings 0 packages/eslint-config-react-app/
./node_modules/.bin/eslint --max-warnings 0 packages/react-dev-utils/
./node_modules/.bin/eslint --max-warnings 0 packages/react-error-overlay/src/
./node_modules/.bin/eslint --max-warnings 0 packages/react-scripts/
npx eslint --max-warnings 0 packages/babel-preset-react-app/
npx eslint --max-warnings 0 packages/confusing-browser-globals/
npx eslint --max-warnings 0 packages/create-react-app/
npx eslint --max-warnings 0 packages/eslint-config-react-app/
npx eslint --max-warnings 0 packages/react-dev-utils/
npx eslint --max-warnings 0 packages/react-error-overlay/src/
npx eslint --max-warnings 0 packages/react-scripts/

npm test -w react-error-overlay
if [ "$AGENT_OS" != 'Windows_NT' ]; then
Expand Down
28 changes: 15 additions & 13 deletions tasks/local-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

node_version=14
current_git_branch=`git rev-parse --abbrev-ref HEAD`
git_branch=${current_git_branch}
test_suite=all
interactive=false

function print_help {
echo "Usage: ${0} [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " --node-version <version> the node version to use while testing [12]"
echo " --git-branch <branch> the git branch to checkout for testing [the current one]"
echo " --test-suite <suite> which test suite to use ('all', 'behavior', installs', 'kitchensink', 'kitchensink-eject', 'simple') ['all']"
echo " --interactive gain a bash shell after the test run"
echo " --node-version <version> the node version to use while testing [${node_version}]"
echo " --git-branch <branch> the git branch to checkout for testing [${current_git_branch}]"
echo " --test-suite <suite> which test suite to use ('all', 'behavior', installs', 'kitchensink', 'kitchensink-eject', 'simple') ['${test_suite}']"
echo " --interactive gain a bash shell after the test run [${interactive}]"
echo " --help print this message and exit"
echo ""
}

cd $(dirname $0)

node_version=14
current_git_branch=`git rev-parse --abbrev-ref HEAD`
git_branch=${current_git_branch}
test_suite=all
interactive=false

while [ "$1" != "" ]; do
case $1 in
"--node-version")
Expand Down Expand Up @@ -84,22 +84,24 @@ cd -
mv /var/create-react-app/patch .
git apply patch
rm patch
git add -A
git commit -m 'Apply local changes'
CMD

if [ ${git_branch} != ${current_git_branch} ]; then
apply_changes=''
fi

read -r -d '' command <<- CMD
echo "prefix=~/.npm" > ~/.npmrc
mkdir ~/.npm
export PATH=\$PATH:~/.npm/bin
npm install npm@8 -g
export PATH=\$(npm config get prefix -g)/bin:\$PATH
set -x
git clone /var/create-react-app create-react-app --branch ${git_branch}
cd create-react-app
${apply_changes}
node --version
npm --version
npm ci
set +x
${test_command}
result_code=\$?
Expand Down
1 change: 1 addition & 0 deletions tasks/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ root_path=$PWD

if [ -n "$(git status --porcelain)" ]; then
echo "Your git status is not clean. Aborting.";
git diff
exit 1;
fi

Expand Down
3 changes: 1 addition & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ To only run the webpack messages, type `p` followed by `webpack-message` and pre

### `fixtures/`

Each `fixture/` gets spun up in a temporary directory and has its dependencies installed with Yarn PnP (for speed).<br>
To opt-out of PnP, create a `.disable-pnp` file in the specific fixture directory.
Each `fixture/` gets spun up in a temporary directory and has its dependencies installed.

A global (`testSetup`) is created which has a few interesting properties:

Expand Down
6 changes: 6 additions & 0 deletions test/__shared__/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

module.exports = {
// Increase the timeout for GitHub macOS runner
timeout: 1000 * 60 * (process.env.RUNNER_OS === 'macOS' ? 10 : 5),
};
11 changes: 4 additions & 7 deletions test/fixtures/__shared__/test-setup.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
const path = require('path');
const fs = require('fs-extra');
const TestSetup = require('./util/setup');
const { timeout } = require('../../__shared__/utils');

const fixturePath = path.dirname(module.parent.filename);
const fixtureName = path.basename(fixturePath);
const disablePnp = fs.existsSync(path.resolve(fixturePath, '.disable-pnp'));
const testSetup = new TestSetup(fixtureName, fixturePath, {
pnp: !disablePnp,
});
const testSetup = new TestSetup(fixtureName, fixturePath);

beforeAll(async () => {
await testSetup.setup();
}, 1000 * 60 * 5);
}, timeout);
afterAll(async () => {
await testSetup.teardown();
});

beforeEach(() => jest.setTimeout(1000 * 60 * 5));
beforeEach(() => jest.setTimeout(timeout));

module.exports = testSetup;
4 changes: 2 additions & 2 deletions test/integration/create-react-app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const execa = require('execa');
const { mkdirp, writeFileSync, existsSync, readdirSync } = require('fs-extra');
const { join } = require('path');
const { rmSync } = require('fs');
const { timeout } = require('../../__shared__/utils');

const cli = require.resolve('create-react-app/index.js');

// Increase the timeout for GitHub macOS runner
jest.setTimeout(1000 * 60 * (process.env.RUNNER_OS === 'macOS' ? 10 : 5));
jest.setTimeout(timeout);

const projectName = 'test-app';
const genPath = join(__dirname, projectName);
Expand Down