# npm test

测试脚本

# 概要

npm test [-- <args>]

aliases: tst, t

# 描述

这将运行在包的 "scripts" 对象的 "test" 属性中指定的预定义命令。

# 例子

{
  "scripts": {
    "test": "node test.js"
  }
}
npm test
> npm@x.x.x test
> node test.js

(test.js output would be here)

# 配置

# ignore-scripts

  • Default: false
  • Type: Boolean

如果为 true, npm 不会运行包中指定的 package.json 文件。

注意

如果设置了 ignore-scripts,那些显式地想要运行特定脚本的命令,比如 npm startnpm stopnpm restartnpm testnpm run-script 仍然会运行它们想要运行的脚本,但是它们不会运行任何前脚本或后脚本。

# script-shell

  • Default: 在 POSIX 系统上为“/bin/sh”,在 Windows 上为“cmd.exe”
  • Type: null | String

用于与 npm execnpm runnpm init <package-spec> 命令一起运行的脚本的 shell。

Last Updated: 4/25/2023, 9:49:29 AM