【问题标题】:I have an error message when running my test?运行测试时出现错误消息?
【发布时间】:2020-01-12 05:46:24
【问题描述】:
what-is-a-test Message gives the name and height:
Error: Expected 'is 34 inches tall' to include 'Susan'
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toInclude (node_modules/expect/lib/Expectation.js:215:28)
at Context.it (test/index-test.js:19:29)
我不确定需要修复什么。请帮忙。
【问题讨论】:
标签:
javascript
node.js
testing
【解决方案1】:
您已了解如何阅读测试,现在该运行测试了。我们让它变得相当容易。在你现在用来编写 nodejs tests.js 或 nodejs index.js 的同一个终端中,你只需要编写 learn。就是这样!无论在哪个实验室,我们的 Learn 命令都会找出您的位置并运行适当的测试并为您提供结果。
说到结果...让我们谈谈如何阅读测试给出的结果。
阅读测试结果
如果我们现在在终端中运行 learn,你会得到一堆失败的测试。它看起来像这样:
在终端中运行学习的输出
> js-functions-lab@0.1.0 test /Users/joe/Documents/Documents/flatiron/js-what-is-a-test-lab
> mocha -R mocha-multi --reporter-options nyan=-,json=.results.json
0 -_-__,------,
3 -_-__| /\_/\
0 -_-_~|_( x .x)
-_-_ "" ""
0 passing (612ms)
3 failing
1) what-is-a-test Name returns "Susan":
Error: Expected 'Joe' to equal 'Susan'
+ expected - actual
-Joe
+Susan
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
at Context.it (test/index-test.js:6:26)
2) what-is-a-test Height is less than 40:
Error: Expected 74 to be less than 40
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toBeLessThan (node_modules/expect/lib/Expectation.js:156:28)
at Context.it (test/index-test.js:13:28)
3) what-is-a-test Message gives the name and height:
Error: Expected ' is 74 inches tall' to include 'Joe'
at assert (node_modules/expect/lib/assert.js:29:9)
at Expectation.toInclude (node_modules/expect/lib/Expectation.js:215:28)
at Context.it (test/index-test.js:19:29)
npm ERR! Test failed. See above for more details.
Let's break this down a bit. If you look at the line under the cat (I love programmers) you'll see a summary of how the tests went:
0 passing (612ms)
3 failing
更多读取数据请查看此链接js-what-is-a-test-lab-bootcamp-prep