npm方式安装

  1. 安装node.js

    1. 将node.exe所在目录加入环境变量,命令行执行:
      1. >node --version
      2. >npm --version
      验证node.js和npm是否安装成功
  2. 进入项目路径,执行npm init命令生成package.json文件 ```bash ➜ cypress_UI_test npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults.

See npm help init for definitive documentation on these fields and exactly what they do.

Use npm install <pkg> afterwards to install a package and save it as a dependency in the package.json file.

Press ^C at any time to quit. package name: (cypress_ui_test) version: (1.0.0) description: cypress test entry point: (index.js) test command: git repository: keywords: author: zaygee license: (ISC) About to write to /Users/zaygee/cypress_UI_test/package.json:

{ “name”: “cypress_ui_test”, “version”: “1.0.0”, “description”: “cypress test”, “main”: “index.js”, “scripts”: { “test”: “echo \”Error: no test specified\” && exit 1” }, “author”: “zaygee”, “license”: “ISC” }

Is this OK? (yes) yes

  1. 3. 使用npm install cypress --save-dev命令安装Cypress
  2. ```bash
  3. npm install cypress --save-dev

打开Cypress

  1. 方式一:

    1. 进入node_modules/.bin文件夹,输入”cypress open”
      1. node_modules/.bin/cypress open
  2. 方式二:

    1. 打开项目,进入文件package.json
      1. #
      2. "scripts": {
      3. "test": "echo \"Error: no test specified\" && exit 1",
      4. "cypress:open": "cypress open" //新增
      5. },
      b. 使用如下方式打开cypress
      1. # 使用npm打开
      2. npm run cypress:open