Unverified Commit d7b23c81 authored by James George's avatar James George Committed by GitHub
Browse files

test(create-react-app): assert for exit code (#10973)

parent 1465357b
main dependabot/npm_and_yarn/follow-redirects-1.14.8 dependabot/npm_and_yarn/nanoid-3.3.1 dependabot/npm_and_yarn/prismjs-1.27.0 github/fork/Aghassi/patch-1 github/fork/AmyShackles/patch-1 github/fork/BenBonno/main github/fork/Bnaya/webpack-ignore-irrelevant-warnings github/fork/BrainEno/yakai911 github/fork/CarlRibbegaardh/feature/filename github/fork/CarlRibbegaardh/feature/tsconfig-config github/fork/CharlesStover/001 github/fork/ChithurajMsys/patch-1 github/fork/CommanderRoot/refactor/rm-deprecated-substr github/fork/DavidKessel/website-update github/fork/DemonHa/add-fullySpecified-cofiguration github/fork/Ekwuno/add-cloudflare-pages-to-deploy github/fork/Emanisay/emanisay27-patch-2 github/fork/Ferri0/patch-1 github/fork/FloydJohn/fix-browser-env github/fork/FontEndArt/main github/fork/GiaKhai/patch-1 github/fork/HAMED-NIYAZI/patch-1 github/fork/Haosik/patch-1 github/fork/HewlettPackard/main github/fork/HollyPony/main github/fork/HugoGEORGET/fix-proxy-middleware-documentation github/fork/HumbertoL/fix/remove-extra-period github/fork/Jarryxin/main github/fork/JensColman/patch-1 github/fork/Jhinpan/patch-1 github/fork/Jiacheng787/main github/fork/KurtGokhan/lint-command github/fork/Lesliemicheal111/patch-1 github/fork/LinusU/disable-tsc-plugin github/fork/M-Usman-Tahir/patch-1 github/fork/M779-star/patch-1 github/fork/Manc/patch github/fork/ManishINN/main github/fork/MarcusMorba/patch-3 github/fork/MartijnHols/fix/12044-dont-install-tailwindcss github/fork/Methuselah96/add-missing-peer-dependencies github/fork/MozhganShafiee/main github/fork/Nareshdhori/circleci-project-setup github/fork/NightWalker9/patch-2 github/fork/NoamGaash/patch-1 github/fork/Ph0enixKM/patch-1 github/fork/Rahim-Chan/fix/filename github/fork/RakeshPotnuru/patch-1 github/fork/RomainTHD/main github/fork/SiegfriedEhret/patch-1 github/fork/TheAli711/main github/fork/TrySound/upgrade-svgr-6 github/fork/VNDRMKT/main github/fork/VoloshchenkoAl/babel-plugin-formatjs github/fork/WesCossick/fix-missing-build-error-paths github/fork/YuanXingH/fix/webpack-tsc-compile-on-error github/fork/ace4port/patch-1 github/fork/acusti/template-comment-typo-fix github/fork/admindivyansh/patch-2 github/fork/adrielcodeco/main github/fork/ajbogh/main github/fork/akolade011/dev github/fork/akuji1993/master github/fork/alexkev/running-tests-recommended-wording github/fork/alexxyzeng/main github/fork/allanzi/patch-1 github/fork/amatissart/fix-webpack-config-glob github/fork/amcgee/feat-auto-publicpath github/fork/andrzej-erli/patch-1 github/fork/atefBB/patch-1 github/fork/await-ovo/fix-docs-add-typescript github/fork/await-ovo/fix-missing-postcss-plugins github/fork/aymans/patch-1 github/fork/benjaminr-ps/add-wds-socket-protocol github/fork/benjaminr-ps/patch-1 github/fork/bhardwajhimanshu219/svgr-webpack-version-upgrade github/fork/binary-person/patch-1 github/fork/bkrausz/patch-1 github/fork/bradoyler/patch-1 github/fork/breyed/patch-1 github/fork/c-w/remove-style-loader github/fork/carlosparreno/v5-fix-splitchunks-issue-prod-build github/fork/cheesestringer/fix-package-lock-json github/fork/cheesestringer/update-measuring-performance github/fork/codybentson2/patch-1 github/fork/cprecioso/no-svgr-url-import github/fork/cszo/homepage-fix github/fork/cybermerlin/hotfix/jest_upgrade github/fork/dan-valentine/Allow-Proxy-to-be-set-by-environment-variables github/fork/daschaa/main github/fork/dblazheski96/entry-path-variable github/fork/ddzz/gha-update github/fork/dedo1911/main github/fork/demurgos/fix/12625-ts-node16 github/fork/demurgos/fix/7147-ts-composite github/fork/derbyshire10/main github/fork/dilanx/patch-1 github/fork/donnygitsome/main github/fork/draculapile/fix/babel-parser-error github/fork/dtran320/patch-1 github/fork/dylan8902/patch-1 github/fork/entropitor/fix-no-emit github/fork/etalab/cra-envs github/fork/eventualbuddha/add-@babel/plugin-proposal-private-property-in-object-dependency github/fork/fivecar/cache_clear_docs github/fork/forana/clear-console github/fork/fupengl/master github/fork/gdethier/main github/fork/geewoo94/config/tailwind github/fork/gergelypap/fix/remove-noopener github/fork/getzelus/patch-1 github/fork/hoangle4/patch-1 github/fork/iansu/drop-node-14 github/fork/iansu/node-17-ci github/fork/improper/bugfix/version-check-breaks-file-path-usage github/fork/izzygld/patch-1 github/fork/jakejakeho/patch-1 github/fork/jameswithers89/patch-1 github/fork/jamidwyer/fix/error-overlay-iframe-axe github/fork/jamirvin/main github/fork/jean-smaug/bump-jest-in-react-scripts github/fork/jmgregory/stable-env-var-order github/fork/joeldenning/cjs-support github/fork/joelparkerhenderson/main github/fork/joey-laminar/patch-1 github/fork/jomarquez21/avoid-casting-on-root-element github/fork/jonatanklosko/jk-stdin-close-exit github/fork/joostlubach/joostlubach-open-browser github/fork/judycodes/patch-1 github/fork/jwalton9/main github/fork/karlhorky/patch-1 github/fork/karlhorky/patch-2 github/fork/kavinkuma6/patch-1 github/fork/khalidwaleed0/patch-1 github/fork/kitsunekyo/feat/allow-postcss-config-override github/fork/kixxer01/patch-1 github/fork/knopp10000/patch-1 github/fork/kopyl/patch-1 github/fork/krreet/swap-babel-out-with-swc-in-start-build-and-test-2 github/fork/larixer/main github/fork/laxsuryavanshi/main github/fork/ldeninski/bugfix/add-missing-cjs-extension-to-webpack-config github/fork/lucabattistini/feat/webpack-svgr-loader github/fork/ludofischer/reduce-noise github/fork/luffy84217/fix-webpack-dev-server-deprecated-option github/fork/maksimdegtyarev/remove-react-import github/fork/manavm1990/main github/fork/mcfedr/cjs-support github/fork/merceyz/merceyz/fix/missing-dependencies github/fork/mkarajohn/fix-absolute-paths-in-jest-config-modulePaths github/fork/modernizer-bot/explicit-path-5 github/fork/mohd-akram/add-eslint-context-rule github/fork/mrduguo/main github/fork/nattwasm/main github/fork/nickmccurdy/add-prettier-config-to-app github/fork/nickmccurdy/feature/remove-remaining-react-imports github/fork/nickmccurdy/move-e2e-tests-to-github-actions github/fork/nickmccurdy/patch-2 github/fork/nickmccurdy/replace-npx github/fork/nickmccurdy/revert-web-vitals github/fork/nnmax/fix/throwAnUnknowError github/fork/oparaskos/patch-1 github/fork/p-avital/patch-2 github/fork/p12tic/fix-dev-server-proxy-broken-origin-header github/fork/pan-alexey/main github/fork/paramt/patch-2 github/fork/pedr0ni/main github/fork/pedro-demeu/patch-1 github/fork/pedromello/patch-1 github/fork/ph-fritsche/update-template github/fork/priyankgandhi/patch-1 github/fork/pstrh/pr/increase-css-module-hash-uniqueness github/fork/pushred/resolve-url-loader-v5 github/fork/puxiao/main github/fork/qubbit/patch-1 github/fork/raix/swap-babel-out-with-swc-in-start-build-and-test github/fork/raix/v5-add-back-support-for-node-builtins github/fork/raix/v5-add-react-runtime-aliases github/fork/raix/v5-fix-react-error-overlay-build github/fork/raix/v5-fix-split-chunks-issue-prod-build github/fork/rannn505/patch-1 github/fork/revolunet/patch-1 github/fork/rgbutov/patch-2 github/fork/rheh/main github/fork/rluvaton/use-module-ids github/fork/rojo20/react-testing-library-docs github/fork/rreckonerr/patch-1 github/fork/rsylvian/patch-1 github/fork/ruckc/websocketurl github/fork/ryo-kagawa/doc-troubleshooting github/fork/sashashura/patch-1 github/fork/saurabhjdas786/patch-1 github/fork/saurabhjdas786/patch-2 github/fork/sbindass-deal/patch-1 github/fork/segheysens/main github/fork/serghei77/patch-1 github/fork/serranom/patch-1 github/fork/sheepsteak/paths github/fork/shfshanyue/fix-inline-chunk github/fork/shhnjk/main github/fork/siddtheone/patch-1 github/fork/sumanthratna/image-optimization2 github/fork/sunil-sharma-999/main github/fork/swayamTA/test_branch github/fork/tanvirstreame/fix-project-directory github/fork/tanvirstreame/update-jest github/fork/tanvirstreame/update-type github/fork/teemezzy/patch-2 github/fork/testower/patch-1 github/fork/tetedacier/patch-1 github/fork/th13vn/main github/fork/tmclo/main github/fork/treuherz/main github/fork/user7564/main github/fork/viswa84/patch-1 github/fork/vlio20/patch-1 github/fork/webbertakken/patch-1 github/fork/wsergent/patch-1 github/fork/xdiegors/patch-2 github/fork/yamankatby/patch-2 github/fork/yicheny/fix_webpack5_cache_invalidation github/fork/ylemkimon/allowed-hosts github/fork/zalox/master github/fork/zenotsai/mr/main/fix_build_cache github/fork/zhaomengfan/main github/fork/zhixiaoqiang/feature/react-dev-utils-export-guessEditor github/fork/zingbretsen/mdx-webpack-bugfix lk/refactor-tests v5.0.1 v5.0.0 react-scripts@5.0.1 react-scripts@5.0.0 react-error-overlay@6.0.11 react-error-overlay@6.0.10 react-dev-utils@12.0.1 react-dev-utils@12.0.0 react-app-polyfill@3.0.0 eslint-config-react-app@7.0.1 eslint-config-react-app@7.0.0 create-react-app@5.0.1 create-react-app@5.0.0 cra-template-typescript@1.2.0 cra-template-typescript@1.1.3 cra-template@1.2.0 cra-template@1.1.3 confusing-browser-globals@1.0.11 babel-preset-react-app@10.0.1 babel-plugin-named-asset-import@0.3.8
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12632Dependabot/npm and yarn/nanoid 3.3.1,!12853brikk
Showing with 24 additions and 6 deletions
+24 -6
......@@ -27,12 +27,18 @@ const genFileExists = f => existsSync(join(genPath, f));
describe('create-react-app', () => {
it('asks to supply an argument if none supplied', async () => {
const { stderr } = await run([], { reject: false });
const { code, stderr } = await run([], { reject: false });
// Assertions
expect(code).toBe(1);
expect(stderr).toContain('Please specify the project directory');
});
it('creates a project on supplying a name as the argument', async () => {
await run([projectName], { cwd: __dirname });
const { code } = await run([projectName], { cwd: __dirname });
// Assert for exit code
expect(code).toBe(0);
// Assert for the generated files
generatedFiles.forEach(file => expect(genFileExists(file)).toBeTruthy());
......@@ -46,11 +52,14 @@ describe('create-react-app', () => {
const pkgJson = join(genPath, 'package.json');
writeFileSync(pkgJson, '{ "foo": "bar" }');
const { stdout } = await run([projectName], {
const { code, stdout } = await run([projectName], {
cwd: __dirname,
reject: false,
});
// Assert for exit code
expect(code).toBe(1);
// Assert for the expected message
expect(stdout).toContain(
`The directory ${projectName} contains files that could conflict`
......@@ -62,18 +71,24 @@ describe('create-react-app', () => {
await mkdirp(genPath);
// Create a project in the current directory
await run(['.'], { cwd: genPath });
const { code } = await run(['.'], { cwd: genPath });
// Assert for exit code
expect(code).toBe(0);
// Assert for the generated files
generatedFiles.forEach(file => expect(genFileExists(file)).toBeTruthy());
});
it('uses yarn as the package manager', async () => {
await run([projectName], {
const { code } = await run([projectName], {
cwd: __dirname,
env: { npm_config_user_agent: 'yarn' },
});
// Assert for exit code
expect(code).toBe(0);
// Assert for the generated files
const generatedFilesWithYarn = [
...generatedFiles.filter(file => file !== 'package-lock.json'),
......@@ -86,10 +101,13 @@ describe('create-react-app', () => {
});
it('creates a project based on the typescript template', async () => {
await run([projectName, '--template', 'typescript'], {
const { code } = await run([projectName, '--template', 'typescript'], {
cwd: __dirname,
});
// Assert for exit code
expect(code).toBe(0);
// Assert for the generated files
[...generatedFiles, 'tsconfig.json'].forEach(file =>
expect(genFileExists(file)).toBeTruthy()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment