在VS Code中指定Jest测试目录

时间:2019-11-20 14:07:56

标签: javascript node.js unit-testing jestjs configuration-files

我在VS Code中以join扩展名使用import smtplib from email import message sent = int(0) while (True): sent = sent + 1 from_addr = 'email@gmail.com' # Must be a gmail adress as the gmail smtp server is used to_addr = ['email@email.com', 'email2@email.com'] subject = 'test!' body = 'test!' msg = message.Message() msg.add_header('from', from_addr) for n in len(to_addr): msg.add_header('To') = ', '.join(to_addr[n]) # Add all entries from to_addr as recipients msg.add_header('subject', subject) msg.set_payload(body) server = smtplib.SMTP('smtp.gmail.com', 587) server.login(from_addr, 'insertyourpasswordhere') # This will also generate an error! server.send_message(msg, from_addr=from_addr, to_addrs=[to_addr]) server.quit() ,并有一个目录jest-test-explorer和另一个test-explorer-ui。测试浏览器侧边栏显示并在两个目录中运行测试,但是我只想在unit tests/目录中查看和运行测试。

我使用bash提示符中的acceptance tests/命令在正确的目录中运行测试,但是配置jest以使其成为默认值的等效方法是什么?我有一个unit tests/文件,其中包含以下内容:

./node_modules/.bin/jest --coverage 'unit tests/'

当我运行命令jest-test.config.js时,它仍然包括测试的第二个目录,并且边栏仍显示其他测试。如何配置Jest仅在指定目录中查找?

1 个答案:

答案 0 :(得分:0)

您可以使用以下命令:

./node_modules/.bin/jest "/unit tests"