跳到主要内容
CNode

大家写好node项目后,单元测试用的是什么,最好分享点流程;有案例就更好了

问答
Sslclub发布于 10 年前最后回复 10 年前
543800

github上面 好多都是mocha,jscover;

使用makefile
make test make make run 什么的

TESTS = $(shell find test -type f -name "*.test.js")
TEST_TIMEOUT = 10000
MOCHA_REPORTER = spec
# NPM_REGISTRY = "--registry=http://registry.npm.taobao.org"
NPM_REGISTRY = ""


all: test

install:
	@npm install $(NPM_REGISTRY)

pretest:
	@if ! test -f config.js; then \
		cp config.default.js config.js; \
	fi
	@if ! test -d public/upload; then \
		mkdir public/upload; \
	fi

test: install pretest
	@NODE_ENV=test ./node_modules/mocha/bin/mocha \
		--reporter $(MOCHA_REPORTER) \
		-r should \
		-r test/env \
		--timeout $(TEST_TIMEOUT) \
		$(TESTS)

集成.travis.yml

项目开发中应该用不到makefile travis吧?

查看回复

回复 (5)

D
designsmart#510 年前

常用 mocha。

Q
Qiubaowei#410 年前

mocha吧

S
slclub#310 年前

多谢诸位楼主

S
SunilWang#210 年前

推荐 ava

I
i5ting#110 年前

说3个长常用的

  • mocha
  • jest
  • ava

参与回复

登录后即可参与回复。登录