运行测试时出现错误消息?

时间:2020-01-12 05:46:24

标签: javascript node.js testing

 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)

我不确定需要修复什么。请帮忙。

1 个答案:

答案 0 :(得分:0)

您了解如何阅读测试,现在该运行测试了。我们已经相当容易了。在您现在用来编写nodejs tests.js或nodejs index.js的同一终端中,您只需要编写学习即可。而已!无论在什么实验室,我们的“学习”命令都会弄清楚您的位置并运行适当的测试并为您提供结果。

说到结果...让我们谈谈如何读取测试给您的结果。

阅读测试结果

如果我们现在在终端中运行学习,您将遇到一堆失败的测试。看起来像这样:

在终端中运行学习的输出

> 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