运行包定义的测试脚本。
yarn test
如果你的包里有一个定义好的 scripts 对象,这个命令会运行指定的 test 脚本。
例如,如果你的包里有一个 bash 脚本 scripts/test:
1. #!/bin/bash
3. echo "Hello, world!"
并且下面是你 package.json 里的:
1. {
2. "name": "my-tribute-package",
3. "version": "1.0.0",
4. "description":
5. "This is not the best package in the world, this is just a tribute.",
6. "main": "index.js",
7. "author": "Yarn Contributor",
8. "license": "MIT",
9. "scripts": {
10. "test": "scripts/test"
11. }
12. }
那么运行 yarn test 将得到:
1. $ yarn test
2. yarn test v0.15.1
3. $ "./scripts/test"
4. Hello, world!
5. ✨ Done in 0.17s.
yarn run test
yarn test 也是 yarn run test 的快捷命令。
