npm方式安装
安装node.js
- 将node.exe所在目录加入环境变量,命令行执行:
验证node.js和npm是否安装成功>node --version
>npm --version
- 将node.exe所在目录加入环境变量,命令行执行:
进入项目路径,执行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
3. 使用npm install cypress --save-dev命令安装Cypress
```bash
npm install cypress --save-dev
打开Cypress
方式一:
- 进入node_modules/.bin文件夹,输入”cypress open”
node_modules/.bin/cypress open
- 进入node_modules/.bin文件夹,输入”cypress open”
方式二:
- 打开项目,进入文件package.json
b. 使用如下方式打开cypress#
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"cypress:open": "cypress open" //新增
},
# 使用npm打开
npm run cypress:open
- 打开项目,进入文件package.json