Files
cypress/cli
Zach Panzarino da3e49bf59 feat: updated scaffolding, new project & user banners, ability to remove scaffolding (#15826)
* update example build scripts

* remove old scaffolding relics

* update

* Fix some issues with scaffolding

* Correctly fix issues with scaffolding

* Replace old onboarding with new banner

* Add ability to remove scaffolded files

* Add banner for new users

* Update tests for new scaffolding

* Compare file sizes before removing

* Add tests for remove file

* Save when user opened cypress rather than boolean

* Update intro link and add tets for banners

* fix small issue

* Update design and copy of onboarding banners

* Update style of new spec file button

* Improve outline button active statE

* Update design of new project a bit more

* Fix specs list tests

* Update banner copy and layout

* Update banner copy and layout

* Switch to docs style alerts

* Fix testing logic

* Update banner styles a bit

* Update banners

* Add confirmation modal for delete specs

* Update tests and fix states

* Upgrade kitchensink dep

* Upgrade kitchen sink version and fix unit tests

* Update integration scaffolding test

* Add further description to warning modal

* Update test for new user and new project case

* Remove check to file tree when removing files

* Update kitchensink version

* Fix edge case where banner could appear when no files have been scaffolded

* Fix tests

* Update styling for 'note' when deleting files

* fix issue with path on windows

* Change remove command

* Fix rm dir

* Fix for windows

* Try to use appveyor to test

* appveyor please

* getting some feedback

* Why doesn't this work

* more info

* I have a feeling this works

* maybe its the other path

* please

* this is the one

* this is it

* this should work

* try reverting that change that might not be needed

* remove appveyor testing scaffolding

Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2021-06-22 10:59:47 -05:00
..

CLI

The CLI is used to build the cypress npm module to be run within a terminal.

The CLI has the following responsibilities:

  • Allow users to print CLI commands
  • Allow users to install the Cypress executable
  • Allow users to print their current Cypress version
  • Allow users to run Cypress tests from the terminal
  • Allow users to open Cypress in the interactive Test Runner.
  • Allow users to verify that Cypress is installed correctly and executable
  • Allow users to manages the Cypress binary cache
  • Allow users to pass in options that change way tests are ran or recorded (browsers used, specfiles ran, grouping, parallelization)

Building

See scripts/build.js. Note that the built npm package will include NPM_README.md as its public README file.

Testing

Automated

From the repo's root, you can run unit tests with:

yarn test-unit --scope cypress
yarn test-watch --scope cypress
yarn test-debug --scope cypress

Updating snaphots

Prepend SNAPSHOT_UPDATE=1 to any test command. See snap-shot-it instructions for more info.

SNAPSHOT_UPDATE=1 yarn test-unit --scope cypress

Type Linting

When testing with dtslint, you may need to remove existing typescript installations before running the type linter (for instance, on OS X, you might rm -rf ~/.dts/typescript-installs) in order to reproduce issues with new versions of typescript (i.e., @next).

Manual

To build and test an NPM package:

  • yarn
  • yarn build

This creates build folder.

  • cd build; yarn pack

This creates an archive, usually named cypress-v<version>.tgz. You can install this archive from other projects, but because there is no corresponding binary yet (probably), skip binary download. For example from inside cypress-example-kitchensink folder

yarn add ~/{your-dirs}/cypress/cli/build/cypress-3.3.1.tgz --ignore-scripts

Which installs the tgz file we have just built from folder Users/jane-lane/{your-dirs}/cypress/cli/build.

Module API

The module API can be tested locally using something like:

/* @ts-ignore */
import cypress from '../../cli/lib/cypress'

const run = cypress.run as (options?: Partial<CypressCommandLine.CypressRunOptions>) => Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>

run({
  spec: './cypress/component/advanced/framer-motion/Motion.spec.tsx',
  testingType: 'component',
  /* @ts-ignore */
  dev: true,
}).then(results => {
  console.log(results)
})

Note that the dev flag is required for local testing, as otherwise the command will fail with a binary error.